Statistics
| Branch: | Tag: | Revision:

root / tidsense / command.h @ 166:1a6a85e8d2e7

History | View | Annotate | Download (1.6 kB)

1
#ifndef __command_h_
2
#define __command_h_
3
4
#include <nwk.h>
5
6
#include "i2cmaster.h"
7
#include "version.h"
8
#include "network.h"
9
10
#define CMD_RESP        (1<<0)
11
12
typedef enum {
13
    CMD_NODEINFO = 0x00,
14
    CMD_DISCOVER = 0x01,
15
    CMD_SETNETWORKS = 0x02,
16
    CMD_ENABLEFEATURE = 0x03,
17
    CMD_DISABLEFEATURE = 0x04,
18
    CMD_GETFEATURES = 0x05,
19
    CMD_NODEINFOREQUEST = 0x06,
20
    CMD_EVENT_REPORT = 0x07,
21
22
    CMD_OTASTART = 0x10,
23
    CMD_OTAREQUEST = 0x11,
24
    CMD_OTASTATUSREQUEST = 0x12,
25
    CMD_REBOOT = 0x13,
26
27
    CMD_SETGPIO = 0x80,
28
    CMD_I2C_WRITE = 0x81,
29
    CMD_I2C_READ = 0x82,
30
    CMD_OTA = 0xF0,
31
} command_id_t;
32
33
typedef struct {
34
    uint8_t cmd;
35
    uint8_t flags;
36
    uint32_t id;
37
} cmd_header_t;
38
39
typedef struct {
40
    cmd_header_t header;
41
42
    version_info_t version_info;
43
44
    uint16_t ota_state;
45
    uint16_t ota_progress;
46
} cmd_nodeinfo_resp_t;
47
48
typedef struct {
49
    cmd_header_t header;
50
    uint8_t priority;
51
    uint16_t net_id;
52
} cmd_discover_resp_t;
53
54
typedef struct {
55
    uint8_t count;
56
    uint16_t networks[];
57
} cmd_setnetworks_t;
58
59
typedef struct {
60
    uint16_t feature;
61
} cmd_enablefeature_t;
62
63
typedef struct {
64
    cmd_header_t header;
65
    uint8_t addr;
66
    uint8_t reg;
67
    uint8_t status;
68
    uint8_t size;
69
    uint8_t data[];
70
} cmd_i2c_t;
71
72
void command_setup(void);
73
void command_set_i2c_bus(i2c_bus_t *bus);
74
void cmd_nodeinfo(NWK_DataInd_t *ind);
75
76
void command_data_confirm(NWK_DataReq_t *req);
77
78
void cmd_setup_req(command_id_t cmd, NWK_DataReq_t *req, uint16_t dest);
79
void cmd_setup_resp(command_id_t cmd, NWK_DataReq_t *req, void *hdr, NWK_DataInd_t *ind);
80
81
uint32_t cmd_get_next_id(void);
82
83
#endif // __command_h_
84