This commit is contained in:
James 2024-04-26 11:34:52 +01:00
parent e5535e8ad3
commit e955b10b4c

View File

@ -66,6 +66,7 @@ void loop() {
}
// Get remote service
Serial.print("Get remote service...");
BLERemoteService* pRemoteService = pClient->getService(serviceUUID);
if (pRemoteService == nullptr){
Serial.println(String("BLE: failed to find service UUID"));
@ -76,6 +77,7 @@ void loop() {
}
// Get BMS receive characteristic
Serial.print("Get BMS receive characteristic...");
BLERemoteCharacteristic* pRemoteCharacteristic_rx = pRemoteService->getCharacteristic(charUUID_rx);
if (pRemoteCharacteristic_rx == nullptr){
Serial.println(String("BLE: failed to find RX UUID"));
@ -86,6 +88,7 @@ void loop() {
}
// Register callback for remote characteristic (receive channel)
Serial.print("Get BMS receive characteristic...");
if (pRemoteCharacteristic_rx->canNotify()){
pRemoteCharacteristic_rx->registerForNotify(MyNotifyCallback);
}else{
@ -96,6 +99,7 @@ void loop() {
}
// Get BMS transmit characteristic
Serial.print("Get BMS transmit characteristic...");
BLERemoteCharacteristic* pRemoteCharacteristic_tx = pRemoteService->getCharacteristic(charUUID_tx);
if (pRemoteCharacteristic_tx == nullptr){
Serial.println(String("BLE: failed to find TX UUID"));
@ -106,6 +110,7 @@ void loop() {
}
// Check whether tx is writeable
Serial.print("Check whether tx is writeable...");
if (!(pRemoteCharacteristic_tx->canWriteNoResponse())){
Serial.println(String("BLE: failed TX remote characteristic is not writable"));
Serial.println("Failed TX remote characteristic is not writable");
@ -113,6 +118,8 @@ void loop() {
continue;
}
Serial.print("Get data...");
gotBasicInfo=false;
gotCellInfo=false;