adafruit / Wippersnapper_Protobuf

Protocol buffer messages for Adafruit.io WipperSnapper Beta
MIT License
0 stars 2 forks source link

Add max_count to the sensor events #73

Closed brentru closed 2 years ago

brentru commented 2 years ago

Adding max_count nanopb compiler flag to the SensorEvent to assist with encoding.

Moves away from a callback encoding model (we did not get this working last time) to compiling the senor_event as an array of sensor_event structs.

Example C++ code:

// Pack SensorEvent payload              

msgi2cResponse.payload.resp_i2c_device_event.sensor_event[msgi2cResponse.payload.resp_i2c_device_event.sensor_event_count].type = wippersnapper_i2c_v1_SensorType_SENSOR_TYPE_AMBIENT_TEMPERATURE;
              msgi2cResponse.payload.resp_i2c_device_event.sensor_event[msgi2cResponse.payload.resp_i2c_device_event.sensor_event_count].value = temp;
// Increment counter
msgi2cResponse.payload.resp_i2c_device_event.sensor_event_count++;