HXC Client Shield Repository.

Dependencies:   mbed

Committer:
kashish_mbed
Date:
Tue Apr 13 22:04:32 2021 +0000
Revision:
2:52bb5ee0a72d
Parent:
0:bacc6e701fb4
Provisioning Cmd process(Not Working)

Who changed what in which revision?

UserRevisionLine numberNew contents of line
kashish_mbed 0:bacc6e701fb4 1 /**
kashish_mbed 0:bacc6e701fb4 2 ******************************************************************************
kashish_mbed 0:bacc6e701fb4 3 * @file hxc_client.h
kashish_mbed 0:bacc6e701fb4 4 * @author Fahad Mirza (Haxiot)
kashish_mbed 0:bacc6e701fb4 5 * @version V1.0.0
kashish_mbed 0:bacc6e701fb4 6 * @modified 24-Jan-2019
kashish_mbed 0:bacc6e701fb4 7 * @brief Header for driver hxc_client.c module
kashish_mbed 0:bacc6e701fb4 8 ******************************************************************************
kashish_mbed 0:bacc6e701fb4 9 * @attention
kashish_mbed 0:bacc6e701fb4 10 *
kashish_mbed 0:bacc6e701fb4 11 * _ _ _____ _______
kashish_mbed 0:bacc6e701fb4 12 * | | | | |_ _| |__ __|
kashish_mbed 0:bacc6e701fb4 13 * | |__| | __ ___ __ | | ___ | |
kashish_mbed 0:bacc6e701fb4 14 * | __ |/ _` \ \/ / | | / _ \| |
kashish_mbed 0:bacc6e701fb4 15 * | | | | (_| |> < _| || (_) | |
kashish_mbed 0:bacc6e701fb4 16 * |_| |_|\__,_/_/\_\_____\___/|_|
kashish_mbed 0:bacc6e701fb4 17 * (C)2017 HaxIoT
kashish_mbed 0:bacc6e701fb4 18 * <h2><center>&copy; COPYRIGHT(c) 2017 Haxiot</center></h2>
kashish_mbed 0:bacc6e701fb4 19 *
kashish_mbed 0:bacc6e701fb4 20 * Redistribution and use in source and binary forms, with or without modification,
kashish_mbed 0:bacc6e701fb4 21 * are permitted provided that the following conditions are met:
kashish_mbed 0:bacc6e701fb4 22 * 1. Redistributions of source code must retain the above copyright notice,
kashish_mbed 0:bacc6e701fb4 23 * this list of conditions and the following disclaimer.
kashish_mbed 0:bacc6e701fb4 24 * 2. Redistributions in binary form must reproduce the above copyright notice,
kashish_mbed 0:bacc6e701fb4 25 * this list of conditions and the following disclaimer in the documentation
kashish_mbed 0:bacc6e701fb4 26 * and/or other materials provided with the distribution.
kashish_mbed 0:bacc6e701fb4 27 * 3. Neither the name of Haxiot nor the names of its contributors
kashish_mbed 0:bacc6e701fb4 28 * may be used to endorse or promote products derived from this software
kashish_mbed 0:bacc6e701fb4 29 * without specific prior written permission.
kashish_mbed 0:bacc6e701fb4 30 *
kashish_mbed 0:bacc6e701fb4 31 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
kashish_mbed 0:bacc6e701fb4 32 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
kashish_mbed 0:bacc6e701fb4 33 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
kashish_mbed 0:bacc6e701fb4 34 * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
kashish_mbed 0:bacc6e701fb4 35 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
kashish_mbed 0:bacc6e701fb4 36 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
kashish_mbed 0:bacc6e701fb4 37 * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
kashish_mbed 0:bacc6e701fb4 38 * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
kashish_mbed 0:bacc6e701fb4 39 * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
kashish_mbed 0:bacc6e701fb4 40 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
kashish_mbed 0:bacc6e701fb4 41 *
kashish_mbed 0:bacc6e701fb4 42 ******************************************************************************
kashish_mbed 0:bacc6e701fb4 43 */
kashish_mbed 0:bacc6e701fb4 44
kashish_mbed 0:bacc6e701fb4 45 /* Define to prevent recursive inclusion -------------------------------------*/
kashish_mbed 0:bacc6e701fb4 46 #ifndef __HXC_CLIENT__
kashish_mbed 0:bacc6e701fb4 47 #define __HXC_CLIENT__
kashish_mbed 0:bacc6e701fb4 48
kashish_mbed 0:bacc6e701fb4 49 #ifdef __cplusplus
kashish_mbed 0:bacc6e701fb4 50 extern "C" {
kashish_mbed 0:bacc6e701fb4 51 #endif
kashish_mbed 0:bacc6e701fb4 52
kashish_mbed 0:bacc6e701fb4 53
kashish_mbed 0:bacc6e701fb4 54 /* Includes ------------------------------------------------------------------*/
kashish_mbed 0:bacc6e701fb4 55 #include<stdint.h>
kashish_mbed 0:bacc6e701fb4 56 #include<stdbool.h>
kashish_mbed 2:52bb5ee0a72d 57 #include <stdarg.h>
kashish_mbed 2:52bb5ee0a72d 58 #include <string.h>
kashish_mbed 2:52bb5ee0a72d 59 #include "hw_usart.h"
kashish_mbed 2:52bb5ee0a72d 60 #include "utilities.h"
kashish_mbed 2:52bb5ee0a72d 61 #include "tiny_vsnprintf.h"
kashish_mbed 2:52bb5ee0a72d 62 #include "hw_conf.h"
kashish_mbed 2:52bb5ee0a72d 63 #include "delay.h"
kashish_mbed 2:52bb5ee0a72d 64 #include "time_server.h"
kashish_mbed 2:52bb5ee0a72d 65 #include "hw_gpio.h"
kashish_mbed 0:bacc6e701fb4 66
kashish_mbed 0:bacc6e701fb4 67 /* Typedefs ------------------------------------------------------------------*/
kashish_mbed 0:bacc6e701fb4 68 /*
kashish_mbed 0:bacc6e701fb4 69 * AT Command statuses, in direct relationship with AT_RetCode static array
kashish_mbed 0:bacc6e701fb4 70 */
kashish_mbed 0:bacc6e701fb4 71 typedef enum eAtStatus
kashish_mbed 0:bacc6e701fb4 72 {
kashish_mbed 0:bacc6e701fb4 73 AT_OK = 0,
kashish_mbed 0:bacc6e701fb4 74 AT_ERROR,
kashish_mbed 0:bacc6e701fb4 75 AT_PARAM_ERROR,
kashish_mbed 0:bacc6e701fb4 76 AT_BUSY_ERROR,
kashish_mbed 0:bacc6e701fb4 77 AT_PARAM_OVERFLOW,
kashish_mbed 0:bacc6e701fb4 78 AT_INVALID_MODE,
kashish_mbed 0:bacc6e701fb4 79 AT_NO_NET_JOINED,
kashish_mbed 0:bacc6e701fb4 80 AT_PAYLOAD_SIZE_ERROR,
kashish_mbed 0:bacc6e701fb4 81 AT_END_ERROR,
kashish_mbed 0:bacc6e701fb4 82 AT_CMD_ERROR,
kashish_mbed 0:bacc6e701fb4 83 AT_UART_LINK_ERROR, // Return code to notify error during UART Tx/Rx/Config
kashish_mbed 0:bacc6e701fb4 84 AT_TIMEOUT,
kashish_mbed 0:bacc6e701fb4 85 } eAtStatus_t;
kashish_mbed 0:bacc6e701fb4 86
kashish_mbed 0:bacc6e701fb4 87 /*
kashish_mbed 0:bacc6e701fb4 88 * AT Command Index.
kashish_mbed 0:bacc6e701fb4 89 * In direct relationship with "CmdTab" static array in atcmd.c
kashish_mbed 0:bacc6e701fb4 90 */
kashish_mbed 0:bacc6e701fb4 91 typedef enum ATCmd
kashish_mbed 0:bacc6e701fb4 92 {
kashish_mbed 0:bacc6e701fb4 93 AT,
kashish_mbed 0:bacc6e701fb4 94 AT_RESET,
kashish_mbed 0:bacc6e701fb4 95 AT_FD,
kashish_mbed 0:bacc6e701fb4 96 AT_DEVEUI,
kashish_mbed 0:bacc6e701fb4 97 AT_DEVADR,
kashish_mbed 0:bacc6e701fb4 98 AT_APPKEY,
kashish_mbed 0:bacc6e701fb4 99 AT_NWKSKEY,
kashish_mbed 0:bacc6e701fb4 100 AT_APPSKEY,
kashish_mbed 0:bacc6e701fb4 101 AT_APPEUI,
kashish_mbed 0:bacc6e701fb4 102 AT_ADR,
kashish_mbed 0:bacc6e701fb4 103 AT_TXP,
kashish_mbed 0:bacc6e701fb4 104 AT_DR,
kashish_mbed 0:bacc6e701fb4 105 AT_DCS,
kashish_mbed 0:bacc6e701fb4 106 AT_PNM,
kashish_mbed 0:bacc6e701fb4 107 AT_RX2WND,
kashish_mbed 0:bacc6e701fb4 108 AT_RX1DL,
kashish_mbed 0:bacc6e701fb4 109 AT_RX2DL,
kashish_mbed 0:bacc6e701fb4 110 AT_JN1DL,
kashish_mbed 0:bacc6e701fb4 111 AT_JN2DL,
kashish_mbed 0:bacc6e701fb4 112 AT_NJM,
kashish_mbed 0:bacc6e701fb4 113 AT_NWKID,
kashish_mbed 0:bacc6e701fb4 114 AT_FCU,
kashish_mbed 0:bacc6e701fb4 115 AT_FCD,
kashish_mbed 0:bacc6e701fb4 116 AT_CLASS,
kashish_mbed 0:bacc6e701fb4 117 AT_CH,
kashish_mbed 0:bacc6e701fb4 118 AT_JOIN,
kashish_mbed 0:bacc6e701fb4 119 AT_NJS,
kashish_mbed 0:bacc6e701fb4 120 AT_SENDB,
kashish_mbed 0:bacc6e701fb4 121 AT_SEND,
kashish_mbed 0:bacc6e701fb4 122 AT_RECVB,
kashish_mbed 0:bacc6e701fb4 123 AT_CFS,
kashish_mbed 0:bacc6e701fb4 124 AT_SNR,
kashish_mbed 0:bacc6e701fb4 125 AT_RSSI,
kashish_mbed 0:bacc6e701fb4 126 AT_MODE,
kashish_mbed 0:bacc6e701fb4 127 AT_RFCFG,
kashish_mbed 0:bacc6e701fb4 128 AT_TXCW,
kashish_mbed 0:bacc6e701fb4 129 AT_TX,
kashish_mbed 0:bacc6e701fb4 130 AT_RX,
kashish_mbed 0:bacc6e701fb4 131 AT_BAT,
kashish_mbed 0:bacc6e701fb4 132 AT_VER,
kashish_mbed 0:bacc6e701fb4 133 AT_END
kashish_mbed 0:bacc6e701fb4 134 } ATCmd_t;
kashish_mbed 0:bacc6e701fb4 135
kashish_mbed 0:bacc6e701fb4 136 // AT command behaviors
kashish_mbed 0:bacc6e701fb4 137 typedef enum ATGroup
kashish_mbed 0:bacc6e701fb4 138 {
kashish_mbed 0:bacc6e701fb4 139 AT_CTRL = 0,
kashish_mbed 0:bacc6e701fb4 140 AT_SET,
kashish_mbed 0:bacc6e701fb4 141 AT_GET,
kashish_mbed 0:bacc6e701fb4 142 AT_TEST,
kashish_mbed 0:bacc6e701fb4 143 }ATGroup_t;
kashish_mbed 0:bacc6e701fb4 144
kashish_mbed 0:bacc6e701fb4 145 // Type definition for SEND command
kashish_mbed 0:bacc6e701fb4 146 typedef struct sSendDataString
kashish_mbed 0:bacc6e701fb4 147 {
kashish_mbed 0:bacc6e701fb4 148 char *Buffer;
kashish_mbed 0:bacc6e701fb4 149 uint8_t Port;
kashish_mbed 0:bacc6e701fb4 150 uint8_t Ack;
kashish_mbed 0:bacc6e701fb4 151 }sSendDataString_t;
kashish_mbed 0:bacc6e701fb4 152
kashish_mbed 0:bacc6e701fb4 153 // Type definition for SENDB command
kashish_mbed 0:bacc6e701fb4 154 typedef struct sSendDataBinary
kashish_mbed 0:bacc6e701fb4 155 {
kashish_mbed 0:bacc6e701fb4 156 uint8_t *Buffer;
kashish_mbed 0:bacc6e701fb4 157 uint8_t DataSize;
kashish_mbed 0:bacc6e701fb4 158 uint8_t Port;
kashish_mbed 0:bacc6e701fb4 159 uint8_t Ack;
kashish_mbed 0:bacc6e701fb4 160 }sSendDataBinary_t;
kashish_mbed 0:bacc6e701fb4 161
kashish_mbed 0:bacc6e701fb4 162 // Type definition for received data
kashish_mbed 0:bacc6e701fb4 163 typedef struct sRecvDataBinary
kashish_mbed 0:bacc6e701fb4 164 {
kashish_mbed 0:bacc6e701fb4 165 uint8_t *Buffer;
kashish_mbed 0:bacc6e701fb4 166 uint32_t DataSize;
kashish_mbed 0:bacc6e701fb4 167 uint8_t Port;
kashish_mbed 0:bacc6e701fb4 168 uint8_t Ack;
kashish_mbed 0:bacc6e701fb4 169 }sRecvDataBinary_t;
kashish_mbed 0:bacc6e701fb4 170
kashish_mbed 0:bacc6e701fb4 171
kashish_mbed 0:bacc6e701fb4 172 /* Exported functions ------------------------------------------------------- */
kashish_mbed 0:bacc6e701fb4 173
kashish_mbed 0:bacc6e701fb4 174 /********************************************************************
kashish_mbed 0:bacc6e701fb4 175 * @brief Configures modem UART interface and Reset GPIO
kashish_mbed 0:bacc6e701fb4 176 * @param None
kashish_mbed 0:bacc6e701fb4 177 * @retval AT_OK in case of success
kashish_mbed 0:bacc6e701fb4 178 * @retval AT_UART_LINK_ERROR in case of failure
kashish_mbed 0:bacc6e701fb4 179 *********************************************************************/
kashish_mbed 0:bacc6e701fb4 180 eAtStatus_t Modem_Init( void ) ;
kashish_mbed 0:bacc6e701fb4 181
kashish_mbed 0:bacc6e701fb4 182 /********************************************************************
kashish_mbed 0:bacc6e701fb4 183 * @brief Deinitialize modem UART interface.
kashish_mbed 0:bacc6e701fb4 184 * @param None
kashish_mbed 0:bacc6e701fb4 185 * @retval None
kashish_mbed 0:bacc6e701fb4 186 *********************************************************************/
kashish_mbed 0:bacc6e701fb4 187 void Modem_IO_DeInit( void ) ;
kashish_mbed 0:bacc6e701fb4 188
kashish_mbed 0:bacc6e701fb4 189 /********************************************************************
kashish_mbed 0:bacc6e701fb4 190 * @brief Handle the AT cmd following their Group type
kashish_mbed 0:bacc6e701fb4 191 * @param at_group AT group [control, set , get)
kashish_mbed 0:bacc6e701fb4 192 * Cmd AT command
kashish_mbed 0:bacc6e701fb4 193 * pdata pointer to the IN/OUT buffer
kashish_mbed 0:bacc6e701fb4 194 * @retval module status
kashish_mbed 0:bacc6e701fb4 195 ********************************************************************/
kashish_mbed 0:bacc6e701fb4 196 eAtStatus_t Modem_AT_Cmd(ATGroup_t at_group, ATCmd_t Cmd, void *pdata);
kashish_mbed 0:bacc6e701fb4 197
kashish_mbed 0:bacc6e701fb4 198 /********************************************************************
kashish_mbed 0:bacc6e701fb4 199 * @brief Reset the HXC client modem using HXC RESET pin
kashish_mbed 0:bacc6e701fb4 200 * @param None
kashish_mbed 0:bacc6e701fb4 201 * @retval module status
kashish_mbed 0:bacc6e701fb4 202 ********************************************************************/
kashish_mbed 0:bacc6e701fb4 203 eAtStatus_t Modem_HardReset(void);
kashish_mbed 0:bacc6e701fb4 204
kashish_mbed 0:bacc6e701fb4 205 /********************************************************************
kashish_mbed 0:bacc6e701fb4 206 * @brief Check if any downlink packet is received
kashish_mbed 0:bacc6e701fb4 207 * @param None
kashish_mbed 0:bacc6e701fb4 208 * @retval TRUE or FALSE
kashish_mbed 0:bacc6e701fb4 209 ********************************************************************/
kashish_mbed 0:bacc6e701fb4 210 bool Modem_IsNewDataReceived(void);
kashish_mbed 0:bacc6e701fb4 211
kashish_mbed 0:bacc6e701fb4 212 char* Modem_GetResponseBuffer(void);
kashish_mbed 0:bacc6e701fb4 213
kashish_mbed 0:bacc6e701fb4 214
kashish_mbed 0:bacc6e701fb4 215 #ifdef __cplusplus
kashish_mbed 0:bacc6e701fb4 216 }
kashish_mbed 0:bacc6e701fb4 217 #endif
kashish_mbed 0:bacc6e701fb4 218
kashish_mbed 0:bacc6e701fb4 219 #endif /* __HXC_CLIENT__ */
kashish_mbed 0:bacc6e701fb4 220
kashish_mbed 0:bacc6e701fb4 221 /************************ (C) COPYRIGHT Haxiot *****END OF FILE****/
kashish_mbed 0:bacc6e701fb4 222