diff --git a/CHANGELOG.md b/CHANGELOG.md index db3ab502..087ab411 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -13,18 +13,19 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - Updated kit purchasing links. - MIN_ERG_CADENCE created and changed from 20 to 30. - Fixed DNS server in AP mode. -- Fixed an issue with IC4 and variants not displaying device name in Bluetooth scanner. Fixes #500 +- Fixed an issue with IC4 and variants not displaying device name in Bluetooth scanner. Fixes #500. - Switched from using Power Table to a Torque Table for better compensation in cad variations. - added test for invalid Peloton data to keep stepper from running away without resistance information. - Fixed a bug with Trainer Day and rapid ERG sending. - Many updates and bug fixes which enable the Config App to communicate with SmartSpin2k. - Scanned devices no longer saved to filesystem. The new scanning method would keep snowballing them otherwise. -- increased MTU for android +- increased MTU for android. - Updated WiFi connection setup. - Firmware no longer updates if only the html files need to be loaded. +- BLE scans blocked during firmware upgrade. ### Hardware -- added Yesoul S3 +- added Yesoul S3. - Wire diameter reduced from 7.2mm to 6.0mm on the window passthrough to accommodate the latest batch of cables. - Changed reference to M4 bolt to M5 Bolt in the construction instructions pdf. - Increased right side case mounting hole to 5.5mm so the bolt slides in easier. diff --git a/include/BLE_Common.h b/include/BLE_Common.h index 3c5c2631..615289a8 100644 --- a/include/BLE_Common.h +++ b/include/BLE_Common.h @@ -59,7 +59,7 @@ class ss2kCustomCharacteristic { //Used internally for notify and onWrite Callback. static void process(std::string rxValue); //Custom Characteristic value that needs to be notified - static void notify(const uint8_t _item); + static void notify(char _item); // Notify any changed value in userConfig static void parseNemit(); }; diff --git a/include/Main.h b/include/Main.h index dc72e134..f8813d8f 100644 --- a/include/Main.h +++ b/include/Main.h @@ -35,9 +35,10 @@ class SS2K { bool externalControl; bool syncMode; int txCheck; - bool rebootFlag = false; - bool saveFlag = false; - bool isUpdating = false; + bool rebootFlag = false; + bool saveFlag = false; + bool resetDefaultsFlag = false; + bool isUpdating = false; bool IRAM_ATTR deBounce(); static void IRAM_ATTR moveStepper(void *pvParameters); diff --git a/src/BLE_Client.cpp b/src/BLE_Client.cpp index 02915b2f..5f4d2950 100644 --- a/src/BLE_Client.cpp +++ b/src/BLE_Client.cpp @@ -86,7 +86,7 @@ void bleClientTask(void *pvParameters) { scanDelay = millis(); } - if (spinBLEClient.doScan) { + if (spinBLEClient.doScan && (!ss2k->isUpdating)) { spinBLEClient.scanProcess(); } @@ -523,15 +523,6 @@ void SpinBLEClient::scanProcess(int duration) { pBLEScan = nullptr; // free up memory } -/*// This is the main server scan request process to use. -void SpinBLEClient::serverScan(bool connectRequest) { - this->dontBlockScan = true; - if (connectRequest) { - this->scanRetries = MAX_SCAN_RETRIES; - } - this->doScan = true; -}*/ - // remove the last connected BLE Power Meter void SpinBLEClient::removeDuplicates(NimBLEClient *pClient) { // BLEAddress thisAddress = pClient->getPeerAddress(); diff --git a/src/BLE_Server.cpp b/src/BLE_Server.cpp index f2a5447b..8770a56e 100644 --- a/src/BLE_Server.cpp +++ b/src/BLE_Server.cpp @@ -323,6 +323,9 @@ void MyServerCallbacks::onConnect(BLEServer *pServer, ble_gap_conn_desc *desc) { void MyServerCallbacks::onDisconnect(BLEServer *pServer) { SS2K_LOG(BLE_SERVER_LOG_TAG, "Bluetooth Remote Client Disconnected. Remaining Clients: %d", pServer->getConnectedCount()); BLEDevice::startAdvertising(); + //client disconnected while trying to write fw - reboot to clear the faulty upload. + if (ss2k->isUpdating) {SS2K_LOG(BLE_SERVER_LOG_TAG, "Rebooting because of update interruption.", pServer->getConnectedCount()); + ss2k->rebootFlag = true;} } bool MyServerCallbacks::onConnParamsUpdateRequest(NimBLEClient *pClient, const ble_gap_upd_params *params) { diff --git a/src/Custom_Characteristic.cpp b/src/Custom_Characteristic.cpp index aeaf3073..d13466a1 100644 --- a/src/Custom_Characteristic.cpp +++ b/src/Custom_Characteristic.cpp @@ -45,7 +45,7 @@ void ss2kCustomCharacteristicCallbacks::onWrite(BLECharacteristic *pCharacterist ss2kCustomCharacteristic::process(rxValue); } -void ss2kCustomCharacteristic::notify(const uint8_t _item) { +void ss2kCustomCharacteristic::notify(char _item) { std::string returnValue = {cc_read, _item}; process(returnValue); } @@ -475,7 +475,7 @@ void ss2kCustomCharacteristic::process(std::string rxValue) { case BLE_resetToDefaults: // 0x1D logBufLength += snprintf(logBuf + logBufLength, kLogBufCapacity - logBufLength, "<-reset to defaults"); if (rxValue[0] == cc_write) { - userConfig->setDefaults(); + ss2k->resetDefaultsFlag = true; returnValue[0] = cc_success; } @@ -707,7 +707,7 @@ void ss2kCustomCharacteristic::parseNemit() { ss2kCustomCharacteristic::notify(BLE_maxBrakeWatts); return; } - if (userConfig->getShifterDir() != _oldParams.getShifterDir()) { + if (userConfig->getShifterDir() != _oldParams.getShifterDir()) { _oldParams.setShifterDir(userConfig->getShifterDir()); ss2kCustomCharacteristic::notify(BLE_shiftDir); return; diff --git a/src/HTTP_Server_Basic.cpp b/src/HTTP_Server_Basic.cpp index 5d3a4983..a54140d6 100644 --- a/src/HTTP_Server_Basic.cpp +++ b/src/HTTP_Server_Basic.cpp @@ -176,16 +176,13 @@ void HTTP_Server::start() { server.on("/load_defaults.html", []() { SS2K_LOG(HTTP_SERVER_LOG_TAG, "Setting Defaults from Web Request"); - LittleFS.format(); - userConfig->setDefaults(); - userConfig->saveToLittleFS(); + ss2k->resetDefaultsFlag = true; String response = "

Defaults have been " "loaded.



Please reconnect to the device on WiFi " "network: " + myIP.toString() + "

"; server.send(200, "text/html", response); - ESP.restart(); }); server.on("/reboot.html", []() { diff --git a/src/Main.cpp b/src/Main.cpp index 5d7b6fd8..fbba254b 100644 --- a/src/Main.cpp +++ b/src/Main.cpp @@ -216,6 +216,14 @@ void SS2K::maintenanceLoop(void *pvParameters) { _loopOnce = true; } + if (ss2k->resetDefaultsFlag) { + LittleFS.format(); + userConfig->setDefaults(); + userConfig->saveToLittleFS(); + ss2k->resetDefaultsFlag = false; + ss2k->rebootFlag = true; + } + // reboot every half hour if not in use. if ((millis() - rebootTimer) > 1800000) { if (NimBLEDevice::getServer()) {