iotexpresslink  2.1.0.0
iotexpresslink.h
Go to the documentation of this file.
1 /****************************************************************************
2 ** Copyright (C) 2020 MikroElektronika d.o.o.
3 ** Contact: https://www.mikroe.com/contact
4 **
5 ** Permission is hereby granted, free of charge, to any person obtaining a copy
6 ** of this software and associated documentation files (the "Software"), to deal
7 ** in the Software without restriction, including without limitation the rights
8 ** to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 ** copies of the Software, and to permit persons to whom the Software is
10 ** furnished to do so, subject to the following conditions:
11 ** The above copyright notice and this permission notice shall be
12 ** included in all copies or substantial portions of the Software.
13 **
14 ** THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15 ** EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
16 ** OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
17 ** IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
18 ** DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT
19 ** OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
20 ** USE OR OTHER DEALINGS IN THE SOFTWARE.
21 ****************************************************************************/
22 
28 #ifndef IOTEXPRESSLINK_H
29 #define IOTEXPRESSLINK_H
30 
31 #ifdef __cplusplus
32 extern "C"{
33 #endif
34 
35 #include "mikrosdk_version.h"
36 
37 #ifdef __GNUC__
38 #if mikroSDK_GET_VERSION < 20800ul
39 #include "rcu_delays.h"
40 #else
41 #include "delays.h"
42 #endif
43 #endif
44 
45 #include "drv_digital_out.h"
46 #include "drv_digital_in.h"
47 #include "drv_uart.h"
48 
69 #define IOTEXPRESSLINK_CMD_AT "AT"
70 #define IOTEXPRESSLINK_CMD_CONNECT "AT+CONNECT"
71 #define IOTEXPRESSLINK_CMD_CONNECT_CHECK "AT+CONNECT?"
72 #define IOTEXPRESSLINK_CMD_DISCONNECT "AT+DISCONNECT"
73 #define IOTEXPRESSLINK_CMD_SLEEP "AT+SLEEP"
74 #define IOTEXPRESSLINK_CMD_CONFMODE "AT+CONFMODE"
75 #define IOTEXPRESSLINK_CMD_RESET "AT+RESET"
76 #define IOTEXPRESSLINK_CMD_FACTORY_RESET "AT+FACTORY_RESET"
77 #define IOTEXPRESSLINK_CMD_SEND "AT+SEND"
78 #define IOTEXPRESSLINK_CMD_GET "AT+GET"
79 #define IOTEXPRESSLINK_CMD_SUBSCRIBE "AT+SUBSCRIBE"
80 #define IOTEXPRESSLINK_CMD_UNSUBSCRIBE "AT+UNSUBSCRIBE"
81 #define IOTEXPRESSLINK_CMD_CONF "AT+CONF"
82 #define IOTEXPRESSLINK_CMD_CONF_CHECK "AT+CONF?"
83 #define IOTEXPRESSLINK_CMD_EVENT "AT+EVENT?"
84 #define IOTEXPRESSLINK_CMD_TIME "AT+TIME"
85 #define IOTEXPRESSLINK_CMD_WHERE "AT+WHERE"
86 #define IOTEXPRESSLINK_CMD_SEPARATOR " "
87 #define IOTEXPRESSLINK_CMD_SIGN_EQUAL "="
88 
93 #define IOTEXPRESSLINK_CONF_KEY_ABOUT "About"
94 #define IOTEXPRESSLINK_CONF_KEY_VERSION "Version"
95 #define IOTEXPRESSLINK_CONF_KEY_TECH_SPEC "TechSpec"
96 #define IOTEXPRESSLINK_CONF_KEY_THING_NAME "ThingName"
97 #define IOTEXPRESSLINK_CONF_KEY_CERTIFICATE "Certificate"
98 #define IOTEXPRESSLINK_CONF_KEY_CUSTOM_NAME "CustomName"
99 #define IOTEXPRESSLINK_CONF_KEY_ENDPOINT "Endpoint"
100 #define IOTEXPRESSLINK_CONF_KEY_ROOT_CA "RootCA"
101 #define IOTEXPRESSLINK_CONF_KEY_DEFENDER "Defender"
102 #define IOTEXPRESSLINK_CONF_KEY_HOTA_CERTIFICATE "HOTAcertificate"
103 #define IOTEXPRESSLINK_CONF_KEY_OTA_CERTIFICATE "OTAcertificate"
104 #define IOTEXPRESSLINK_CONF_KEY_SSID "SSID"
105 #define IOTEXPRESSLINK_CONF_KEY_PASSPHRASE "Passphrase"
106 #define IOTEXPRESSLINK_CONF_KEY_APN "APN"
107 #define IOTEXPRESSLINK_CONF_KEY_QOS "QOS"
108 #define IOTEXPRESSLINK_CONF_KEY_TOPIC "Topic"
109 
114 #define IOTEXPRESSLINK_RSP_OK "OK"
115 #define IOTEXPRESSLINK_RSP_ERR "ERR"
116 
122 #define IOTEXPRESSLINK_TX_DRV_BUFFER_SIZE 300
123 #define IOTEXPRESSLINK_RX_DRV_BUFFER_SIZE 1000
124  // iotexpresslink_cmd
126 
141 #define IOTEXPRESSLINK_MAP_MIKROBUS( cfg, mikrobus ) \
142  cfg.tx_pin = MIKROBUS( mikrobus, MIKROBUS_TX ); \
143  cfg.rx_pin = MIKROBUS( mikrobus, MIKROBUS_RX ); \
144  cfg.rst = MIKROBUS( mikrobus, MIKROBUS_RST ); \
145  cfg.wake = MIKROBUS( mikrobus, MIKROBUS_PWM ); \
146  cfg.event = MIKROBUS( mikrobus, MIKROBUS_INT );
147  // iotexpresslink_map // iotexpresslink
150 
155 typedef struct
156 {
157  // Output pins
158  digital_out_t rst;
160  // Input pins
161  digital_in_t event;
162  digital_in_t wake;
164  // Modules
165  uart_t uart;
167  // Buffers
168  uint8_t uart_rx_buffer[ IOTEXPRESSLINK_RX_DRV_BUFFER_SIZE ];
169  uint8_t uart_tx_buffer[ IOTEXPRESSLINK_TX_DRV_BUFFER_SIZE ];
172 
177 typedef struct
178 {
179  // Communication gpio pins
180  pin_name_t rx_pin;
181  pin_name_t tx_pin;
183  // Additional gpio pins
184  pin_name_t rst;
185  pin_name_t event;
186  pin_name_t wake;
188  // Static variable
189  uint32_t baud_rate;
191  uart_data_bits_t data_bit;
192  uart_parity_t parity_bit;
193  uart_stop_bits_t stop_bit;
196 
201 typedef enum
202 {
208 
210 
227 
242 
255 err_t iotexpresslink_generic_write ( iotexpresslink_t *ctx, uint8_t *data_in, uint16_t len );
256 
269 err_t iotexpresslink_generic_read ( iotexpresslink_t *ctx, uint8_t *data_out, uint16_t len );
270 
282 void iotexpresslink_send_cmd ( iotexpresslink_t *ctx, uint8_t *cmd );
283 
293 
303 
313 
323 
333 
334 #ifdef __cplusplus
335 }
336 #endif
337 #endif // IOTEXPRESSLINK_H
338  // iotexpresslink
340 
341 // ------------------------------------------------------------------------ END