@@ -204,29 +204,28 @@ void loop()
204
204
205
205
// Update the HRM value periodically
206
206
if (blinkyms+BLINKY_MS < millis ()) {
207
- // Make sure we are connected to a Central device!
208
207
if (Bluefruit.connected ()) {
209
- // Update the value of the notify characteristic
210
- uint8_t hrmdata[2 ] = { 0b00000110 , bps++ }; // Connected, increment BPS value
208
+ uint8_t hrmdata[2 ] = { 0b00000110 , bps++ }; // Sensor connected, increment BPS value
211
209
err_t resp = hrmc.notify (hrmdata, sizeof (hrmdata)); // Note: We use .notify instead of .write!
212
210
213
- // Check the results of the attempt to update the notify characteristic
211
+ // This isn't strictly necessary, but you can check the result
212
+ // of the .notify() attempt to see if it was successful or not
214
213
switch (resp) {
215
214
case ERROR_NONE:
216
215
// Value was written correctly!
217
- Serial.print (" Heart Rate Measurement updated to: " );
218
- Serial.println (bps);
216
+ Serial.print (" Heart Rate Measurement updated to: " ); Serial.println (bps);
219
217
break ;
220
218
case NRF_ERROR_INVALID_PARAM:
221
219
// Characteristic property not set to 'Notify'
222
- Serial.println (" Error : Characteristic 'Property' not set to Notify!" );
220
+ Serial.println (" ERROR : Characteristic 'Property' not set to Notify!" );
223
221
break ;
224
222
case NRF_ERROR_INVALID_STATE:
225
- // Notify bit not set in the CCCD by the Central device
226
- Serial.println (" Warning : Notify not enabled in the CCCD!" );
223
+ // Notify bit not set in the CCCD or not connected
224
+ Serial.println (" ERROR : Notify not set in the CCCD or not connected !" );
227
225
break ;
228
226
default :
229
- Serial.print (" Error: Ox" ); Serial.println (resp, HEX);
227
+ // Unhandled error code
228
+ Serial.print (" ERROR: Ox" ); Serial.println (resp, HEX);
230
229
break ;
231
230
}
232
231
}
0 commit comments