Skip to content

Commit

Permalink
Merge pull request #537 from doudar/ConfigApp
Browse files Browse the repository at this point in the history
Config app
  • Loading branch information
doudar authored Mar 16, 2024
2 parents 6f72a14 + 12d27ff commit 8034145
Show file tree
Hide file tree
Showing 8 changed files with 25 additions and 24 deletions.
7 changes: 4 additions & 3 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
2 changes: 1 addition & 1 deletion include/BLE_Common.h
Original file line number Diff line number Diff line change
Expand Up @@ -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();
};
Expand Down
7 changes: 4 additions & 3 deletions include/Main.h
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
11 changes: 1 addition & 10 deletions src/BLE_Client.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ void bleClientTask(void *pvParameters) {
scanDelay = millis();
}

if (spinBLEClient.doScan) {
if (spinBLEClient.doScan && (!ss2k->isUpdating)) {
spinBLEClient.scanProcess();
}

Expand Down Expand Up @@ -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();
Expand Down
3 changes: 3 additions & 0 deletions src/BLE_Server.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
6 changes: 3 additions & 3 deletions src/Custom_Characteristic.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand Down Expand Up @@ -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;
}

Expand Down Expand Up @@ -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;
Expand Down
5 changes: 1 addition & 4 deletions src/HTTP_Server_Basic.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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 =
"<!DOCTYPE html><html><body><h1>Defaults have been "
"loaded.</h1><p><br><br> Please reconnect to the device on WiFi "
"network: " +
myIP.toString() + "</p></body></html>";
server.send(200, "text/html", response);
ESP.restart();
});

server.on("/reboot.html", []() {
Expand Down
8 changes: 8 additions & 0 deletions src/Main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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()) {
Expand Down

0 comments on commit 8034145

Please sign in to comment.