File tree Expand file tree Collapse file tree 2 files changed +19
-6
lines changed
examples/Central/central_bleuart Expand file tree Collapse file tree 2 files changed +19
-6
lines changed Original file line number Diff line number Diff line change 1818 */
1919#include < bluefruit.h>
2020
21- BLEClientDis clientDis;
22- BLEClientUart clientUart;
21+ BLEClientBas clientBas; // battery client
22+ BLEClientDis clientDis; // device information client
23+ BLEClientUart clientUart; // bleuart client
2324
2425void setup ()
2526{
@@ -35,6 +36,9 @@ void setup()
3536
3637 Bluefruit.setName (" Bluefruit52 Central" );
3738
39+ // Configure Battyer client
40+ clientBas.begin ();
41+
3842 // Configure DIS client
3943 clientDis.begin ();
4044
@@ -91,7 +95,7 @@ void connect_callback(uint16_t conn_handle)
9195{
9296 Serial.println (" Connected" );
9397
94- Serial.print (" Dicovering DIS ... " );
98+ Serial.print (" Dicovering Device Information ... " );
9599 if ( clientDis.discover (conn_handle) )
96100 {
97101 Serial.println (" Found it" );
@@ -114,10 +118,19 @@ void connect_callback(uint16_t conn_handle)
114118 }
115119
116120 Serial.println ();
117- }
121+ }
118122
119- Serial.print (" Discovering BLE Uart Service ... " );
123+ Serial.print (" Dicovering Battery ... " );
124+ if ( clientBas.discover (conn_handle) )
125+ {
126+ Serial.println (" Found it" );
127+ Serial.print (" Battery level: " );
128+ Serial.print (clientBas.read ());
129+ Serial.println (" %" );
130+ }
131+
120132
133+ Serial.print (" Discovering BLE Uart Service ... " );
121134 if ( clientUart.discover (conn_handle) )
122135 {
123136 Serial.println (" Found it" );
Original file line number Diff line number Diff line change @@ -53,6 +53,6 @@ class BLEClientBas : public BLEClientService
5353
5454 private:
5555 BLEClientCharacteristic _battery;
56- }
56+ };
5757
5858#endif /* BLECLIENTBAS_H_ */
You can’t perform that action at this time.
0 commit comments