enhance example, relate to #150

This commit is contained in:
hathach committed 2019-01-11 14:50:37 +07:00
1 parent 71efec28ec
commit 1182aca25c
3 files changed
+13 -4

No files matched your search

@@ -118,6 +118,9 @@ void connect_callback(uint16_t conn_handle)
}
Serial.println();
}else
{
Serial.println("Found NONE");
}
Serial.print("Dicovering Battery ... ");
@@ -127,8 +130,10 @@ void connect_callback(uint16_t conn_handle)
Serial.print("Battery level: ");
Serial.print(clientBas.read());
Serial.println("%");
}else
{
Serial.println("Found NONE");
}
Serial.print("Discovering BLE Uart Service ... ");
if ( clientUart.discover(conn_handle) )
@@ -132,9 +132,9 @@ void loop(void)
Serial.println(" bytes ...");
start = millis();
while (remaining > 0)
while ( (remaining > 0) && Bluefruit.connected() && bleuart.notifyEnabled() )
{
bleuart.print(TEST_STRING);
if ( !bleuart.print(TEST_STRING) ) break;
sent += TEST_STRLEN;
remaining -= TEST_STRLEN;
@@ -82,7 +82,11 @@ bool BLEDiscovery::_discoverService(uint16_t conn_handle, BLEClientService& svc,
int32_t bytecount = _adamsg.waitUntilComplete(BLE_DISCOVERY_TIMEOUT);
// timeout or has no data (due to GATT Error)
if ( bytecount <= 0 ) return false;
if ( bytecount <= 0 )
{
LOG_LV1("DISC", "[SVC] timeout or error", start_handle);
return false;
}
// Check the discovered UUID with input one
if ( (disc_svc.count) && (svc.uuid == disc_svc.services[0].uuid) )