[][src]Module app::app_sensor

Poll the temperature sensor every 10 seconds. Transmit the sensor data to the CoAP server after polling. This is the Rust version of https://github.com/lupyuen/stm32bluepill-mynewt-sensor/blob/rust-nbiot/apps/my_sensor_app/OLDsrc/sensor.c

Constants

SENSOR_POLL_TIME

Poll sensor every 10,000 milliseconds (10 seconds)

TEMP_SENSOR_KEY

Use key (field name) t to transmit raw temperature to CoAP Server

TEMP_SENSOR_TYPE

Type of sensor: Raw temperature sensor (integer sensor values 0 to 4095)

Statics

SENSOR_DEVICE

Sensor to be polled: temp_stm32_0 is Blue Pill's internal temperature sensor

Functions

convert_sensor_data

Convert the raw temperature value received from Mynewt into a SensorValue for transmission, which includes the sensor data key t. sensor_type indicates the type of data in sensor_data.

handle_sensor_data

This listener function is called every 10 seconds by Mynewt to handle the polled sensor data. Return 0 if we have handled the sensor data successfully.

start_sensor_listener

Ask Mynewt to poll the temperature sensor every 10 seconds and call handle_sensor_data(). Return Ok() if successful, else return Err() with MynewtError error code inside.