diff --git a/docs/software/esp32-arduino-build-notes.md b/docs/software/esp32-arduino-build-notes.md index b9fd6850..94b64f62 100644 --- a/docs/software/esp32-arduino-build-notes.md +++ b/docs/software/esp32-arduino-build-notes.md @@ -12,5 +12,12 @@ you'll automatically get our fixed libraries. https://docs.espressif.com/projects/esp-idf/en/release-v3.3/get-started/linux-setup.html kevinh@kevin-server:~/development/meshtastic/esp32-arduino-lib-builder\$ python /home/kevinh/development/meshtastic/esp32-arduino-lib-builder/esp-idf/components/esptool*py/esptool/esptool.py --chip esp32 --port /dev/ttyUSB0 --baud 921600 --before default_reset --after hard_reset write_flash -z --flash_mode dout --flash_freq 40m --flash_size detect 0x1000 /home/kevinh/development/meshtastic/esp32-arduino-lib-builder/build/bootloader/bootloader.bin cp -a out/tools/sdk/* components/arduino/tools/sdk - cp -ar components/arduino/* ~/.platformio/packages/framework-arduinoespressif32@src-fba9d33740f719f712e9f8b07da6ea13/ + cp -ar components/arduino/* ~/.platformio/packages/framework-arduinoespressif32 + + /// @src-fba9d33740f719f712e9f8b07da6ea13/ + + or + + cp -ar out/tools/sdk/* ~/.platformio/packages/framework-arduinoespressif32/tools/sdk + ``` diff --git a/platformio.ini b/platformio.ini index b7343e9b..bbf8ffbd 100644 --- a/platformio.ini +++ b/platformio.ini @@ -37,13 +37,6 @@ build_flags = -Wno-missing-field-initializers -Isrc -Isrc/mesh -Isrc/gps -Ilib/n -DAPP_VERSION=${sysenv.APP_VERSION} -DHW_VERSION=${sysenv.HW_VERSION} -; not needed included in ttgo-t-beam board file -; also to use PSRAM https://docs.platformio.org/en/latest/platforms/espressif32.html#external-ram-psram -; -DBOARD_HAS_PSRAM -; -mfix-esp32-psram-cache-issue - -; -DLOG_LOCAL_LEVEL=ESP_LOG_DEBUG -DCORE_DEBUG_LEVEL=ARDUHAL_LOG_LEVEL_DEBUG - ; leave this commented out to avoid breaking Windows ;upload_port = /dev/ttyUSB0 ;monitor_port = /dev/ttyUSB0 @@ -92,6 +85,13 @@ lib_ignore = segger_rtt platform_packages = framework-arduinoespressif32 @ https://github.com/meshtastic/arduino-esp32.git#b7f106cd11a04573b902228ea97025c8b5814dd9 +; not needed included in ttgo-t-beam board file +; also to use PSRAM https://docs.platformio.org/en/latest/platforms/espressif32.html#external-ram-psram +; -DBOARD_HAS_PSRAM +; -mfix-esp32-psram-cache-issue + +; -DLOG_LOCAL_LEVEL=ESP_LOG_DEBUG -DCORE_DEBUG_LEVEL=ARDUHAL_LOG_LEVEL_DEBUG + ; The 1.0 release of the TBEAM board [env:tbeam] extends = esp32_base diff --git a/src/esp32/BluetoothSoftwareUpdate.cpp b/src/esp32/BluetoothSoftwareUpdate.cpp index 3b455b56..a1143e96 100644 --- a/src/esp32/BluetoothSoftwareUpdate.cpp +++ b/src/esp32/BluetoothSoftwareUpdate.cpp @@ -1,6 +1,5 @@ #include "BluetoothSoftwareUpdate.h" #include "BluetoothUtil.h" -#include "CallbackCharacteristic.h" #include "RadioLibInterface.h" #include "configuration.h" #include "../concurrency/LockGuard.h" @@ -11,7 +10,9 @@ #include #include -//using namespace meshtastic; +#ifdef CONFIG_BLUEDROID_ENABLED + +#include "CallbackCharacteristic.h" CRC32 crc; uint32_t rebootAtMsec = 0; // If not zero we will reboot at this time (used to reboot shortly after the update completes) @@ -176,4 +177,6 @@ void destroyUpdateService() assert(resultC); resultC = NULL; -} \ No newline at end of file +} + +#endif diff --git a/src/esp32/BluetoothSoftwareUpdate.h b/src/esp32/BluetoothSoftwareUpdate.h index 60517a7f..80b32ffc 100644 --- a/src/esp32/BluetoothSoftwareUpdate.h +++ b/src/esp32/BluetoothSoftwareUpdate.h @@ -5,7 +5,11 @@ #include #include +#ifdef CONFIG_BLUEDROID_ENABLED + BLEService *createUpdateService(BLEServer *server, std::string hwVendor, std::string swVersion, std::string hwVersion); void destroyUpdateService(); -void bluetoothRebootCheck(); \ No newline at end of file +void bluetoothRebootCheck(); + +#endif \ No newline at end of file diff --git a/src/esp32/BluetoothUtil.cpp b/src/esp32/BluetoothUtil.cpp index 03b7c974..cc2e3422 100644 --- a/src/esp32/BluetoothUtil.cpp +++ b/src/esp32/BluetoothUtil.cpp @@ -6,6 +6,8 @@ #include #include +#ifdef CONFIG_BLUEDROID_ENABLED + SimpleAllocator btPool; bool _BLEClientConnected = false; @@ -321,3 +323,12 @@ void loopBLE() { bluetoothRebootCheck(); } + +#else + +/// Given a level between 0-100, update the BLE attribute +void updateBatteryLevel(uint8_t level) {} +void deinitBLE() {} +void loopBLE() {} + +#endif diff --git a/src/esp32/BluetoothUtil.h b/src/esp32/BluetoothUtil.h index 67797a0c..4773cb54 100644 --- a/src/esp32/BluetoothUtil.h +++ b/src/esp32/BluetoothUtil.h @@ -8,8 +8,7 @@ #include #include "SimpleAllocator.h" -// Now handled by BluetoothUtil.cpp -// BLEService *createDeviceInfomationService(BLEServer* server, uint8_t sig, uint16_t vid, uint16_t pid, uint16_t version); +#ifdef CONFIG_BLUEDROID_ENABLED // Help routine to add a description to any BLECharacteristic and add it to the service void addWithDesc(BLEService *service, BLECharacteristic *c, const char *description); @@ -23,11 +22,9 @@ uint32_t getValue32(BLECharacteristic *c, uint32_t defaultValue); using StartBluetoothPinScreenCallback = std::function; using StopBluetoothPinScreenCallback = std::function; -void loopBLE(); BLEServer *initBLE( StartBluetoothPinScreenCallback startBtPinScreen, StopBluetoothPinScreenCallback stopBtPinScreen, std::string devName, std::string hwVendor, std::string swVersion, std::string hwVersion = ""); -void deinitBLE(); /// Add a characteristic that we will delete when we restart BLECharacteristic *addBLECharacteristic(BLECharacteristic *c); @@ -35,8 +32,12 @@ BLECharacteristic *addBLECharacteristic(BLECharacteristic *c); /// Add a characteristic that we will delete when we restart BLEDescriptor *addBLEDescriptor(BLEDescriptor *c); -/// Given a level between 0-100, update the BLE attribute -void updateBatteryLevel(uint8_t level); - /// Any bluetooth objects you allocate _must_ come from this pool if you want to be able to call deinitBLE() extern SimpleAllocator btPool; + +#endif + +/// Given a level between 0-100, update the BLE attribute +void updateBatteryLevel(uint8_t level); +void deinitBLE(); +void loopBLE(); \ No newline at end of file diff --git a/src/esp32/MeshBluetoothService.cpp b/src/esp32/MeshBluetoothService.cpp index 9bc41459..a087d3be 100644 --- a/src/esp32/MeshBluetoothService.cpp +++ b/src/esp32/MeshBluetoothService.cpp @@ -1,11 +1,7 @@ -#include "MeshBluetoothService.h" -#include "BluetoothUtil.h" -#include -#include -#include -#include -#include "CallbackCharacteristic.h" +#include +#include + #include "GPS.h" #include "MeshService.h" #include "NodeDB.h" @@ -15,6 +11,14 @@ #include "mesh-pb-constants.h" #include "mesh.pb.h" +#ifdef CONFIG_BLUEDROID_ENABLED + +#include +#include +#include "CallbackCharacteristic.h" +#include "BluetoothUtil.h" +#include "MeshBluetoothService.h" + // This scratch buffer is used for various bluetooth reads/writes - but it is safe because only one bt operation can be in // proccess at once static uint8_t trBytes[_max(_max(_max(_max(ToRadio_size, RadioConfig_size), User_size), MyNodeInfo_size), FromRadio_size)]; @@ -141,3 +145,10 @@ void destroyMeshBluetoothService() meshFromNumCharacteristic = NULL; } + +#else + +void destroyMeshBluetoothService() {} +void stopMeshBluetoothService() {} + +#endif \ No newline at end of file diff --git a/src/esp32/MeshBluetoothService.h b/src/esp32/MeshBluetoothService.h index 17916fa9..c0a95a0b 100644 --- a/src/esp32/MeshBluetoothService.h +++ b/src/esp32/MeshBluetoothService.h @@ -4,12 +4,11 @@ #include #include +#ifdef CONFIG_BLUEDROID_ENABLED + BLEService *createMeshBluetoothService(BLEServer *server); + +#endif + void destroyMeshBluetoothService(); - -/** - * Tell any bluetooth clients that the number of rx packets has changed - */ -void bluetoothNotifyFromNum(uint32_t newValue); - void stopMeshBluetoothService(); \ No newline at end of file diff --git a/src/esp32/main-esp32.cpp b/src/esp32/main-esp32.cpp index 0a0b98cd..666e47b0 100644 --- a/src/esp32/main-esp32.cpp +++ b/src/esp32/main-esp32.cpp @@ -17,9 +17,7 @@ void reinitBluetooth() { DEBUG_MSG("Starting bluetooth\n"); - // FIXME - we are leaking like crazy - // AllocatorScope scope(btPool); - +#ifdef CONFIG_BLUEDROID_ENABLED // Note: these callbacks might be coming in from a different thread. BLEServer *serve = initBLE( [](uint32_t pin) { @@ -32,6 +30,7 @@ void reinitBluetooth() // Start advertising - this must be done _after_ creating all services serve->getAdvertising()->start(); +#endif } // Enable/disable bluetooth.