iotexpresslink3  2.1.0.0
iotexpresslink3.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 IOTEXPRESSLINK3_H
29 #define IOTEXPRESSLINK3_H
30 
31 #ifdef __cplusplus
32 extern "C"{
33 #endif
34 
39 #ifdef PREINIT_SUPPORTED
40 #include "preinit.h"
41 #endif
42 
43 #ifdef MikroCCoreVersion
44  #if MikroCCoreVersion >= 1
45  #include "delays.h"
46  #endif
47 #endif
48 
49 #include "drv_digital_out.h"
50 #include "drv_digital_in.h"
51 #include "drv_uart.h"
52 
73 #define IOTEXPRESSLINK3_CMD_AT "AT"
74 #define IOTEXPRESSLINK3_CMD_CONNECT "AT+CONNECT"
75 #define IOTEXPRESSLINK3_CMD_CONNECT_CHECK "AT+CONNECT?"
76 #define IOTEXPRESSLINK3_CMD_DISCONNECT "AT+DISCONNECT"
77 #define IOTEXPRESSLINK3_CMD_SLEEP "AT+SLEEP"
78 #define IOTEXPRESSLINK3_CMD_CONFMODE "AT+CONFMODE"
79 #define IOTEXPRESSLINK3_CMD_RESET "AT+RESET"
80 #define IOTEXPRESSLINK3_CMD_FACTORY_RESET "AT+FACTORY_RESET"
81 #define IOTEXPRESSLINK3_CMD_SEND "AT+SEND"
82 #define IOTEXPRESSLINK3_CMD_GET "AT+GET"
83 #define IOTEXPRESSLINK3_CMD_SUBSCRIBE "AT+SUBSCRIBE"
84 #define IOTEXPRESSLINK3_CMD_UNSUBSCRIBE "AT+UNSUBSCRIBE"
85 #define IOTEXPRESSLINK3_CMD_CONF "AT+CONF"
86 #define IOTEXPRESSLINK3_CMD_CONF_CHECK "AT+CONF?"
87 #define IOTEXPRESSLINK3_CMD_EVENT "AT+EVENT?"
88 #define IOTEXPRESSLINK3_CMD_TIME "AT+TIME?"
89 #define IOTEXPRESSLINK3_CMD_WHERE "AT+WHERE?"
90 #define IOTEXPRESSLINK3_CMD_SEPARATOR " "
91 #define IOTEXPRESSLINK3_CMD_SIGN_EQUAL "="
92 
97 #define IOTEXPRESSLINK3_CONF_KEY_ABOUT "About"
98 #define IOTEXPRESSLINK3_CONF_KEY_VERSION "Version"
99 #define IOTEXPRESSLINK3_CONF_KEY_TECH_SPEC "TechSpec"
100 #define IOTEXPRESSLINK3_CONF_KEY_THING_NAME "ThingName"
101 #define IOTEXPRESSLINK3_CONF_KEY_CERTIFICATE "Certificate"
102 #define IOTEXPRESSLINK3_CONF_KEY_CUSTOM_NAME "CustomName"
103 #define IOTEXPRESSLINK3_CONF_KEY_ENDPOINT "Endpoint"
104 #define IOTEXPRESSLINK3_CONF_KEY_ROOT_CA "RootCA"
105 #define IOTEXPRESSLINK3_CONF_KEY_DEFENDER "Defender"
106 #define IOTEXPRESSLINK3_CONF_KEY_HOTA_CERTIFICATE "HOTAcertificate"
107 #define IOTEXPRESSLINK3_CONF_KEY_OTA_CERTIFICATE "OTAcertificate"
108 #define IOTEXPRESSLINK3_CONF_KEY_SSID "SSID"
109 #define IOTEXPRESSLINK3_CONF_KEY_PASSPHRASE "Passphrase"
110 #define IOTEXPRESSLINK3_CONF_KEY_APN "APN"
111 #define IOTEXPRESSLINK3_CONF_KEY_QOS "QOS"
112 #define IOTEXPRESSLINK3_CONF_KEY_TOPIC "Topic"
113 
118 #define IOTEXPRESSLINK3_RSP_OK "OK"
119 #define IOTEXPRESSLINK3_RSP_ERR "ERR"
120 
126 #define IOTEXPRESSLINK3_TX_DRV_BUFFER_SIZE 300
127 #define IOTEXPRESSLINK3_RX_DRV_BUFFER_SIZE 1000
128  // iotexpresslink3_cmd
130 
145 #define IOTEXPRESSLINK3_MAP_MIKROBUS( cfg, mikrobus ) \
146  cfg.tx_pin = MIKROBUS( mikrobus, MIKROBUS_TX ); \
147  cfg.rx_pin = MIKROBUS( mikrobus, MIKROBUS_RX ); \
148  cfg.rsn = MIKROBUS( mikrobus, MIKROBUS_AN ); \
149  cfg.rst = MIKROBUS( mikrobus, MIKROBUS_RST ); \
150  cfg.wake = MIKROBUS( mikrobus, MIKROBUS_PWM ); \
151  cfg.event = MIKROBUS( mikrobus, MIKROBUS_INT );
152  // iotexpresslink3_map // iotexpresslink3
155 
160 typedef struct
161 {
162  // Output pins
163  digital_out_t rst;
165  // Input pins
166  digital_in_t event;
167  digital_in_t wake;
168  digital_in_t rsn;
170  // Modules
171  uart_t uart;
173  // Buffers
174  uint8_t uart_rx_buffer[ IOTEXPRESSLINK3_RX_DRV_BUFFER_SIZE ];
175  uint8_t uart_tx_buffer[ IOTEXPRESSLINK3_TX_DRV_BUFFER_SIZE ];
178 
183 typedef struct
184 {
185  // Communication gpio pins
186  pin_name_t rx_pin;
187  pin_name_t tx_pin;
189  // Additional gpio pins
190  pin_name_t rst;
191  pin_name_t event;
192  pin_name_t wake;
193  pin_name_t rsn;
195  // Static variable
196  uint32_t baud_rate;
198  uart_data_bits_t data_bit;
199  uart_parity_t parity_bit;
200  uart_stop_bits_t stop_bit;
203 
208 typedef enum
209 {
215 
217 
234 
249 
262 err_t iotexpresslink3_generic_write ( iotexpresslink3_t *ctx, uint8_t *data_in, uint16_t len );
263 
276 err_t iotexpresslink3_generic_read ( iotexpresslink3_t *ctx, uint8_t *data_out, uint16_t len );
277 
287 void iotexpresslink3_send_cmd ( iotexpresslink3_t *ctx, uint8_t *cmd );
288 
298 
308 
318 
328 
338 
348 
349 #ifdef __cplusplus
350 }
351 #endif
352 #endif // IOTEXPRESSLINK3_H
353  // iotexpresslink3
355 
356 // ------------------------------------------------------------------------ END
IOTEXPRESSLINK3_ERROR_TIMEOUT
@ IOTEXPRESSLINK3_ERROR_TIMEOUT
Definition: iotexpresslink3.h:212
iotexpresslink3_generic_read
err_t iotexpresslink3_generic_read(iotexpresslink3_t *ctx, uint8_t *data_out, uint16_t len)
IoT ExpressLink 3 data reading function.
iotexpresslink3_cfg_t::uart_blocking
bool uart_blocking
Definition: iotexpresslink3.h:197
IOTEXPRESSLINK3_RX_DRV_BUFFER_SIZE
#define IOTEXPRESSLINK3_RX_DRV_BUFFER_SIZE
Definition: iotexpresslink3.h:127
iotexpresslink3_t::event
digital_in_t event
Definition: iotexpresslink3.h:166
iotexpresslink3_disable_device
void iotexpresslink3_disable_device(iotexpresslink3_t *ctx)
IoT ExpressLink 3 disable device function.
iotexpresslink3_return_value_t
iotexpresslink3_return_value_t
IoT ExpressLink 3 Click return value data.
Definition: iotexpresslink3.h:209
iotexpresslink3_get_wake_pin
uint8_t iotexpresslink3_get_wake_pin(iotexpresslink3_t *ctx)
IoT ExpressLink 3 get wake pin function.
iotexpresslink3_t::rsn
digital_in_t rsn
Definition: iotexpresslink3.h:168
iotexpresslink3_get_event_pin
uint8_t iotexpresslink3_get_event_pin(iotexpresslink3_t *ctx)
IoT ExpressLink 3 get event pin function.
iotexpresslink3_cfg_t
IoT ExpressLink 3 Click configuration object.
Definition: iotexpresslink3.h:184
iotexpresslink3_cfg_t::stop_bit
uart_stop_bits_t stop_bit
Definition: iotexpresslink3.h:200
IOTEXPRESSLINK3_ERROR_CMD
@ IOTEXPRESSLINK3_ERROR_CMD
Definition: iotexpresslink3.h:213
IOTEXPRESSLINK3_ERROR_UNKNOWN
@ IOTEXPRESSLINK3_ERROR_UNKNOWN
Definition: iotexpresslink3.h:214
iotexpresslink3_t::uart
uart_t uart
Definition: iotexpresslink3.h:171
iotexpresslink3_cfg_t::parity_bit
uart_parity_t parity_bit
Definition: iotexpresslink3.h:199
iotexpresslink3_t::wake
digital_in_t wake
Definition: iotexpresslink3.h:167
iotexpresslink3_cfg_t::rx_pin
pin_name_t rx_pin
Definition: iotexpresslink3.h:186
iotexpresslink3_cfg_setup
void iotexpresslink3_cfg_setup(iotexpresslink3_cfg_t *cfg)
IoT ExpressLink 3 configuration object setup function.
IOTEXPRESSLINK3_TX_DRV_BUFFER_SIZE
#define IOTEXPRESSLINK3_TX_DRV_BUFFER_SIZE
IoT ExpressLink 3 driver buffer size.
Definition: iotexpresslink3.h:126
IOTEXPRESSLINK3_OK
@ IOTEXPRESSLINK3_OK
Definition: iotexpresslink3.h:210
iotexpresslink3_cfg_t::tx_pin
pin_name_t tx_pin
Definition: iotexpresslink3.h:187
iotexpresslink3_enable_device
void iotexpresslink3_enable_device(iotexpresslink3_t *ctx)
IoT ExpressLink 3 enable device function.
iotexpresslink3_send_cmd
void iotexpresslink3_send_cmd(iotexpresslink3_t *ctx, uint8_t *cmd)
IoT ExpressLink 3 send cmd function.
iotexpresslink3_cfg_t::event
pin_name_t event
Definition: iotexpresslink3.h:191
iotexpresslink3_cfg_t::rst
pin_name_t rst
Definition: iotexpresslink3.h:190
IOTEXPRESSLINK3_ERROR
@ IOTEXPRESSLINK3_ERROR
Definition: iotexpresslink3.h:211
iotexpresslink3_cfg_t::data_bit
uart_data_bits_t data_bit
Definition: iotexpresslink3.h:198
iotexpresslink3_t::rst
digital_out_t rst
Definition: iotexpresslink3.h:163
iotexpresslink3_init
err_t iotexpresslink3_init(iotexpresslink3_t *ctx, iotexpresslink3_cfg_t *cfg)
IoT ExpressLink 3 initialization function.
iotexpresslink3_t
IoT ExpressLink 3 Click context object.
Definition: iotexpresslink3.h:161
iotexpresslink3_get_rsn_pin
uint8_t iotexpresslink3_get_rsn_pin(iotexpresslink3_t *ctx)
IoT ExpressLink 3 get rsn pin function.
iotexpresslink3_cfg_t::baud_rate
uint32_t baud_rate
Definition: iotexpresslink3.h:196
iotexpresslink3_cfg_t::rsn
pin_name_t rsn
Definition: iotexpresslink3.h:193
iotexpresslink3_cfg_t::wake
pin_name_t wake
Definition: iotexpresslink3.h:192
iotexpresslink3_reset_device
void iotexpresslink3_reset_device(iotexpresslink3_t *ctx)
IoT ExpressLink 3 reset device function.
iotexpresslink3_generic_write
err_t iotexpresslink3_generic_write(iotexpresslink3_t *ctx, uint8_t *data_in, uint16_t len)
IoT ExpressLink 3 data writing function.