From 52b398083a79eb1cb5e42499d68a80927460104a Mon Sep 17 00:00:00 2001 From: geeksville Date: Fri, 14 Feb 2020 14:00:08 -0800 Subject: [PATCH] general both build types --- build-all.sh | 13 +++++++++++++ lib/BluetoothOTA/src/BluetoothUtil.cpp | 9 ++++----- lib/BluetoothOTA/src/BluetoothUtil.h | 2 +- release/.gitignore | 1 + src/configuration.h | 18 +++++++++--------- src/main.ino | 18 +++++++----------- 6 files changed, 35 insertions(+), 26 deletions(-) create mode 100755 build-all.sh create mode 100644 release/.gitignore diff --git a/build-all.sh b/build-all.sh new file mode 100755 index 00000000..38ece584 --- /dev/null +++ b/build-all.sh @@ -0,0 +1,13 @@ +set -e + +VERSION=0.0.2 + +rm .pio/build/esp32/firmware.bin +export PLATFORMIO_BUILD_FLAGS="-DT_BEAM_V10 -DAPP_VERSION=$VERSION" +pio run # -v +cp .pio/build/esp32/firmware.bin release/firmware-TBEAM-US.bin + +rm .pio/build/esp32/firmware.bin +export PLATFORMIO_BUILD_FLAGS="-DHELTEC_LORA32 -DAPP_VERSION=$VERSION" +pio run # -v +cp .pio/build/esp32/firmware.bin release/firmware-HELTEC-US.bin \ No newline at end of file diff --git a/lib/BluetoothOTA/src/BluetoothUtil.cpp b/lib/BluetoothOTA/src/BluetoothUtil.cpp index f1ea5b0f..06d4f0dd 100644 --- a/lib/BluetoothOTA/src/BluetoothUtil.cpp +++ b/lib/BluetoothOTA/src/BluetoothUtil.cpp @@ -15,7 +15,7 @@ static BLECharacteristic HardwareVersionCharacteristic(BLEUUID((uint16_t)ESP_GAT /** * Create standard device info service **/ -BLEService *createDeviceInfomationService(BLEServer *server, std::string hwVendor, std::string swVersion) +BLEService *createDeviceInfomationService(BLEServer *server, std::string hwVendor, std::string swVersion, std::string hwVersion) { BLEService *deviceInfoService = server->createService(BLEUUID((uint16_t)ESP_GATT_UUID_DEVICE_INFO_SVC)); @@ -32,7 +32,7 @@ BLEService *createDeviceInfomationService(BLEServer *server, std::string hwVendo deviceInfoService->addCharacteristic(&SWVersionCharacteristic); ManufacturerCharacteristic.setValue(hwVendor); deviceInfoService->addCharacteristic(&ManufacturerCharacteristic); - HardwareVersionCharacteristic.setValue("1.0"); + HardwareVersionCharacteristic.setValue(hwVersion); deviceInfoService->addCharacteristic(&HardwareVersionCharacteristic); //SerialNumberCharacteristic.setValue("FIXME"); //deviceInfoService->addCharacteristic(&SerialNumberCharacteristic); @@ -179,7 +179,7 @@ class MySecurity : public BLESecurityCallbacks } }; -BLEServer *initBLE(std::string deviceName, std::string hwVendor, std::string swVersion) +BLEServer *initBLE(std::string deviceName, std::string hwVendor, std::string swVersion, std::string hwVersion) { BLEDevice::init(deviceName); BLEDevice::setEncryptionLevel(ESP_BLE_SEC_ENCRYPT); @@ -193,7 +193,7 @@ BLEServer *initBLE(std::string deviceName, std::string hwVendor, std::string swV BLEServer *pServer = BLEDevice::createServer(); pServer->setCallbacks(new MyServerCallbacks()); - BLEService *pDevInfo = createDeviceInfomationService(pServer, hwVendor, swVersion); + BLEService *pDevInfo = createDeviceInfomationService(pServer, hwVendor, swVersion, hwVersion); // We now let users create the battery service only if they really want (not all devices have a battery) // BLEService *pBattery = createBatteryService(pServer); @@ -210,7 +210,6 @@ BLEServer *initBLE(std::string deviceName, std::string hwVendor, std::string swV // FIXME turn on this restriction only after the device is paired with a phone // advert->setScanFilter(false, true); // We let anyone scan for us (FIXME, perhaps only allow that until we are paired with a phone and configured) but only let whitelist phones connect - BLESecurity *pSecurity = new BLESecurity(); pSecurity->setCapability(ESP_IO_CAP_OUT); pSecurity->setAuthenticationMode(ESP_LE_AUTH_REQ_SC_BOND); diff --git a/lib/BluetoothOTA/src/BluetoothUtil.h b/lib/BluetoothOTA/src/BluetoothUtil.h index 65ab327f..dda09c89 100644 --- a/lib/BluetoothOTA/src/BluetoothUtil.h +++ b/lib/BluetoothOTA/src/BluetoothUtil.h @@ -18,4 +18,4 @@ void dumpCharacteristic(BLECharacteristic *c); uint32_t getValue32(BLECharacteristic *c, uint32_t defaultValue); void loopBLE(); -BLEServer *initBLE(std::string devName, std::string hwVendor, std::string swVersion); \ No newline at end of file +BLEServer *initBLE(std::string devName, std::string hwVendor, std::string swVersion, std::string hwVersion); \ No newline at end of file diff --git a/release/.gitignore b/release/.gitignore new file mode 100644 index 00000000..f3ac583d --- /dev/null +++ b/release/.gitignore @@ -0,0 +1 @@ +*.bin \ No newline at end of file diff --git a/src/configuration.h b/src/configuration.h index 3c23405f..36171b9c 100644 --- a/src/configuration.h +++ b/src/configuration.h @@ -30,20 +30,20 @@ along with this program. If not, see . // ----------------------------------------------------------------------------- #define APP_NAME "Meshtastic" -#define APP_VERSION "0.0.1" +#ifndef APP_VERSION +#define APP_VERSION "0.0.0" +#endif +#define HW_VERSION "US" // We encode the hardware freq range in the hw version string, so sw update can eventually install the correct build // ----------------------------------------------------------------------------- // Configuration // ----------------------------------------------------------------------------- -// Select which T-Beam board is being used. Only uncomment one. Note: these options now come from platformio standard build file flags -//#ifdef ARDUINO_T_Beam -//#define T_BEAM_V10 // AKA Rev1 (second board released) -//#endif - -//#ifdef ARDUINO_HELTEC_WIFI_LORA_32_V2 -#define HELTEC_LORA32 -//#endif +// Select which board is being used. If the outside build environment has sent a choice, just use that +#if !defined(T_BEAM_V10) && !defined(HELTEC_LORA32) +#define T_BEAM_V10 // AKA Rev1 (second board released) +//#define HELTEC_LORA32 +#endif // If we are using the JTAG port for debugging, some pins must be left free for that (and things like GPS have to be disabled) // we don't support jtag on the ttgo - access to gpio 12 is a PITA diff --git a/src/main.ino b/src/main.ino index 87e5fa7b..9e572e89 100644 --- a/src/main.ino +++ b/src/main.ino @@ -39,6 +39,7 @@ AXP20X_Class axp; bool pmu_irq = false; #endif bool isCharging = false; +bool isUSBPowered = false; bool ssd1306_found = false; bool axp192_found = false; @@ -282,6 +283,7 @@ void axp192Init() #endif isCharging = axp.isChargeing(); + isUSBPowered = axp.isVBUSPlug(); } else { @@ -380,7 +382,7 @@ void setup() if (useBluetooth) { DEBUG_MSG("Starting bluetooth\n"); - BLEServer *serve = initBLE(getDeviceName(), HW_VENDOR, APP_VERSION); // FIXME, use a real name based on the macaddr + BLEServer *serve = initBLE(getDeviceName(), HW_VENDOR, APP_VERSION, HW_VERSION); // FIXME, use a real name based on the macaddr createMeshBluetoothService(serve); // Start advertising - this must be done _after_ creating all services @@ -420,17 +422,11 @@ void loop() { pmu_irq = false; axp.readIRQ(); - isCharging = axp.isChargingIRQ(); - if (axp.isVbusRemoveIRQ()) - isCharging = false; + isCharging = axp.isChargeing(); + isUSBPowered = axp.isVBUSPlug(); - if (axp.isAcinPlugInIRQ()) - fixme - cleanup all this is chrarging crap.just read the status registers then clear the irq - isUSBPowered = true - // This is not a GPIO actually connected on the tbeam board - // digitalWrite(2, !digitalRead(2)); - axp.clearIRQ(); + axp.clearIRQ(); } #endif } @@ -478,7 +474,7 @@ void loop() #ifdef MINWAKE_MSECS // Don't deepsleep if we have USB power or if the user as pressed a button recently - if (millis() - lastPressMs > MINWAKE_MSECS && !isCharging) + if (millis() - lastPressMs > MINWAKE_MSECS && !isUSBPowered) { sleep(); }