@@ -115,27 +115,27 @@ void connect_callback(uint16_t conn_handle)
115115
116116 // Once HRM service is found, we continue to discover its characteristic
117117 Serial.println (" Found it" );
118- Serial.println (" Discovering Measurement and Body location characteristic ... " );
119118
120- uint8_t num_found_chr = Bluefruit.Discovery .discoverCharacteristic (conn_handle, hrmc, bslc);
121-
122- Serial.print (" Found " );
123- Serial.print (num_found_chr);
124- Serial.println (" Characteristics" );
125-
126- // Measurement chr is mandatory, if it is not found (valid), then disconnect
127- if ( !hrmc.discovered () )
119+
120+ Serial.print (" Discovering Measurement characteristic ... " );
121+ if ( !hrmc.discover () )
128122 {
129- Serial.println (" Measurement characteristic not found" );
123+ // Measurement chr is mandatory, if it is not found (valid), then disconnect
124+ Serial.println (" not found !!!" );
125+ Serial.println (" Measurement characteristic is mandatory but not found" );
130126 Bluefruit.Central .disconnect (conn_handle);
131-
132127 return ;
133128 }
129+ Serial.println (" Found it" );
134130
131+ // Measurement is found, continue to look for option Body Sensor Location
135132 // https://www.bluetooth.com/specifications/gatt/viewer?attributeXmlFile=org.bluetooth.characteristic.body_sensor_location.xml
136- // Body Sensor Location is optional, print its location (in text) if present
137- if ( bslc.discovered () )
133+ // Body Sensor Location is optional, print out the location in text if present
134+ Serial.print (" Discovering Body Sensor Location characteristic ... " );
135+ if ( bslc.discover () )
138136 {
137+ Serial.println (" Found it" );
138+
139139 // Body sensor location value is 8 bit
140140 const char * body_str[] = { " Other" , " Chest" , " Wrist" , " Finger" , " Hand" , " Ear Lobe" , " Foot" };
141141
@@ -145,6 +145,9 @@ void connect_callback(uint16_t conn_handle)
145145 Serial.print (" Body Location Sensor: " );
146146 Serial.println (body_str[loc_value]);
147147 }
148+ }else
149+ {
150+ Serial.println (" Found NONE" );
148151 }
149152
150153 // Reaching here means we are ready to go, let's enable notification on measurement chr
0 commit comments