summaryrefslogtreecommitdiff
path: root/src/devices.h
diff options
context:
space:
mode:
Diffstat (limited to 'src/devices.h')
-rw-r--r--src/devices.h42
1 files changed, 42 insertions, 0 deletions
diff --git a/src/devices.h b/src/devices.h
new file mode 100644
index 0000000..ef4e65b
--- /dev/null
+++ b/src/devices.h
@@ -0,0 +1,42 @@
+
+#include "handshake.pb.h"
+
+#define _MDR s2m_MDR_response
+
+typedef struct _device_info {
+ uint8_t device_id;
+ uint8_t i2c_addr;
+ _MDR MDR;
+
+ uint32_t subscription_requests[4]; /* Subscriptions to this device */
+ uint32_t subscriptions[4]; /* Subscriptions by this device */
+} device_info_t;
+
+typedef struct _subscription_info {
+ uint8_t module_ids[128];
+ uint8_t entity_ids[128];
+ uint8_t module_class[3];
+ uint8_t i2c_address[128];
+ uint8_t mod_idx, entity_idx, class_idx, i2c_idx;
+} subscription_info_t;
+
+typedef enum hs_status {
+ IDLE = 0, // send mdr request. success: mdr_ack. fail: hs_fail
+ HS_MDR_ACK = 1, // get mdr ack. success: mdr_cts. fail: hs_fail
+ HS_MDR_CTS = 2, // send mdr cts. success: mdr_mdr. fail: hs_fail
+ HS_MDR_MDR = 3, // get mdr. success: registered. fail: hs_fail
+ HS_REGISTERED = 4, // send registered. success: exit. fail: hs_fail
+ HS_FAILED = 5
+} hs_status_t;
+
+typedef enum state {
+ NO_HS = 0, /* Initial state: handshake not attempted yet */
+ OFFLINE = 1, /* Device not found on bus */
+ CONNECTED = 2, /* Device found on bus but handshake not completed */
+ REGISTERED = 3, /* Completed handshake; ready for action */
+ FAILED = 4, /* Handshake failed */
+ NO_DATA = 5 /* ??? */
+} state_t;
+
+/* Handshake message size definitions */
+#define MDR_req_buf_len 2