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 "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 IOTEXPRESSLINK3_CMD_AT "AT"
70 #define IOTEXPRESSLINK3_CMD_CONNECT "AT+CONNECT"
71 #define IOTEXPRESSLINK3_CMD_CONNECT_CHECK "AT+CONNECT?"
72 #define IOTEXPRESSLINK3_CMD_DISCONNECT "AT+DISCONNECT"
73 #define IOTEXPRESSLINK3_CMD_SLEEP "AT+SLEEP"
74 #define IOTEXPRESSLINK3_CMD_CONFMODE "AT+CONFMODE"
75 #define IOTEXPRESSLINK3_CMD_RESET "AT+RESET"
76 #define IOTEXPRESSLINK3_CMD_FACTORY_RESET "AT+FACTORY_RESET"
77 #define IOTEXPRESSLINK3_CMD_SEND "AT+SEND"
78 #define IOTEXPRESSLINK3_CMD_GET "AT+GET"
79 #define IOTEXPRESSLINK3_CMD_SUBSCRIBE "AT+SUBSCRIBE"
80 #define IOTEXPRESSLINK3_CMD_UNSUBSCRIBE "AT+UNSUBSCRIBE"
81 #define IOTEXPRESSLINK3_CMD_CONF "AT+CONF"
82 #define IOTEXPRESSLINK3_CMD_CONF_CHECK "AT+CONF?"
83 #define IOTEXPRESSLINK3_CMD_EVENT "AT+EVENT?"
84 #define IOTEXPRESSLINK3_CMD_TIME "AT+TIME?"
85 #define IOTEXPRESSLINK3_CMD_WHERE "AT+WHERE?"
86 #define IOTEXPRESSLINK3_CMD_SEPARATOR " "
87 #define IOTEXPRESSLINK3_CMD_SIGN_EQUAL "="
88 
93 #define IOTEXPRESSLINK3_CONF_KEY_ABOUT "About"
94 #define IOTEXPRESSLINK3_CONF_KEY_VERSION "Version"
95 #define IOTEXPRESSLINK3_CONF_KEY_TECH_SPEC "TechSpec"
96 #define IOTEXPRESSLINK3_CONF_KEY_THING_NAME "ThingName"
97 #define IOTEXPRESSLINK3_CONF_KEY_CERTIFICATE "Certificate"
98 #define IOTEXPRESSLINK3_CONF_KEY_CUSTOM_NAME "CustomName"
99 #define IOTEXPRESSLINK3_CONF_KEY_ENDPOINT "Endpoint"
100 #define IOTEXPRESSLINK3_CONF_KEY_ROOT_CA "RootCA"
101 #define IOTEXPRESSLINK3_CONF_KEY_DEFENDER "Defender"
102 #define IOTEXPRESSLINK3_CONF_KEY_HOTA_CERTIFICATE "HOTAcertificate"
103 #define IOTEXPRESSLINK3_CONF_KEY_OTA_CERTIFICATE "OTAcertificate"
104 #define IOTEXPRESSLINK3_CONF_KEY_SSID "SSID"
105 #define IOTEXPRESSLINK3_CONF_KEY_PASSPHRASE "Passphrase"
106 #define IOTEXPRESSLINK3_CONF_KEY_APN "APN"
107 #define IOTEXPRESSLINK3_CONF_KEY_QOS "QOS"
108 #define IOTEXPRESSLINK3_CONF_KEY_TOPIC "Topic"
109 
114 #define IOTEXPRESSLINK3_RSP_OK "OK"
115 #define IOTEXPRESSLINK3_RSP_ERR "ERR"
116 
122 #define IOTEXPRESSLINK3_TX_DRV_BUFFER_SIZE 300
123 #define IOTEXPRESSLINK3_RX_DRV_BUFFER_SIZE 1000
124  // iotexpresslink3_cmd
126 
141 #define IOTEXPRESSLINK3_MAP_MIKROBUS( cfg, mikrobus ) \
142  cfg.tx_pin = MIKROBUS( mikrobus, MIKROBUS_TX ); \
143  cfg.rx_pin = MIKROBUS( mikrobus, MIKROBUS_RX ); \
144  cfg.rsn = MIKROBUS( mikrobus, MIKROBUS_AN ); \
145  cfg.rst = MIKROBUS( mikrobus, MIKROBUS_RST ); \
146  cfg.wake = MIKROBUS( mikrobus, MIKROBUS_PWM ); \
147  cfg.event = MIKROBUS( mikrobus, MIKROBUS_INT );
148  // iotexpresslink3_map // iotexpresslink3
151 
156 typedef struct
157 {
158  // Output pins
159  digital_out_t rst;
161  // Input pins
162  digital_in_t event;
163  digital_in_t wake;
164  digital_in_t rsn;
166  // Modules
167  uart_t uart;
169  // Buffers
170  uint8_t uart_rx_buffer[ IOTEXPRESSLINK3_RX_DRV_BUFFER_SIZE ];
171  uint8_t uart_tx_buffer[ IOTEXPRESSLINK3_TX_DRV_BUFFER_SIZE ];
174 
179 typedef struct
180 {
181  // Communication gpio pins
182  pin_name_t rx_pin;
183  pin_name_t tx_pin;
185  // Additional gpio pins
186  pin_name_t rst;
187  pin_name_t event;
188  pin_name_t wake;
189  pin_name_t rsn;
191  // Static variable
192  uint32_t baud_rate;
194  uart_data_bits_t data_bit;
195  uart_parity_t parity_bit;
196  uart_stop_bits_t stop_bit;
199 
204 typedef enum
205 {
211 
213 
230 
245 
258 err_t iotexpresslink3_generic_write ( iotexpresslink3_t *ctx, uint8_t *data_in, uint16_t len );
259 
272 err_t iotexpresslink3_generic_read ( iotexpresslink3_t *ctx, uint8_t *data_out, uint16_t len );
273 
283 void iotexpresslink3_send_cmd ( iotexpresslink3_t *ctx, uint8_t *cmd );
284 
294 
304 
314 
324 
334 
344 
345 #ifdef __cplusplus
346 }
347 #endif
348 #endif // IOTEXPRESSLINK3_H
349  // iotexpresslink3
351 
352 // ------------------------------------------------------------------------ END
IOTEXPRESSLINK3_ERROR_TIMEOUT
@ IOTEXPRESSLINK3_ERROR_TIMEOUT
Definition: iotexpresslink3.h:208
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:193
IOTEXPRESSLINK3_RX_DRV_BUFFER_SIZE
#define IOTEXPRESSLINK3_RX_DRV_BUFFER_SIZE
Definition: iotexpresslink3.h:123
iotexpresslink3_t::event
digital_in_t event
Definition: iotexpresslink3.h:162
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:205
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:164
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:180
iotexpresslink3_cfg_t::stop_bit
uart_stop_bits_t stop_bit
Definition: iotexpresslink3.h:196
IOTEXPRESSLINK3_ERROR_CMD
@ IOTEXPRESSLINK3_ERROR_CMD
Definition: iotexpresslink3.h:209
IOTEXPRESSLINK3_ERROR_UNKNOWN
@ IOTEXPRESSLINK3_ERROR_UNKNOWN
Definition: iotexpresslink3.h:210
iotexpresslink3_t::uart
uart_t uart
Definition: iotexpresslink3.h:167
iotexpresslink3_cfg_t::parity_bit
uart_parity_t parity_bit
Definition: iotexpresslink3.h:195
iotexpresslink3_t::wake
digital_in_t wake
Definition: iotexpresslink3.h:163
iotexpresslink3_cfg_t::rx_pin
pin_name_t rx_pin
Definition: iotexpresslink3.h:182
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:122
IOTEXPRESSLINK3_OK
@ IOTEXPRESSLINK3_OK
Definition: iotexpresslink3.h:206
iotexpresslink3_cfg_t::tx_pin
pin_name_t tx_pin
Definition: iotexpresslink3.h:183
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:187
iotexpresslink3_cfg_t::rst
pin_name_t rst
Definition: iotexpresslink3.h:186
IOTEXPRESSLINK3_ERROR
@ IOTEXPRESSLINK3_ERROR
Definition: iotexpresslink3.h:207
iotexpresslink3_cfg_t::data_bit
uart_data_bits_t data_bit
Definition: iotexpresslink3.h:194
iotexpresslink3_t::rst
digital_out_t rst
Definition: iotexpresslink3.h:159
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:157
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:192
iotexpresslink3_cfg_t::rsn
pin_name_t rsn
Definition: iotexpresslink3.h:189
iotexpresslink3_cfg_t::wake
pin_name_t wake
Definition: iotexpresslink3.h:188
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.