@@ -325,7 +325,7 @@ bool cbDecodePinConfigMsg(pb_istream_t *stream, const pb_field_t *field,
325
325
326
326
/* *************************************************************************/
327
327
/* !
328
- @brief Decodes repeated PinEvents messages.
328
+ @brief Decodes repeated PinEvents (digital pin write) messages.
329
329
@param stream
330
330
Input stream to read from.
331
331
@param field
@@ -335,10 +335,10 @@ bool cbDecodePinConfigMsg(pb_istream_t *stream, const pb_field_t *field,
335
335
@returns True if successfully decoded, False otherwise.
336
336
*/
337
337
/* *************************************************************************/
338
- bool cbDecodePinEventMsg (pb_istream_t *stream, const pb_field_t *field,
339
- void **arg) {
338
+ bool cbDecodeDigitalPinWriteMsg (pb_istream_t *stream, const pb_field_t *field,
339
+ void **arg) {
340
340
bool is_success = true ;
341
- WS_DEBUG_PRINTLN (" cbDecodePinEventMsg " );
341
+ WS_DEBUG_PRINTLN (" cbDecodeDigitalPinWriteMsg " );
342
342
343
343
// Decode stream into a PinEvent
344
344
wippersnapper_pin_v1_PinEvent pinEventMsg =
@@ -348,17 +348,9 @@ bool cbDecodePinEventMsg(pb_istream_t *stream, const pb_field_t *field,
348
348
is_success = false ;
349
349
}
350
350
351
+ // execute callback
351
352
char *pinName = pinEventMsg.pin_name + 1 ;
352
- if (pinEventMsg.pin_name [0 ] == ' D' ) { // digital pin event
353
- WS._digitalGPIO ->digitalWriteSvc (atoi (pinName),
354
- atoi (pinEventMsg.pin_value ));
355
- } else if (pinEventMsg.pin_name [0 ] == ' A' ) { // analog pin event
356
- // TODO
357
- WS_DEBUG_PRINTLN (" ERROR: Analog PinEvent unimplemented!" );
358
- } else {
359
- WS_DEBUG_PRINTLN (" ERROR: Unable to decode pin event name." );
360
- is_success = false ;
361
- }
353
+ WS._digitalGPIO ->digitalWriteSvc (atoi (pinName), atoi (pinEventMsg.pin_value ));
362
354
363
355
return is_success;
364
356
}
@@ -412,7 +404,7 @@ bool cbSignalMsg(pb_istream_t *stream, const pb_field_t *field, void **arg) {
412
404
wippersnapper_pin_v1_PinEvents msg =
413
405
wippersnapper_pin_v1_PinEvents_init_zero;
414
406
// set up callback
415
- msg.list .funcs .decode = cbDecodePinEventMsg ;
407
+ msg.list .funcs .decode = cbDecodeDigitalPinWriteMsg ;
416
408
msg.list .arg = field->pData ;
417
409
// decode each PinEvents sub-message
418
410
if (!pb_decode (stream, wippersnapper_pin_v1_PinEvents_fields, &msg)) {
0 commit comments