Skip to content

Commit

Permalink
only save name or address of BLE, not both
Browse files Browse the repository at this point in the history
  • Loading branch information
doudar committed Jan 29, 2024
1 parent 2fe7764 commit 825d954
Showing 1 changed file with 5 additions and 7 deletions.
12 changes: 5 additions & 7 deletions src/BLE_Client.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -159,11 +159,8 @@ bool SpinBLEClient::connectToServer() {
// spinBLEClient.serverScan(true);
return false;
}
String t_name = "";
if (myDevice->haveName()) {
String t_name = myDevice->getName().c_str();
}
SS2K_LOG(BLE_CLIENT_LOG_TAG, "Forming a connection to: %s %s", t_name.c_str(), myDevice->getAddress().toString().c_str());

SS2K_LOG(BLE_CLIENT_LOG_TAG, "Forming a connection to: %s %s", myDevice->haveName() ? myDevice->getName() : "", myDevice->getAddress().toString().c_str());

NimBLEClient *pClient = nullptr;

Expand Down Expand Up @@ -377,7 +374,7 @@ void MyClientCallback::onAuthenticationComplete(ble_gap_conn_desc desc) { SS2K_L
*/

void MyAdvertisedDeviceCallback::onResult(BLEAdvertisedDevice *advertisedDevice) {
char aDevName[40]; //40 should be enough for anybody!
char aDevName[40]; // 40 should be enough for anybody!
(advertisedDevice->haveName()) ? strcpy(aDevName, advertisedDevice->getName().c_str()) : strcpy(aDevName, advertisedDevice->getAddress().toString().c_str());

if ((advertisedDevice->haveServiceUUID()) &&
Expand Down Expand Up @@ -455,10 +452,11 @@ void SpinBLEClient::scanProcess(int duration) {
if (d.isAdvertisingService(CYCLINGPOWERSERVICE_UUID) || d.isAdvertisingService(HEARTSERVICE_UUID) || d.isAdvertisingService(FLYWHEEL_UART_SERVICE_UUID) ||
d.isAdvertisingService(FITNESSMACHINESERVICE_UUID) || d.isAdvertisingService(ECHELON_DEVICE_UUID) || d.isAdvertisingService(HID_SERVICE_UUID)) {
device = "device " + String(i);
devices[device]["address"] = d.getAddress().toString();

if (d.haveName()) {
devices[device]["name"] = d.getName();
}else {
devices[device]["address"] = d.getAddress().toString();
}

if (d.haveServiceUUID()) {
Expand Down

0 comments on commit 825d954

Please sign in to comment.