From 7c0e1f7ffb750813a788940fdd55e9800c2f701d Mon Sep 17 00:00:00 2001 From: Trygve Laugstøl Date: Tue, 23 Dec 2014 13:38:57 +0100 Subject: o Initial import of trygvis.io soil moisture device. --- app.h | 66 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 66 insertions(+) create mode 100644 app.h (limited to 'app.h') diff --git a/app.h b/app.h new file mode 100644 index 0000000..af3c39a --- /dev/null +++ b/app.h @@ -0,0 +1,66 @@ +#ifndef APP_H +#define APP_H + +#include + +enum sm_cmd_code { + SM_CMD_GET_SENSOR_COUNT = 1, + SM_CMD_SET_SENSOR_THRESHOLD = 2, + SM_CMD_GET_SENSOR_LEVEL = 3, + SM_CMD_FAIL = 255, +}; + +struct sm_get_sensor_count_req { +}; + +struct sm_get_sensor_count_res { + uint8_t count; +}; + +struct sm_set_sensor_threshold_req { + uint8_t sensor; + uint8_t threshold; +}; + +struct sm_set_sensor_threshold_res { +}; + +struct sm_get_sensor_level_req { + uint8_t sensor; +}; + +struct sm_get_sensor_level_res { + uint8_t sensor; + uint8_t level; +}; + +struct sm_req { + uint8_t code; + union { + struct sm_get_sensor_count_req get_sensor_count; + struct sm_get_sensor_level_req get_sensor_level; + struct sm_set_sensor_threshold_req set_sensor_threshold; + }; +}; + +struct sm_res { + uint8_t len; + uint8_t code; + union { + struct sm_get_sensor_count_res get_sensor_count; + struct sm_get_sensor_level_res get_sensor_level; + struct sm_set_sensor_threshold_res set_sensor_threshold; + }; +}; + +void on_loop(); + +bool tx_soil_moisture(struct sm_res *res); +void notify_soil_moisture(struct sm_res *res); +void notify_battery_level(uint8_t value); + +void on_soil_moisture(uint8_t *data, uint8_t len); + +#endif + + -- cgit v1.2.3