|
ENTS-tock
Environmental NeTworked Sensor firmware on Tock OS
|
Library for encoding/decoding protobuf messages. More...
Functions | |
| size_t | EncodePowerMeasurement (uint32_t ts, uint32_t logger_id, uint32_t cell_id, double voltage, double current, uint8_t *buffer) |
| Encodes a power measurement. | |
| size_t | EncodePowerDeltaMeasurement (uint32_t ts, uint32_t logger_id, uint32_t cell_id, uint32_t voltage, uint32_t current, uint8_t *buffer) |
| Encodes power delta measurements. | |
| size_t | EncodeTeros12Measurement (uint32_t ts, uint32_t logger_id, uint32_t cell_id, double vwc_raw, double vwc_adj, double temp, uint32_t ec, uint8_t *buffer) |
| Encodes a Teros12 measurement. | |
| size_t | EncodeTeros21Measurement (uint32_t ts, uint32_t logger_id, uint32_t cell_id, double matric_pot, double temp, uint8_t *buffer) |
| Encodes a Teros21 measurement. | |
| size_t | EncodePhytos31Measurement (uint32_t ts, uint32_t logger_id, uint32_t cell_id, double voltage, double leaf_wetness, uint8_t *buffer) |
| Encodes a Phytos31 measurement. | |
| size_t | EncodeBME280Measurement (uint32_t ts, uint32_t logger_id, uint32_t cell_id, uint32_t pressure, int32_t temperature, uint32_t humidity, uint8_t *buffer) |
| Encodes a BME280 measurement. | |
| size_t | EncodeWaterPressMeasurement (uint32_t ts, uint32_t logger_id, uint32_t cell_id, double voltage, double water_pressure, uint8_t *buffer) |
| Encodes a Water Pressure measurement. | |
| size_t | EncodeSEN0308Measurement (uint32_t ts, uint32_t logger_id, uint32_t cell_id, double voltage, double humidity, uint8_t *buffer) |
| Encodes a Capacitive Soil Moisture measurement. | |
| size_t | EncodeWaterFlowMeasurement (uint32_t ts, uint32_t logger_id, uint32_t cell_id, double water_flow, uint8_t *buffer) |
| Encodes a Water Flow measurement. | |
| size_t | EncodePCAP02Measurement (uint32_t ts, uint32_t logger_id, uint32_t cell_id, double capacitance, uint8_t *buffer) |
| Encodes a PCAP02 measurement. | |
| int | DecodeMeasurement (Measurement *meas, const uint8_t *buffer, const size_t len) |
| Decodes a measurement. | |
| Response_ResponseType | DecodeResponse (const uint8_t *data, const size_t len) |
| Decodes a response message. | |
| Esp32Command | DecodeEsp32Command (const uint8_t *data, const size_t len) |
| Decodes an Esp32Command message. | |
| size_t | EncodePageCommand (PageCommand_RequestType req, int fd, size_t bs, size_t n, uint8_t *buffer, size_t size) |
| Encodes a page command. | |
| size_t | EncodeTestCommand (TestCommand_ChangeState state, int32_t data, uint8_t *buffer, size_t size) |
| Encodes a test command. | |
| size_t | EncodeMicroSDCommand (const MicroSDCommand *microsd_cmd, uint8_t *buffer, size_t size) |
| Encodes a MicroSDCommand. | |
| size_t | EncodeWiFiCommand (const WiFiCommand *wifi_cmd, uint8_t *buffer, size_t size) |
| Encodes a WiFiCommand. | |
| size_t | EncodeUserConfigCommand (UserConfigCommand_RequestType type, const UserConfiguration *config_data, uint8_t *buffer, size_t size) |
| Encodes a UserConfigCommand into a protobuf message. | |
| size_t | EncodeIrrigationCommand (const IrrigationCommand *irrigation_cmd, uint8_t *buffer, size_t size) |
| Encodes an IrrigationCommand. | |
| size_t | EncodePowerCommand (const PowerCommand *power_cmd, uint8_t *buffer, size_t size) |
| Encodes a PowerCommand. | |
| size_t | EncodeUserConfiguration (const UserConfiguration *config, uint8_t *buffer) |
| Encodes user configuration data. | |
| int | DecodeUserConfiguration (const uint8_t *data, const size_t len, UserConfiguration *config) |
| Decodes user configuration data. | |
Library for encoding/decoding protobuf messages.
| Esp32Command DecodeEsp32Command | ( | const uint8_t * | data, |
| const size_t | len | ||
| ) |
Decodes an Esp32Command message.
The type of command and the data from the command will need to be manually extracted,
Definition at line 246 of file transcoder.c.
References data.
Referenced by ControllerMicroSDLog(), ControllerMicroSDSave(), ControllerMicroSDUserConfig(), ControllerUserConfigRequest(), IrrigationCommandTransaction(), ModuleHandler::ModuleHandler::OnReceive(), PowerCommandTransaction(), and WiFiCommandTransaction().
| int DecodeMeasurement | ( | Measurement * | meas, |
| const uint8_t * | buffer, | ||
| const size_t | len | ||
| ) |
Decodes a measurement.
Use meas.which_measurement to determine the type of sensor data.
| meas | Destination Measurement struct |
| buffer | Source buffer containing the serialized measurement to decode |
| len | Number of bytes in buffer |
Definition at line 235 of file transcoder.c.
References buffer.
Referenced by ControllerMicroSDSave().
| Response_ResponseType DecodeResponse | ( | const uint8_t * | data, |
| const size_t | len | ||
| ) |
Decodes a response message.
Take bytes in data withy length len and decodes into a response type. Neither data or len are modified. A return value of -1 indicates an error in decoding. See soil_power_sensor.proto for a full list of response types.
| data | Protobuf serialized data |
| len | Number of bytes in data |
Definition at line 207 of file transcoder.c.
References data.
| int DecodeUserConfiguration | ( | const uint8_t * | data, |
| const size_t | len, | ||
| UserConfiguration * | config | ||
| ) |
Decodes user configuration data.
This function deserializes a user configuration protobuf message from a buffer. The message length is specified, and a return value of -1 indicates a decoding error.
| data | Serialized data buffer |
| len | Length of data buffer |
| config | Decoded user configuration output |
Definition at line 376 of file transcoder.c.
References data.
Referenced by setConfig(), and UserConfigLoadBytes().
| size_t EncodeBME280Measurement | ( | uint32_t | ts, |
| uint32_t | logger_id, | ||
| uint32_t | cell_id, | ||
| uint32_t | pressure, | ||
| int32_t | temperature, | ||
| uint32_t | humidity, | ||
| uint8_t * | buffer | ||
| ) |
Encodes a BME280 measurement.
The timestamp is not able to encode timezones and is references from UTC+0. The serialized data is stored in buffer with the number of bytes written being returned by the function. A return value of -1 indicates an error in encoding.
Below shows the relation between raw measurements taken from the device in relation to real-world or si units.
Raw values
pressure: 98473 temperature: 2275 humidity: 43600
SI unit values
pressure: 9847.3 hPa temperature: 22.75 C humidity: 43.600 %
| ts | Timestamp |
| logger_id | Logger Id |
| cell_id | Cell Id |
| pressure | Air pressure in hPa |
| temperature | Air temperature in celsius (C) |
| humidity | Relative humidity in percent (%) |
| buffer | Buffer to store serialized measurement |
buffer Definition at line 99 of file transcoder.c.
References buffer, and EncodeMeasurement().
| size_t EncodeIrrigationCommand | ( | const IrrigationCommand * | irrigation_cmd, |
| uint8_t * | buffer, | ||
| size_t | size | ||
| ) |
Encodes an IrrigationCommand.
| irrigation_cmd | Command containing the data |
| buffer | Buffer to store serialized measurement |
| size | Size of buffer |
buffer Definition at line 322 of file transcoder.c.
References buffer, and EncodeEsp32Command().
Referenced by IrrigationCommandTransaction().
| size_t EncodeMicroSDCommand | ( | const MicroSDCommand * | microsd_cmd, |
| uint8_t * | buffer, | ||
| size_t | size | ||
| ) |
Encodes a MicroSDCommand.
| microsd_cmd | Command containing the data |
| buffer | Buffer to store serialized command |
| size | Size of buffer |
buffer Definition at line 278 of file transcoder.c.
References buffer, and EncodeEsp32Command().
Referenced by ControllerMicroSDLog(), ControllerMicroSDSave(), and ControllerMicroSDUserConfig().
| size_t EncodePageCommand | ( | PageCommand_RequestType | req, |
| int | fd, | ||
| size_t | bs, | ||
| size_t | n, | ||
| uint8_t * | buffer, | ||
| size_t | size | ||
| ) |
Encodes a page command.
| req | Request type |
| fd | File descriptor |
| bs | Block size |
| n | Number of bytes |
| buffer | Buffer to store serialized command |
| size | Size of buffer |
buffer Definition at line 255 of file transcoder.c.
References buffer, and EncodeEsp32Command().
| size_t EncodePCAP02Measurement | ( | uint32_t | ts, |
| uint32_t | logger_id, | ||
| uint32_t | cell_id, | ||
| double | capacitance, | ||
| uint8_t * | buffer | ||
| ) |
Encodes a PCAP02 measurement.
The timestamp is not able to encode timezones and is references from UTC+0. The serialized data is stored in buffer with the number of bytes written being returned by the function. A return value of -1 indicates an error in encoding.
| ts | Timestamp |
| logger_id | Logger Id |
| cell_id | Cell Id |
| voltage | Raw voltage reading |
| capacitance | Capacitance |
| buffer | Buffer to store serialized measurement |
buffer Definition at line 190 of file transcoder.c.
References buffer, and EncodeMeasurement().
| size_t EncodePhytos31Measurement | ( | uint32_t | ts, |
| uint32_t | logger_id, | ||
| uint32_t | cell_id, | ||
| double | voltage, | ||
| double | leaf_wetness, | ||
| uint8_t * | buffer | ||
| ) |
Encodes a Phytos31 measurement.
Currently only the voltage measurement is used. Leaf wetness will be implemented once more is known about the sensor.
The timestamp is not able to encode timezones and is references from UTC+0. The serialized data is stored in buffer with the number of bytes written being returned by the function. A return value of -1 indicates an error in encoding.
| ts | Timestamp |
| logger_id | Logger Id |
| cell_id | Cell Id |
| voltage | Raw voltage reading |
| leaf_wetness | Calibrated leaf wetness |
| buffer | Buffer to store serialized measurement |
buffer Definition at line 81 of file transcoder.c.
References buffer, and EncodeMeasurement().
| size_t EncodePowerCommand | ( | const PowerCommand * | power_cmd, |
| uint8_t * | buffer, | ||
| size_t | size | ||
| ) |
Encodes a PowerCommand.
| power_cmd | Command containing the data |
| buffer | Buffer to store serialized measurement |
| size | Size of buffer |
buffer Definition at line 335 of file transcoder.c.
References buffer, and EncodeEsp32Command().
Referenced by PowerCommandTransaction().
| size_t EncodePowerDeltaMeasurement | ( | uint32_t | ts, |
| uint32_t | logger_id, | ||
| uint32_t | cell_id, | ||
| uint32_t | voltage, | ||
| uint32_t | current, | ||
| uint8_t * | buffer | ||
| ) |
Encodes power delta measurements.
The timestamp is not able to encode timezones and is references from UTC+0. The serialized data is stored in buffer with the number of bytes written being returned by the function. A return value of -1 indicates an error in encoding.
| ts | Unix epochs |
| logger_id | Logger Id |
| cell_id | Cell Id |
| voltage | Voltage measured in mV |
| current | Current measured in uA |
| buffer | Buffer to store serialized measurement |
buffer | size_t EncodePowerMeasurement | ( | uint32_t | ts, |
| uint32_t | logger_id, | ||
| uint32_t | cell_id, | ||
| double | voltage, | ||
| double | current, | ||
| uint8_t * | buffer | ||
| ) |
Encodes a power measurement.
The timestamp is not able to encode timezones and is references from UTC+0. The serialized data is stored in buffer with the number of bytes written being returned by the function. A return value of -1 indicates an error in encoding.
| ts | Unix epochs |
| logger_id | Logger Id |
| cell_id | Cell Id |
| voltage | Voltage measured in mV |
| current | Current measured in uA |
| buffer | Buffer to store serialized measurement |
buffer Definition at line 43 of file transcoder.c.
References buffer, and EncodeMeasurement().
| size_t EncodeSEN0308Measurement | ( | uint32_t | ts, |
| uint32_t | logger_id, | ||
| uint32_t | cell_id, | ||
| double | voltage, | ||
| double | humidity, | ||
| uint8_t * | buffer | ||
| ) |
Encodes a Capacitive Soil Moisture measurement.
Currently only the voltage measurement is used. Sensor will be implemented once more is known about the sensor.
The timestamp is not able to encode timezones and is references from UTC+0. The serialized data is stored in buffer with the number of bytes written being returned by the function. A return value of -1 indicates an error in encoding.
| ts | Timestamp |
| logger_id | Logger Id |
| cell_id | Cell Id |
| voltage | Raw voltage reading |
| soil_moister | Calibrated soil moister |
| buffer | Buffer to store serialized measurement |
buffer Definition at line 137 of file transcoder.c.
References buffer, and EncodeMeasurement().
| size_t EncodeTeros12Measurement | ( | uint32_t | ts, |
| uint32_t | logger_id, | ||
| uint32_t | cell_id, | ||
| double | vwc_raw, | ||
| double | vwc_adj, | ||
| double | temp, | ||
| uint32_t | ec, | ||
| uint8_t * | buffer | ||
| ) |
Encodes a Teros12 measurement.
The timestamp is not able to encode timezones and is references from UTC+0. The serialized data is stored in buffer with the number of bytes written being returned by the function. A return value of -1 indicates an error in encoding.
| ts | Timestamp |
| logger_id | Logger Id |
| cell_id | Cell Id |
| vwc_raw | Raw volumetric water content |
| vwc_adj | Volumetric water content converted to percentage |
| temp | Temperature in celsius |
| ec | Electrical conductivity |
| buffer | Buffer to store serialized measurement |
buffer Definition at line 60 of file transcoder.c.
References buffer, and EncodeMeasurement().
| size_t EncodeTeros21Measurement | ( | uint32_t | ts, |
| uint32_t | logger_id, | ||
| uint32_t | cell_id, | ||
| double | matric_pot, | ||
| double | temp, | ||
| uint8_t * | buffer | ||
| ) |
Encodes a Teros21 measurement.
The timestamp is not able to encode timezones and is references from UTC+0. The serialized data is stored in buffer with the number of bytes written being returned by the function. A return value of -1 indicates an error in encoding.
| ts | Timestamp |
| logger_id | Logger Id |
| cell_id | Cell Id |
| matric_pot | Matric potential |
| temp | Temperature in celsius |
buffer Definition at line 119 of file transcoder.c.
References buffer, and EncodeMeasurement().
| size_t EncodeTestCommand | ( | TestCommand_ChangeState | state, |
| int32_t | data, | ||
| uint8_t * | buffer, | ||
| size_t | size | ||
| ) |
Encodes a test command.
| state | State to change to |
| data | Data to encode |
| buffer | Buffer to store serialized command |
| size | Size of buffer |
buffer Definition at line 268 of file transcoder.c.
References buffer, data, EncodeEsp32Command(), and state.
| size_t EncodeUserConfigCommand | ( | UserConfigCommand_RequestType | type, |
| const UserConfiguration * | config_data, | ||
| uint8_t * | buffer, | ||
| size_t | size | ||
| ) |
Encodes a UserConfigCommand into a protobuf message.
| type | The request type (REQUEST_CONFIG or RESPONSE_CONFIG) |
| config_data | Pointer to UserConfiguration data |
| buffer | Output buffer for encoded data |
| size | Size of output buffer |
buffer Definition at line 302 of file transcoder.c.
References buffer, and EncodeEsp32Command().
Referenced by ControllerUserConfigRequest(), ControllerUserConfigSend(), and ControllerUserConfigStart().
| size_t EncodeUserConfiguration | ( | const UserConfiguration * | config, |
| uint8_t * | buffer | ||
| ) |
Encodes user configuration data.
This function serializes user configuration settings, including upload settings, measurement settings, and WiFi settings, using protobuf and stores the result in a buffer. The serialized data length is returned, or -1 if an encoding error occurred.
| config | User configuration to encode |
| buffer | Buffer to store serialized data |
Definition at line 361 of file transcoder.c.
References buffer.
Referenced by setConfig(), and UserConfigSave().
| size_t EncodeWaterFlowMeasurement | ( | uint32_t | ts, |
| uint32_t | logger_id, | ||
| uint32_t | cell_id, | ||
| double | water_flow, | ||
| uint8_t * | buffer | ||
| ) |
Encodes a Water Flow measurement.
Currently only the voltage measurement is used. Sensor will be implemented once more is known about the sensor.
The timestamp is not able to encode timezones and is references from UTC+0. The serialized data is stored in buffer with the number of bytes written being returned by the function. A return value of -1 indicates an error in encoding.
| ts | Timestamp |
| logger_id | Logger Id |
| cell_id | Cell Id |
| water_flow | Water Flow |
| buffer | Buffer to store serialized measurement |
buffer Definition at line 173 of file transcoder.c.
References buffer, and EncodeMeasurement().
| size_t EncodeWaterPressMeasurement | ( | uint32_t | ts, |
| uint32_t | logger_id, | ||
| uint32_t | cell_id, | ||
| double | voltage, | ||
| double | water_pressure, | ||
| uint8_t * | buffer | ||
| ) |
Encodes a Water Pressure measurement.
Currently only the voltage measurement is used. Sensor will be implemented once more is known about the sensor.
The timestamp is not able to encode timezones and is references from UTC+0. The serialized data is stored in buffer with the number of bytes written being returned by the function. A return value of -1 indicates an error in encoding.
| ts | Timestamp |
| logger_id | Logger Id |
| cell_id | Cell Id |
| voltage | Raw voltage reading |
| water_pressure | Water Pressure |
| buffer | Buffer to store serialized measurement |
buffer Definition at line 155 of file transcoder.c.
References buffer, and EncodeMeasurement().
| size_t EncodeWiFiCommand | ( | const WiFiCommand * | wifi_cmd, |
| uint8_t * | buffer, | ||
| size_t | size | ||
| ) |
Encodes a WiFiCommand.
| wifi_cmd | Command containing the data |
| buffer | Buffer to store serialized measurement |
| size | Size of buffer |
buffer Definition at line 290 of file transcoder.c.
References buffer, and EncodeEsp32Command().
Referenced by WiFiCommandTransaction().