From 91887865818bda76ea62a12c00ee3096a5380981 Mon Sep 17 00:00:00 2001 From: beegee-tokyo Date: Tue, 10 Sep 2024 11:58:25 +0800 Subject: [PATCH] Fix #ifndef and rename the variant --- platformio.ini | 2 +- src/mqtt/MQTT.cpp | 12 +++++----- .../platformio.ini | 24 ++++++++++++------- .../variant.cpp | 0 .../variant.h | 0 5 files changed, 23 insertions(+), 15 deletions(-) rename variants/{rak4631_mqtt_json => rak4631_eth_gw}/platformio.ini (80%) rename variants/{rak4631_mqtt_json => rak4631_eth_gw}/variant.cpp (100%) rename variants/{rak4631_mqtt_json => rak4631_eth_gw}/variant.h (100%) diff --git a/platformio.ini b/platformio.ini index c10128609..f47b801ce 100644 --- a/platformio.ini +++ b/platformio.ini @@ -29,7 +29,7 @@ default_envs = tbeam ;default_envs = meshtastic-dr-dev ;default_envs = m5stack-coreink ;default_envs = rak4631 -;default_envs = rak4631_mqtt_json +;default_envs = rak4631_eth_gw ;default_envs = rak2560 ;default_envs = rak10701 ;default_envs = wio-e5 diff --git a/src/mqtt/MQTT.cpp b/src/mqtt/MQTT.cpp index 63bdd5bba..33a22e5d4 100644 --- a/src/mqtt/MQTT.cpp +++ b/src/mqtt/MQTT.cpp @@ -379,13 +379,13 @@ void MQTT::sendSubscriptions() std::string topic = cryptTopic + channels.getGlobalId(i) + "/+"; LOG_INFO("Subscribing to %s\n", topic.c_str()); pubSub.subscribe(topic.c_str(), 1); // FIXME, is QOS 1 right? -// #ifndef ARCH_NRF52 // JSON is not supported on nRF52, see issue #2804 ### Fixed by using ArduinoJSON ### +#if !defined(ARCH_NRF52) || defined(NRF52_USE_JSON) // JSON is not supported on nRF52, see issue #2804 ### Fixed by using ArduinoJSON ### if (moduleConfig.mqtt.json_enabled == true) { std::string topicDecoded = jsonTopic + channels.getGlobalId(i) + "/+"; LOG_INFO("Subscribing to %s\n", topicDecoded.c_str()); pubSub.subscribe(topicDecoded.c_str(), 1); // FIXME, is QOS 1 right? } -// #endif // ARCH_NRF52 +#endif // ARCH_NRF52 NRF52_USE_JSON } } #if !MESHTASTIC_EXCLUDE_PKI @@ -480,7 +480,7 @@ void MQTT::publishQueuedMessages() publish(topic.c_str(), bytes, numBytes, false); -// #ifndef ARCH_NRF52 // JSON is not supported on nRF52, see issue #2804 ### Fixed by using ArduinoJson ### +#if !defined(ARCH_NRF52) || defined(NRF52_USE_JSON) // JSON is not supported on nRF52, see issue #2804 ### Fixed by using ArduinoJson ### if (moduleConfig.mqtt.json_enabled) { // handle json topic auto jsonString = MeshPacketSerializer::JsonSerialize(env->packet); @@ -496,7 +496,7 @@ void MQTT::publishQueuedMessages() publish(topicJson.c_str(), jsonString.c_str(), false); } } -// #endif // ARCH_NRF52 +#endif // ARCH_NRF52 NRF52_USE_JSON mqttPool.release(env); } } @@ -562,7 +562,7 @@ void MQTT::onSend(const meshtastic_MeshPacket &mp, const meshtastic_MeshPacket & publish(topic.c_str(), bytes, numBytes, false); -// #ifndef ARCH_NRF52 // JSON is not supported on nRF52, see issue #2804 ### Fixed by using ArduinoJson ### +#if !defined(ARCH_NRF52) || defined(NRF52_USE_JSON) // JSON is not supported on nRF52, see issue #2804 ### Fixed by using ArduinoJson ### if (moduleConfig.mqtt.json_enabled) { // handle json topic auto jsonString = MeshPacketSerializer::JsonSerialize((meshtastic_MeshPacket *)&mp_decoded); @@ -573,7 +573,7 @@ void MQTT::onSend(const meshtastic_MeshPacket &mp, const meshtastic_MeshPacket & publish(topicJson.c_str(), jsonString.c_str(), false); } } -// #endif // ARCH_NRF52 +#endif // ARCH_NRF52 NRF52_USE_JSON } else { LOG_INFO("MQTT not connected, queueing packet\n"); if (mqttQueue.numFree() == 0) { diff --git a/variants/rak4631_mqtt_json/platformio.ini b/variants/rak4631_eth_gw/platformio.ini similarity index 80% rename from variants/rak4631_mqtt_json/platformio.ini rename to variants/rak4631_eth_gw/platformio.ini index 5d459a91a..bf8713293 100644 --- a/variants/rak4631_mqtt_json/platformio.ini +++ b/variants/rak4631_eth_gw/platformio.ini @@ -1,21 +1,29 @@ ; The very slick RAK wireless RAK 4631 / 4630 board - Unified firmware for 5005/19003, with or without OLED RAK 1921 -[env:rak4631_mqtt_json] +[env:rak4631_eth_gw] extends = nrf52840_base board = wiscore_rak4631 board_check = true -build_flags = ${nrf52840_base.build_flags} -Ivariants/rak4631_mqtt_json -D RAK_4631 +build_flags = ${nrf52840_base.build_flags} -Ivariants/rak4631_eth_gw -D RAK_4631 -L "${platformio.libdeps_dir}/${this.__env__}/bsec2/src/cortex-m4/fpv4-sp-d16-hard" -DGPS_POWER_TOGGLE ; comment this line to disable triple press function on the user button to turn off gps entirely. -DEINK_DISPLAY_MODEL=GxEPD2_213_BN -DEINK_WIDTH=250 -DEINK_HEIGHT=122 -DNRF52_USE_JSON=1 -; -DMESHTASTIC_EXCLUDE_GPS=1 + -DMESHTASTIC_EXCLUDE_GPS=1 -DMESHTASTIC_EXCLUDE_WIFI=1 ; -DMESHTASTIC_EXCLUDE_SCREEN=1 - -DMESHTASTIC_EXCLUDE_PKI=1 +; -DMESHTASTIC_EXCLUDE_PKI=1 -DMESHTASTIC_EXCLUDE_POWER_FSM=1 -build_src_filter = ${nrf52_base.build_src_filter} +<../variants/rak4631_mqtt_json> + + + + -DMESHTASTIC_EXCLUDE_POWERMON=1 + -DMESHTASTIC_EXCLUDE_TZ=1 + -DMESHTASTIC_EXCLUDE_EXTERNALNOTIFICATION=1 + -DMESHTASTIC_EXCLUDE_PAXCOUNTER=1 + -DMESHTASTIC_EXCLUDE_REMOTEHARDWARE=1 + -DMESHTASTIC_EXCLUDE_STOREFORWARD=1 + -DMESHTASTIC_EXCLUDE_CANNEDMESSAGES=1 + -DMESHTASTIC_EXCLUDE_WAYPOINT=1 +build_src_filter = ${nrf52_base.build_src_filter} +<../variants/rak4631_eth_gw> + + + lib_deps = ${nrf52840_base.lib_deps} ${networking_base.lib_deps} @@ -31,7 +39,7 @@ lib_deps = ; Allows programming and debug via the RAK NanoDAP as the default debugger tool for the RAK4631 (it is only $10!) ; programming time is about the same as the bootloader version. ; For information on this see the meshtastic developers documentation for "Development on the NRF52" -[env:rak4631_mqtt_json_dbg] +[env:rak4631_eth_gw_dbg] extends = env:rak4631 board_level = extra @@ -39,11 +47,11 @@ board_level = extra ; platform_packages = platformio/tool-openocd@^3.1200.0 build_flags = - ${env:rak4631_mqtt_json.build_flags} + ${env:rak4631_eth_gw.build_flags} -D USE_SEMIHOSTING lib_deps = - ${env:rak4631_mqtt_json.lib_deps} + ${env:rak4631_eth_gw.lib_deps} https://github.com/geeksville/Armduino-Semihosting.git#35b538fdf208c3530c1434cd099a08e486672ee4 ; NOTE: the pyocd support for semihosting is buggy. So I switched to using the builtin platformio support for the stlink adapter which worked much better. diff --git a/variants/rak4631_mqtt_json/variant.cpp b/variants/rak4631_eth_gw/variant.cpp similarity index 100% rename from variants/rak4631_mqtt_json/variant.cpp rename to variants/rak4631_eth_gw/variant.cpp diff --git a/variants/rak4631_mqtt_json/variant.h b/variants/rak4631_eth_gw/variant.h similarity index 100% rename from variants/rak4631_mqtt_json/variant.h rename to variants/rak4631_eth_gw/variant.h