aboutsummaryrefslogtreecommitdiff
path: root/app.h
diff options
context:
space:
mode:
authorTrygve Laugstøl <trygvis@inamo.no>2014-12-23 13:38:57 +0100
committerTrygve Laugstøl <trygvis@inamo.no>2014-12-27 22:39:07 +0100
commit7c0e1f7ffb750813a788940fdd55e9800c2f701d (patch)
treede7a200205b6d6725cdbd428dfedb0eac2a825a1 /app.h
downloadtrygvisio_soil_moisture-7c0e1f7ffb750813a788940fdd55e9800c2f701d.tar.gz
trygvisio_soil_moisture-7c0e1f7ffb750813a788940fdd55e9800c2f701d.tar.bz2
trygvisio_soil_moisture-7c0e1f7ffb750813a788940fdd55e9800c2f701d.tar.xz
trygvisio_soil_moisture-7c0e1f7ffb750813a788940fdd55e9800c2f701d.zip
o Initial import of trygvis.io soil moisture device.
Diffstat (limited to 'app.h')
-rw-r--r--app.h66
1 files changed, 66 insertions, 0 deletions
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 <stdint.h>
+
+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
+
+