1414#include " BLE_Fitness_Machine_Service.h"
1515#include " BLE_Custom_Characteristic.h"
1616#include " BLE_Device_Information_Service.h"
17+ #include " BLE_Wattbike_Service.h"
1718
1819#include < ArduinoJson.h>
1920#include < Constants.h>
@@ -32,6 +33,7 @@ BLE_Heart_Service heartService;
3233BLE_Fitness_Machine_Service fitnessMachineService;
3334BLE_ss2kCustomCharacteristic ss2kCustomCharacteristic;
3435BLE_Device_Information_Service deviceInformationService;
36+ BLE_Wattbike_Service wattbikeService;
3537
3638void startBLEServer () {
3739 // Server Setup
@@ -46,7 +48,8 @@ void startBLEServer() {
4648 fitnessMachineService.setupService (spinBLEServer.pServer , &chrCallbacks);
4749 ss2kCustomCharacteristic.setupService (spinBLEServer.pServer );
4850 deviceInformationService.setupService (spinBLEServer.pServer );
49-
51+ wattbikeService.setupService (spinBLEServer.pServer ); // No callback needed
52+
5053 BLEAdvertising *pAdvertising = BLEDevice::getAdvertising ();
5154 // const std::string fitnessData = {0b00000001, 0b00100000, 0b00000000};
5255 // pAdvertising->setServiceData(FITNESSMACHINESERVICE_UUID, fitnessData);
@@ -56,6 +59,7 @@ void startBLEServer() {
5659 pAdvertising->addServiceUUID (CSCSERVICE_UUID);
5760 pAdvertising->addServiceUUID (HEARTSERVICE_UUID);
5861 pAdvertising->addServiceUUID (SMARTSPIN2K_SERVICE_UUID);
62+ pAdvertising->addServiceUUID (WATTBIKE_SERVICE_UUID);
5963 pAdvertising->setMaxInterval (250 );
6064 pAdvertising->setMinInterval (160 );
6165 pAdvertising->setScanResponse (true );
@@ -74,6 +78,7 @@ void SpinBLEServer::update() {
7478 cyclingPowerService.update ();
7579 cyclingSpeedCadenceService.update ();
7680 fitnessMachineService.update ();
81+ wattbikeService.parseNemit (); // Changed from update() to parseNemit()
7782}
7883
7984double SpinBLEServer::calculateSpeed () {
@@ -182,7 +187,7 @@ void MyCallbacks::onSubscribe(NimBLECharacteristic *pCharacteristic, ble_gap_con
182187 SS2K_LOG (BLE_SERVER_LOG_TAG, " %s" , str.c_str ());
183188}
184189
185- // This might be worth depreciating. With multiple clients connected (SS2k App, + Training App), it at least needs to be an int, not a bool.
190+ // This might be worth depreciating. With multiple clients connected (SS2k App, + Training App), it at least needs to be an int, not a bool.
186191void SpinBLEServer::setClientSubscribed (NimBLEUUID pUUID, bool subscribe) {
187192 if (pUUID == HEARTCHARACTERISTIC_UUID) {
188193 spinBLEServer.clientSubscribed .Heartrate = subscribe;
0 commit comments