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 
35 #include "drv_digital_out.h"
36 #include "drv_digital_in.h"
37 #include "drv_uart.h"
38 
59 #define IOTEXPRESSLINK3_CMD_AT "AT"
60 #define IOTEXPRESSLINK3_CMD_CONNECT "AT+CONNECT"
61 #define IOTEXPRESSLINK3_CMD_CONNECT_CHECK "AT+CONNECT?"
62 #define IOTEXPRESSLINK3_CMD_DISCONNECT "AT+DISCONNECT"
63 #define IOTEXPRESSLINK3_CMD_SLEEP "AT+SLEEP"
64 #define IOTEXPRESSLINK3_CMD_CONFMODE "AT+CONFMODE"
65 #define IOTEXPRESSLINK3_CMD_RESET "AT+RESET"
66 #define IOTEXPRESSLINK3_CMD_FACTORY_RESET "AT+FACTORY_RESET"
67 #define IOTEXPRESSLINK3_CMD_SEND "AT+SEND"
68 #define IOTEXPRESSLINK3_CMD_GET "AT+GET"
69 #define IOTEXPRESSLINK3_CMD_SUBSCRIBE "AT+SUBSCRIBE"
70 #define IOTEXPRESSLINK3_CMD_UNSUBSCRIBE "AT+UNSUBSCRIBE"
71 #define IOTEXPRESSLINK3_CMD_CONF "AT+CONF"
72 #define IOTEXPRESSLINK3_CMD_CONF_CHECK "AT+CONF?"
73 #define IOTEXPRESSLINK3_CMD_EVENT "AT+EVENT?"
74 #define IOTEXPRESSLINK3_CMD_TIME "AT+TIME?"
75 #define IOTEXPRESSLINK3_CMD_WHERE "AT+WHERE?"
76 #define IOTEXPRESSLINK3_CMD_SEPARATOR " "
77 #define IOTEXPRESSLINK3_CMD_SIGN_EQUAL "="
78 
83 #define IOTEXPRESSLINK3_CONF_KEY_ABOUT "About"
84 #define IOTEXPRESSLINK3_CONF_KEY_VERSION "Version"
85 #define IOTEXPRESSLINK3_CONF_KEY_TECH_SPEC "TechSpec"
86 #define IOTEXPRESSLINK3_CONF_KEY_THING_NAME "ThingName"
87 #define IOTEXPRESSLINK3_CONF_KEY_CERTIFICATE "Certificate"
88 #define IOTEXPRESSLINK3_CONF_KEY_CUSTOM_NAME "CustomName"
89 #define IOTEXPRESSLINK3_CONF_KEY_ENDPOINT "Endpoint"
90 #define IOTEXPRESSLINK3_CONF_KEY_ROOT_CA "RootCA"
91 #define IOTEXPRESSLINK3_CONF_KEY_DEFENDER "Defender"
92 #define IOTEXPRESSLINK3_CONF_KEY_HOTA_CERTIFICATE "HOTAcertificate"
93 #define IOTEXPRESSLINK3_CONF_KEY_OTA_CERTIFICATE "OTAcertificate"
94 #define IOTEXPRESSLINK3_CONF_KEY_SSID "SSID"
95 #define IOTEXPRESSLINK3_CONF_KEY_PASSPHRASE "Passphrase"
96 #define IOTEXPRESSLINK3_CONF_KEY_APN "APN"
97 #define IOTEXPRESSLINK3_CONF_KEY_QOS "QOS"
98 #define IOTEXPRESSLINK3_CONF_KEY_TOPIC "Topic"
99 
104 #define IOTEXPRESSLINK3_RSP_OK "OK"
105 #define IOTEXPRESSLINK3_RSP_ERR "ERR"
106 
112 #define IOTEXPRESSLINK3_TX_DRV_BUFFER_SIZE 300
113 #define IOTEXPRESSLINK3_RX_DRV_BUFFER_SIZE 1000
114  // iotexpresslink3_cmd
116 
131 #define IOTEXPRESSLINK3_MAP_MIKROBUS( cfg, mikrobus ) \
132  cfg.tx_pin = MIKROBUS( mikrobus, MIKROBUS_TX ); \
133  cfg.rx_pin = MIKROBUS( mikrobus, MIKROBUS_RX ); \
134  cfg.rsn = MIKROBUS( mikrobus, MIKROBUS_AN ); \
135  cfg.rst = MIKROBUS( mikrobus, MIKROBUS_RST ); \
136  cfg.wake = MIKROBUS( mikrobus, MIKROBUS_PWM ); \
137  cfg.event = MIKROBUS( mikrobus, MIKROBUS_INT );
138  // iotexpresslink3_map // iotexpresslink3
141 
146 typedef struct
147 {
148  // Output pins
149  digital_out_t rst;
151  // Input pins
152  digital_in_t event;
153  digital_in_t wake;
154  digital_in_t rsn;
156  // Modules
157  uart_t uart;
159  // Buffers
160  uint8_t uart_rx_buffer[ IOTEXPRESSLINK3_RX_DRV_BUFFER_SIZE ];
161  uint8_t uart_tx_buffer[ IOTEXPRESSLINK3_TX_DRV_BUFFER_SIZE ];
164 
169 typedef struct
170 {
171  // Communication gpio pins
172  pin_name_t rx_pin;
173  pin_name_t tx_pin;
175  // Additional gpio pins
176  pin_name_t rst;
177  pin_name_t event;
178  pin_name_t wake;
179  pin_name_t rsn;
181  // Static variable
182  uint32_t baud_rate;
184  uart_data_bits_t data_bit;
185  uart_parity_t parity_bit;
186  uart_stop_bits_t stop_bit;
189 
194 typedef enum
195 {
201 
203 
220 
235 
248 err_t iotexpresslink3_generic_write ( iotexpresslink3_t *ctx, uint8_t *data_in, uint16_t len );
249 
262 err_t iotexpresslink3_generic_read ( iotexpresslink3_t *ctx, uint8_t *data_out, uint16_t len );
263 
273 void iotexpresslink3_send_cmd ( iotexpresslink3_t *ctx, uint8_t *cmd );
274 
284 
294 
304 
314 
324 
334 
335 #ifdef __cplusplus
336 }
337 #endif
338 #endif // IOTEXPRESSLINK3_H
339  // iotexpresslink3
341 
342 // ------------------------------------------------------------------------ END
IOTEXPRESSLINK3_ERROR_TIMEOUT
@ IOTEXPRESSLINK3_ERROR_TIMEOUT
Definition: iotexpresslink3.h:198
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:183
IOTEXPRESSLINK3_RX_DRV_BUFFER_SIZE
#define IOTEXPRESSLINK3_RX_DRV_BUFFER_SIZE
Definition: iotexpresslink3.h:113
iotexpresslink3_t::event
digital_in_t event
Definition: iotexpresslink3.h:152
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:195
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:154
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:170
iotexpresslink3_cfg_t::stop_bit
uart_stop_bits_t stop_bit
Definition: iotexpresslink3.h:186
IOTEXPRESSLINK3_ERROR_CMD
@ IOTEXPRESSLINK3_ERROR_CMD
Definition: iotexpresslink3.h:199
IOTEXPRESSLINK3_ERROR_UNKNOWN
@ IOTEXPRESSLINK3_ERROR_UNKNOWN
Definition: iotexpresslink3.h:200
iotexpresslink3_t::uart
uart_t uart
Definition: iotexpresslink3.h:157
iotexpresslink3_cfg_t::parity_bit
uart_parity_t parity_bit
Definition: iotexpresslink3.h:185
iotexpresslink3_t::wake
digital_in_t wake
Definition: iotexpresslink3.h:153
iotexpresslink3_cfg_t::rx_pin
pin_name_t rx_pin
Definition: iotexpresslink3.h:172
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:112
IOTEXPRESSLINK3_OK
@ IOTEXPRESSLINK3_OK
Definition: iotexpresslink3.h:196
iotexpresslink3_cfg_t::tx_pin
pin_name_t tx_pin
Definition: iotexpresslink3.h:173
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:177
iotexpresslink3_cfg_t::rst
pin_name_t rst
Definition: iotexpresslink3.h:176
IOTEXPRESSLINK3_ERROR
@ IOTEXPRESSLINK3_ERROR
Definition: iotexpresslink3.h:197
iotexpresslink3_cfg_t::data_bit
uart_data_bits_t data_bit
Definition: iotexpresslink3.h:184
iotexpresslink3_t::rst
digital_out_t rst
Definition: iotexpresslink3.h:149
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:147
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:182
iotexpresslink3_cfg_t::rsn
pin_name_t rsn
Definition: iotexpresslink3.h:179
iotexpresslink3_cfg_t::wake
pin_name_t wake
Definition: iotexpresslink3.h:178
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.