Kashish Haresh Shah
/
HXCClientShield
HXC Client Shield Repository.
LoRa/hxc_client.h@0:bacc6e701fb4, 2021-03-29 (annotated)
- Committer:
- kashish_mbed
- Date:
- Mon Mar 29 15:37:08 2021 +0000
- Revision:
- 0:bacc6e701fb4
- Child:
- 2:52bb5ee0a72d
Initial Commit
Who changed what in which revision?
User | Revision | Line number | New 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>© 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 | 0:bacc6e701fb4 | 57 | |
kashish_mbed | 0:bacc6e701fb4 | 58 | /* Typedefs ------------------------------------------------------------------*/ |
kashish_mbed | 0:bacc6e701fb4 | 59 | /* |
kashish_mbed | 0:bacc6e701fb4 | 60 | * AT Command statuses, in direct relationship with AT_RetCode static array |
kashish_mbed | 0:bacc6e701fb4 | 61 | */ |
kashish_mbed | 0:bacc6e701fb4 | 62 | typedef enum eAtStatus |
kashish_mbed | 0:bacc6e701fb4 | 63 | { |
kashish_mbed | 0:bacc6e701fb4 | 64 | AT_OK = 0, |
kashish_mbed | 0:bacc6e701fb4 | 65 | AT_ERROR, |
kashish_mbed | 0:bacc6e701fb4 | 66 | AT_PARAM_ERROR, |
kashish_mbed | 0:bacc6e701fb4 | 67 | AT_BUSY_ERROR, |
kashish_mbed | 0:bacc6e701fb4 | 68 | AT_PARAM_OVERFLOW, |
kashish_mbed | 0:bacc6e701fb4 | 69 | AT_INVALID_MODE, |
kashish_mbed | 0:bacc6e701fb4 | 70 | AT_NO_NET_JOINED, |
kashish_mbed | 0:bacc6e701fb4 | 71 | AT_PAYLOAD_SIZE_ERROR, |
kashish_mbed | 0:bacc6e701fb4 | 72 | AT_END_ERROR, |
kashish_mbed | 0:bacc6e701fb4 | 73 | AT_CMD_ERROR, |
kashish_mbed | 0:bacc6e701fb4 | 74 | AT_UART_LINK_ERROR, // Return code to notify error during UART Tx/Rx/Config |
kashish_mbed | 0:bacc6e701fb4 | 75 | AT_TIMEOUT, |
kashish_mbed | 0:bacc6e701fb4 | 76 | } eAtStatus_t; |
kashish_mbed | 0:bacc6e701fb4 | 77 | |
kashish_mbed | 0:bacc6e701fb4 | 78 | /* |
kashish_mbed | 0:bacc6e701fb4 | 79 | * AT Command Index. |
kashish_mbed | 0:bacc6e701fb4 | 80 | * In direct relationship with "CmdTab" static array in atcmd.c |
kashish_mbed | 0:bacc6e701fb4 | 81 | */ |
kashish_mbed | 0:bacc6e701fb4 | 82 | typedef enum ATCmd |
kashish_mbed | 0:bacc6e701fb4 | 83 | { |
kashish_mbed | 0:bacc6e701fb4 | 84 | AT, |
kashish_mbed | 0:bacc6e701fb4 | 85 | AT_RESET, |
kashish_mbed | 0:bacc6e701fb4 | 86 | AT_FD, |
kashish_mbed | 0:bacc6e701fb4 | 87 | AT_DEVEUI, |
kashish_mbed | 0:bacc6e701fb4 | 88 | AT_DEVADR, |
kashish_mbed | 0:bacc6e701fb4 | 89 | AT_APPKEY, |
kashish_mbed | 0:bacc6e701fb4 | 90 | AT_NWKSKEY, |
kashish_mbed | 0:bacc6e701fb4 | 91 | AT_APPSKEY, |
kashish_mbed | 0:bacc6e701fb4 | 92 | AT_APPEUI, |
kashish_mbed | 0:bacc6e701fb4 | 93 | AT_ADR, |
kashish_mbed | 0:bacc6e701fb4 | 94 | AT_TXP, |
kashish_mbed | 0:bacc6e701fb4 | 95 | AT_DR, |
kashish_mbed | 0:bacc6e701fb4 | 96 | AT_DCS, |
kashish_mbed | 0:bacc6e701fb4 | 97 | AT_PNM, |
kashish_mbed | 0:bacc6e701fb4 | 98 | AT_RX2WND, |
kashish_mbed | 0:bacc6e701fb4 | 99 | AT_RX1DL, |
kashish_mbed | 0:bacc6e701fb4 | 100 | AT_RX2DL, |
kashish_mbed | 0:bacc6e701fb4 | 101 | AT_JN1DL, |
kashish_mbed | 0:bacc6e701fb4 | 102 | AT_JN2DL, |
kashish_mbed | 0:bacc6e701fb4 | 103 | AT_NJM, |
kashish_mbed | 0:bacc6e701fb4 | 104 | AT_NWKID, |
kashish_mbed | 0:bacc6e701fb4 | 105 | AT_FCU, |
kashish_mbed | 0:bacc6e701fb4 | 106 | AT_FCD, |
kashish_mbed | 0:bacc6e701fb4 | 107 | AT_CLASS, |
kashish_mbed | 0:bacc6e701fb4 | 108 | AT_CH, |
kashish_mbed | 0:bacc6e701fb4 | 109 | AT_JOIN, |
kashish_mbed | 0:bacc6e701fb4 | 110 | AT_NJS, |
kashish_mbed | 0:bacc6e701fb4 | 111 | AT_SENDB, |
kashish_mbed | 0:bacc6e701fb4 | 112 | AT_SEND, |
kashish_mbed | 0:bacc6e701fb4 | 113 | AT_RECVB, |
kashish_mbed | 0:bacc6e701fb4 | 114 | AT_CFS, |
kashish_mbed | 0:bacc6e701fb4 | 115 | AT_SNR, |
kashish_mbed | 0:bacc6e701fb4 | 116 | AT_RSSI, |
kashish_mbed | 0:bacc6e701fb4 | 117 | AT_MODE, |
kashish_mbed | 0:bacc6e701fb4 | 118 | AT_RFCFG, |
kashish_mbed | 0:bacc6e701fb4 | 119 | AT_TXCW, |
kashish_mbed | 0:bacc6e701fb4 | 120 | AT_TX, |
kashish_mbed | 0:bacc6e701fb4 | 121 | AT_RX, |
kashish_mbed | 0:bacc6e701fb4 | 122 | AT_BAT, |
kashish_mbed | 0:bacc6e701fb4 | 123 | AT_VER, |
kashish_mbed | 0:bacc6e701fb4 | 124 | AT_END |
kashish_mbed | 0:bacc6e701fb4 | 125 | } ATCmd_t; |
kashish_mbed | 0:bacc6e701fb4 | 126 | |
kashish_mbed | 0:bacc6e701fb4 | 127 | // AT command behaviors |
kashish_mbed | 0:bacc6e701fb4 | 128 | typedef enum ATGroup |
kashish_mbed | 0:bacc6e701fb4 | 129 | { |
kashish_mbed | 0:bacc6e701fb4 | 130 | AT_CTRL = 0, |
kashish_mbed | 0:bacc6e701fb4 | 131 | AT_SET, |
kashish_mbed | 0:bacc6e701fb4 | 132 | AT_GET, |
kashish_mbed | 0:bacc6e701fb4 | 133 | AT_TEST, |
kashish_mbed | 0:bacc6e701fb4 | 134 | }ATGroup_t; |
kashish_mbed | 0:bacc6e701fb4 | 135 | |
kashish_mbed | 0:bacc6e701fb4 | 136 | // Type definition for SEND command |
kashish_mbed | 0:bacc6e701fb4 | 137 | typedef struct sSendDataString |
kashish_mbed | 0:bacc6e701fb4 | 138 | { |
kashish_mbed | 0:bacc6e701fb4 | 139 | char *Buffer; |
kashish_mbed | 0:bacc6e701fb4 | 140 | uint8_t Port; |
kashish_mbed | 0:bacc6e701fb4 | 141 | uint8_t Ack; |
kashish_mbed | 0:bacc6e701fb4 | 142 | }sSendDataString_t; |
kashish_mbed | 0:bacc6e701fb4 | 143 | |
kashish_mbed | 0:bacc6e701fb4 | 144 | // Type definition for SENDB command |
kashish_mbed | 0:bacc6e701fb4 | 145 | typedef struct sSendDataBinary |
kashish_mbed | 0:bacc6e701fb4 | 146 | { |
kashish_mbed | 0:bacc6e701fb4 | 147 | uint8_t *Buffer; |
kashish_mbed | 0:bacc6e701fb4 | 148 | uint8_t DataSize; |
kashish_mbed | 0:bacc6e701fb4 | 149 | uint8_t Port; |
kashish_mbed | 0:bacc6e701fb4 | 150 | uint8_t Ack; |
kashish_mbed | 0:bacc6e701fb4 | 151 | }sSendDataBinary_t; |
kashish_mbed | 0:bacc6e701fb4 | 152 | |
kashish_mbed | 0:bacc6e701fb4 | 153 | // Type definition for received data |
kashish_mbed | 0:bacc6e701fb4 | 154 | typedef struct sRecvDataBinary |
kashish_mbed | 0:bacc6e701fb4 | 155 | { |
kashish_mbed | 0:bacc6e701fb4 | 156 | uint8_t *Buffer; |
kashish_mbed | 0:bacc6e701fb4 | 157 | uint32_t DataSize; |
kashish_mbed | 0:bacc6e701fb4 | 158 | uint8_t Port; |
kashish_mbed | 0:bacc6e701fb4 | 159 | uint8_t Ack; |
kashish_mbed | 0:bacc6e701fb4 | 160 | }sRecvDataBinary_t; |
kashish_mbed | 0:bacc6e701fb4 | 161 | |
kashish_mbed | 0:bacc6e701fb4 | 162 | |
kashish_mbed | 0:bacc6e701fb4 | 163 | /* Exported functions ------------------------------------------------------- */ |
kashish_mbed | 0:bacc6e701fb4 | 164 | |
kashish_mbed | 0:bacc6e701fb4 | 165 | /******************************************************************** |
kashish_mbed | 0:bacc6e701fb4 | 166 | * @brief Configures modem UART interface and Reset GPIO |
kashish_mbed | 0:bacc6e701fb4 | 167 | * @param None |
kashish_mbed | 0:bacc6e701fb4 | 168 | * @retval AT_OK in case of success |
kashish_mbed | 0:bacc6e701fb4 | 169 | * @retval AT_UART_LINK_ERROR in case of failure |
kashish_mbed | 0:bacc6e701fb4 | 170 | *********************************************************************/ |
kashish_mbed | 0:bacc6e701fb4 | 171 | eAtStatus_t Modem_Init( void ) ; |
kashish_mbed | 0:bacc6e701fb4 | 172 | |
kashish_mbed | 0:bacc6e701fb4 | 173 | /******************************************************************** |
kashish_mbed | 0:bacc6e701fb4 | 174 | * @brief Deinitialize modem UART interface. |
kashish_mbed | 0:bacc6e701fb4 | 175 | * @param None |
kashish_mbed | 0:bacc6e701fb4 | 176 | * @retval None |
kashish_mbed | 0:bacc6e701fb4 | 177 | *********************************************************************/ |
kashish_mbed | 0:bacc6e701fb4 | 178 | void Modem_IO_DeInit( void ) ; |
kashish_mbed | 0:bacc6e701fb4 | 179 | |
kashish_mbed | 0:bacc6e701fb4 | 180 | /******************************************************************** |
kashish_mbed | 0:bacc6e701fb4 | 181 | * @brief Handle the AT cmd following their Group type |
kashish_mbed | 0:bacc6e701fb4 | 182 | * @param at_group AT group [control, set , get) |
kashish_mbed | 0:bacc6e701fb4 | 183 | * Cmd AT command |
kashish_mbed | 0:bacc6e701fb4 | 184 | * pdata pointer to the IN/OUT buffer |
kashish_mbed | 0:bacc6e701fb4 | 185 | * @retval module status |
kashish_mbed | 0:bacc6e701fb4 | 186 | ********************************************************************/ |
kashish_mbed | 0:bacc6e701fb4 | 187 | eAtStatus_t Modem_AT_Cmd(ATGroup_t at_group, ATCmd_t Cmd, void *pdata); |
kashish_mbed | 0:bacc6e701fb4 | 188 | |
kashish_mbed | 0:bacc6e701fb4 | 189 | /******************************************************************** |
kashish_mbed | 0:bacc6e701fb4 | 190 | * @brief Reset the HXC client modem using HXC RESET pin |
kashish_mbed | 0:bacc6e701fb4 | 191 | * @param None |
kashish_mbed | 0:bacc6e701fb4 | 192 | * @retval module status |
kashish_mbed | 0:bacc6e701fb4 | 193 | ********************************************************************/ |
kashish_mbed | 0:bacc6e701fb4 | 194 | eAtStatus_t Modem_HardReset(void); |
kashish_mbed | 0:bacc6e701fb4 | 195 | |
kashish_mbed | 0:bacc6e701fb4 | 196 | /******************************************************************** |
kashish_mbed | 0:bacc6e701fb4 | 197 | * @brief Check if any downlink packet is received |
kashish_mbed | 0:bacc6e701fb4 | 198 | * @param None |
kashish_mbed | 0:bacc6e701fb4 | 199 | * @retval TRUE or FALSE |
kashish_mbed | 0:bacc6e701fb4 | 200 | ********************************************************************/ |
kashish_mbed | 0:bacc6e701fb4 | 201 | bool Modem_IsNewDataReceived(void); |
kashish_mbed | 0:bacc6e701fb4 | 202 | |
kashish_mbed | 0:bacc6e701fb4 | 203 | char* Modem_GetResponseBuffer(void); |
kashish_mbed | 0:bacc6e701fb4 | 204 | |
kashish_mbed | 0:bacc6e701fb4 | 205 | |
kashish_mbed | 0:bacc6e701fb4 | 206 | #ifdef __cplusplus |
kashish_mbed | 0:bacc6e701fb4 | 207 | } |
kashish_mbed | 0:bacc6e701fb4 | 208 | #endif |
kashish_mbed | 0:bacc6e701fb4 | 209 | |
kashish_mbed | 0:bacc6e701fb4 | 210 | #endif /* __HXC_CLIENT__ */ |
kashish_mbed | 0:bacc6e701fb4 | 211 | |
kashish_mbed | 0:bacc6e701fb4 | 212 | /************************ (C) COPYRIGHT Haxiot *****END OF FILE****/ |
kashish_mbed | 0:bacc6e701fb4 | 213 |