customized SNICInterface
Fork of NySNICInterface by
SNIC/SNIC_Core.h@33:33f1bc919486, 2014-06-03 (annotated)
- Committer:
- kishino
- Date:
- Tue Jun 03 08:53:07 2014 +0000
- Revision:
- 33:33f1bc919486
- Parent:
- 32:ae95309643aa
- Child:
- 36:f33fcf5975ab
Created functions of UDP client and UDP server.
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
kishino | 20:dd736d328de6 | 1 | /******************* Murata Manufacturing Co.,Ltd. 2014 ***************** |
kishino | 20:dd736d328de6 | 2 | * |
kishino | 20:dd736d328de6 | 3 | * Filename: SNIC_Core.h |
kishino | 20:dd736d328de6 | 4 | * |
kishino | 20:dd736d328de6 | 5 | * Purpose: This module has define of internal common function for API. |
kishino | 20:dd736d328de6 | 6 | * |
kishino | 20:dd736d328de6 | 7 | * $Author: kishino $ |
kishino | 20:dd736d328de6 | 8 | * |
kishino | 20:dd736d328de6 | 9 | * $Date: 2014/03/26 $ |
kishino | 20:dd736d328de6 | 10 | * |
kishino | 20:dd736d328de6 | 11 | * $Revision: 0.0.0.1 $ |
kishino | 20:dd736d328de6 | 12 | * ***********************************************************************/ |
kishino | 20:dd736d328de6 | 13 | #ifndef _SNIC_CORE_H_ |
kishino | 20:dd736d328de6 | 14 | #define _SNIC_CORE_H_ |
kishino | 20:dd736d328de6 | 15 | |
kishino | 25:67183ed15708 | 16 | #include "MurataObject.h" |
kishino | 20:dd736d328de6 | 17 | #include "mbed.h" |
kishino | 20:dd736d328de6 | 18 | #include "rtos.h" |
kishino | 20:dd736d328de6 | 19 | #include "RawSerial.h" |
kishino | 20:dd736d328de6 | 20 | #include "CBuffer.h" |
kishino | 20:dd736d328de6 | 21 | |
kishino | 20:dd736d328de6 | 22 | #include "SNIC_UartCommandManager.h" |
kishino | 20:dd736d328de6 | 23 | |
kishino | 29:6a0ba999597d | 24 | #define UART_REQUEST_PAYLOAD_MAX 1024 |
kishino | 20:dd736d328de6 | 25 | |
kishino | 20:dd736d328de6 | 26 | #define MEMPOOL_BLOCK_SIZE 2048 |
kishino | 20:dd736d328de6 | 27 | #define MEMPOOL_PAYLOAD_NUM 1 |
kishino | 20:dd736d328de6 | 28 | #define MAX_SOCKET_ID 5 |
kishino | 20:dd736d328de6 | 29 | |
kishino | 29:6a0ba999597d | 30 | #define MEMPOOL_UART_RECV_NUM 2 |
kishino | 32:ae95309643aa | 31 | #define SNIC_UART_RECVBUF_SIZE 2048 |
kishino | 29:6a0ba999597d | 32 | |
kishino | 20:dd736d328de6 | 33 | /** Wi-Fi security |
kishino | 20:dd736d328de6 | 34 | */ |
kishino | 20:dd736d328de6 | 35 | typedef enum SECURITY { |
kishino | 20:dd736d328de6 | 36 | /** Securiry Open */ |
kishino | 20:dd736d328de6 | 37 | e_SEC_OPEN = 0x00, |
kishino | 20:dd736d328de6 | 38 | /** Securiry WEP */ |
kishino | 20:dd736d328de6 | 39 | e_SEC_WEP = 0x01, |
kishino | 20:dd736d328de6 | 40 | /** Securiry WPA-PSK(TKIP) */ |
kishino | 20:dd736d328de6 | 41 | e_SEC_WPA_TKIP = 0x02, |
kishino | 20:dd736d328de6 | 42 | /** Securiry WPA2-PSK(AES) */ |
kishino | 20:dd736d328de6 | 43 | e_SEC_WPA2_AES = 0x04, |
kishino | 20:dd736d328de6 | 44 | /** Securiry WPA2-PSK(TKIP/AES) */ |
kishino | 20:dd736d328de6 | 45 | e_SEC_WPA2_MIXED = 0x06, |
kishino | 20:dd736d328de6 | 46 | /** Securiry WPA-PSK(AES) */ |
kishino | 20:dd736d328de6 | 47 | e_SEC_WPA_AES = 0x07 |
kishino | 20:dd736d328de6 | 48 | }E_SECURITY; |
kishino | 20:dd736d328de6 | 49 | |
kishino | 20:dd736d328de6 | 50 | /** Wi-Fi status |
kishino | 20:dd736d328de6 | 51 | */ |
kishino | 20:dd736d328de6 | 52 | typedef enum WIFI_STATUS { |
kishino | 20:dd736d328de6 | 53 | /** Wi-Fi OFF */ |
kishino | 20:dd736d328de6 | 54 | e_STATUS_OFF = 0, |
kishino | 20:dd736d328de6 | 55 | /** No network */ |
kishino | 20:dd736d328de6 | 56 | e_NO_NETWORK, |
kishino | 20:dd736d328de6 | 57 | /** Connected to AP (STA mode) */ |
kishino | 20:dd736d328de6 | 58 | e_STA_JOINED, |
kishino | 20:dd736d328de6 | 59 | /** Started on AP mode */ |
kishino | 20:dd736d328de6 | 60 | e_AP_STARTED |
kishino | 20:dd736d328de6 | 61 | }E_WIFI_STATUS; |
kishino | 20:dd736d328de6 | 62 | |
kishino | 29:6a0ba999597d | 63 | /** Memorypool |
kishino | 29:6a0ba999597d | 64 | */ |
kishino | 29:6a0ba999597d | 65 | typedef struct |
kishino | 29:6a0ba999597d | 66 | { |
kishino | 29:6a0ba999597d | 67 | unsigned int size; |
kishino | 29:6a0ba999597d | 68 | unsigned char buf[MEMPOOL_BLOCK_SIZE]; |
kishino | 29:6a0ba999597d | 69 | }tagMEMPOOL_BLOCK_T; |
kishino | 29:6a0ba999597d | 70 | |
kishino | 23:4ff2231ff9ba | 71 | /** Internal class used by any other classes. This class is singleton. |
kishino | 20:dd736d328de6 | 72 | */ |
kishino | 25:67183ed15708 | 73 | class C_SNIC_Core: public C_MurataObject |
kishino | 20:dd736d328de6 | 74 | { |
kishino | 21:dda155fe5048 | 75 | friend class C_SNIC_UartCommandManager; |
kishino | 21:dda155fe5048 | 76 | friend class C_SNIC_WifiInterface; |
kishino | 21:dda155fe5048 | 77 | friend class TCPSocketConnection; |
kishino | 33:33f1bc919486 | 78 | friend class TCPSocketServer; |
kishino | 33:33f1bc919486 | 79 | friend class UDPSocket; |
kishino | 21:dda155fe5048 | 80 | friend class Socket; |
kishino | 21:dda155fe5048 | 81 | |
kishino | 21:dda155fe5048 | 82 | private: |
kishino | 22:a9ec0cad4f84 | 83 | /** Wi-Fi Network type |
kishino | 22:a9ec0cad4f84 | 84 | */ |
kishino | 22:a9ec0cad4f84 | 85 | typedef enum NETWORK_TYPE { |
kishino | 22:a9ec0cad4f84 | 86 | /** Infrastructure */ |
kishino | 22:a9ec0cad4f84 | 87 | e_INFRA = 0, |
kishino | 22:a9ec0cad4f84 | 88 | /** Adhoc */ |
kishino | 22:a9ec0cad4f84 | 89 | e_ADHOC = 1 |
kishino | 22:a9ec0cad4f84 | 90 | }E_NETWORK_TYPE; |
kishino | 22:a9ec0cad4f84 | 91 | |
kishino | 22:a9ec0cad4f84 | 92 | /** Connection information |
kishino | 22:a9ec0cad4f84 | 93 | */ |
kishino | 22:a9ec0cad4f84 | 94 | typedef struct { |
kishino | 29:6a0ba999597d | 95 | CircBuffer<char> *recvbuf_p; |
kishino | 22:a9ec0cad4f84 | 96 | bool is_connected; |
kishino | 22:a9ec0cad4f84 | 97 | bool is_received; |
kishino | 32:ae95309643aa | 98 | int parent_socket; |
kishino | 32:ae95309643aa | 99 | bool is_accept; |
kishino | 22:a9ec0cad4f84 | 100 | }tagCONNECT_INFO_T; |
kishino | 22:a9ec0cad4f84 | 101 | |
kishino | 33:33f1bc919486 | 102 | /** UDP Recv information |
kishino | 33:33f1bc919486 | 103 | */ |
kishino | 33:33f1bc919486 | 104 | typedef struct { |
kishino | 33:33f1bc919486 | 105 | CircBuffer<char> *recvbuf_p; |
kishino | 33:33f1bc919486 | 106 | int from_ip; |
kishino | 33:33f1bc919486 | 107 | short from_port; |
kishino | 33:33f1bc919486 | 108 | int parent_socket; |
kishino | 33:33f1bc919486 | 109 | bool is_received; |
kishino | 33:33f1bc919486 | 110 | }tagUDP_RECVINFO_T; |
kishino | 33:33f1bc919486 | 111 | |
kishino | 22:a9ec0cad4f84 | 112 | /** GEN_FW_VER_GET_REQ Command */ |
kishino | 22:a9ec0cad4f84 | 113 | typedef struct |
kishino | 22:a9ec0cad4f84 | 114 | { |
kishino | 22:a9ec0cad4f84 | 115 | unsigned char cmd_sid; |
kishino | 22:a9ec0cad4f84 | 116 | unsigned char seq; |
kishino | 22:a9ec0cad4f84 | 117 | }tagGEN_FW_VER_GET_REQ_T; |
kishino | 22:a9ec0cad4f84 | 118 | |
kishino | 22:a9ec0cad4f84 | 119 | /** SNIC_INIT_REQ */ |
kishino | 22:a9ec0cad4f84 | 120 | typedef struct |
kishino | 22:a9ec0cad4f84 | 121 | { |
kishino | 28:b796031f6519 | 122 | unsigned char cmd_sid; |
kishino | 28:b796031f6519 | 123 | unsigned char seq; |
kishino | 28:b796031f6519 | 124 | unsigned char buf_size[2]; |
kishino | 22:a9ec0cad4f84 | 125 | }tagSNIC_INIT_REQ_T; |
kishino | 22:a9ec0cad4f84 | 126 | |
kishino | 31:15c22824cc46 | 127 | /** SNIC_IP_CONFIG_REQ */ |
kishino | 31:15c22824cc46 | 128 | typedef struct |
kishino | 31:15c22824cc46 | 129 | { |
kishino | 31:15c22824cc46 | 130 | unsigned char cmd_sid; |
kishino | 31:15c22824cc46 | 131 | unsigned char seq; |
kishino | 31:15c22824cc46 | 132 | unsigned char interface; |
kishino | 31:15c22824cc46 | 133 | unsigned char dhcp; |
kishino | 31:15c22824cc46 | 134 | }tagSNIC_IP_CONFIG_REQ_DHCP_T; |
kishino | 31:15c22824cc46 | 135 | |
kishino | 31:15c22824cc46 | 136 | /** SNIC_IP_CONFIG_REQ */ |
kishino | 31:15c22824cc46 | 137 | typedef struct |
kishino | 31:15c22824cc46 | 138 | { |
kishino | 31:15c22824cc46 | 139 | unsigned char cmd_sid; |
kishino | 31:15c22824cc46 | 140 | unsigned char seq; |
kishino | 31:15c22824cc46 | 141 | unsigned char interface; |
kishino | 31:15c22824cc46 | 142 | unsigned char dhcp; |
kishino | 31:15c22824cc46 | 143 | unsigned char ip_addr[4]; |
kishino | 31:15c22824cc46 | 144 | unsigned char netmask[4]; |
kishino | 31:15c22824cc46 | 145 | unsigned char gateway[4]; |
kishino | 31:15c22824cc46 | 146 | }tagSNIC_IP_CONFIG_REQ_STATIC_T; |
kishino | 31:15c22824cc46 | 147 | |
kishino | 22:a9ec0cad4f84 | 148 | /** SNIC_TCP_CREATE_SOCKET_REQ */ |
kishino | 22:a9ec0cad4f84 | 149 | typedef struct |
kishino | 22:a9ec0cad4f84 | 150 | { |
kishino | 22:a9ec0cad4f84 | 151 | unsigned char cmd_sid; |
kishino | 22:a9ec0cad4f84 | 152 | unsigned char seq; |
kishino | 22:a9ec0cad4f84 | 153 | unsigned char bind; |
kishino | 22:a9ec0cad4f84 | 154 | unsigned char local_addr[4]; |
kishino | 22:a9ec0cad4f84 | 155 | unsigned char local_port[2]; |
kishino | 22:a9ec0cad4f84 | 156 | }tagSNIC_TCP_CREATE_SOCKET_REQ_T; |
kishino | 27:dcc4f34448f0 | 157 | |
kishino | 27:dcc4f34448f0 | 158 | /** SNIC_CLOSE_SOCKET_REQ */ |
kishino | 27:dcc4f34448f0 | 159 | typedef struct |
kishino | 27:dcc4f34448f0 | 160 | { |
kishino | 27:dcc4f34448f0 | 161 | unsigned char cmd_sid; |
kishino | 27:dcc4f34448f0 | 162 | unsigned char seq; |
kishino | 27:dcc4f34448f0 | 163 | unsigned char socket_id; |
kishino | 27:dcc4f34448f0 | 164 | }tagSNIC_CLOSE_SOCKET_REQ_T; |
kishino | 22:a9ec0cad4f84 | 165 | |
kishino | 22:a9ec0cad4f84 | 166 | /** SNIC_TCP_SEND_FROM_SOCKET_REQ */ |
kishino | 22:a9ec0cad4f84 | 167 | typedef struct |
kishino | 22:a9ec0cad4f84 | 168 | { |
kishino | 22:a9ec0cad4f84 | 169 | unsigned char cmd_sid; |
kishino | 22:a9ec0cad4f84 | 170 | unsigned char seq; |
kishino | 22:a9ec0cad4f84 | 171 | unsigned char socket_id; |
kishino | 22:a9ec0cad4f84 | 172 | unsigned char option; |
kishino | 22:a9ec0cad4f84 | 173 | unsigned char payload_len[2]; |
kishino | 22:a9ec0cad4f84 | 174 | }tagSNIC_TCP_SEND_FROM_SOCKET_REQ_T; |
kishino | 22:a9ec0cad4f84 | 175 | |
kishino | 32:ae95309643aa | 176 | /** SNIC_TCP_CREATE_CONNECTION_REQ */ |
kishino | 32:ae95309643aa | 177 | typedef struct |
kishino | 32:ae95309643aa | 178 | { |
kishino | 32:ae95309643aa | 179 | unsigned char cmd_sid; |
kishino | 32:ae95309643aa | 180 | unsigned char seq; |
kishino | 32:ae95309643aa | 181 | unsigned char socket_id; |
kishino | 32:ae95309643aa | 182 | unsigned char recv_bufsize[2]; |
kishino | 32:ae95309643aa | 183 | unsigned char max_client; |
kishino | 32:ae95309643aa | 184 | }tagSNIC_TCP_CREATE_CONNECTION_REQ_T; |
kishino | 32:ae95309643aa | 185 | |
kishino | 22:a9ec0cad4f84 | 186 | /** SNIC_TCP_CONNECT_TO_SERVER_REQ */ |
kishino | 22:a9ec0cad4f84 | 187 | typedef struct |
kishino | 22:a9ec0cad4f84 | 188 | { |
kishino | 22:a9ec0cad4f84 | 189 | unsigned char cmd_sid; |
kishino | 22:a9ec0cad4f84 | 190 | unsigned char seq; |
kishino | 22:a9ec0cad4f84 | 191 | unsigned char socket_id; |
kishino | 22:a9ec0cad4f84 | 192 | unsigned char remote_addr[4]; |
kishino | 22:a9ec0cad4f84 | 193 | unsigned char remote_port[2]; |
kishino | 22:a9ec0cad4f84 | 194 | unsigned char recv_bufsize[2]; |
kishino | 22:a9ec0cad4f84 | 195 | unsigned char timeout; |
kishino | 22:a9ec0cad4f84 | 196 | }tagSNIC_TCP_CONNECT_TO_SERVER_REQ_T; |
kishino | 22:a9ec0cad4f84 | 197 | |
kishino | 33:33f1bc919486 | 198 | /** SNIC_UDP_SIMPLE_SEND_REQ */ |
kishino | 33:33f1bc919486 | 199 | typedef struct |
kishino | 33:33f1bc919486 | 200 | { |
kishino | 33:33f1bc919486 | 201 | unsigned char cmd_sid; |
kishino | 33:33f1bc919486 | 202 | unsigned char seq; |
kishino | 33:33f1bc919486 | 203 | unsigned char remote_ip[4]; |
kishino | 33:33f1bc919486 | 204 | unsigned char remote_port[2]; |
kishino | 33:33f1bc919486 | 205 | unsigned char payload_len[2]; |
kishino | 33:33f1bc919486 | 206 | }tagSNIC_UDP_SIMPLE_SEND_REQ_T; |
kishino | 33:33f1bc919486 | 207 | |
kishino | 33:33f1bc919486 | 208 | /** SNIC_UDP_CREATE_SOCKET_REQ */ |
kishino | 33:33f1bc919486 | 209 | typedef struct |
kishino | 33:33f1bc919486 | 210 | { |
kishino | 33:33f1bc919486 | 211 | unsigned char cmd_sid; |
kishino | 33:33f1bc919486 | 212 | unsigned char seq; |
kishino | 33:33f1bc919486 | 213 | unsigned char bind; |
kishino | 33:33f1bc919486 | 214 | unsigned char local_addr[4]; |
kishino | 33:33f1bc919486 | 215 | unsigned char local_port[2]; |
kishino | 33:33f1bc919486 | 216 | }tagSNIC_UDP_CREATE_SOCKET_REQ_T; |
kishino | 33:33f1bc919486 | 217 | |
kishino | 33:33f1bc919486 | 218 | /** SNIC_UDP_START_RECV_REQ */ |
kishino | 33:33f1bc919486 | 219 | typedef struct |
kishino | 33:33f1bc919486 | 220 | { |
kishino | 33:33f1bc919486 | 221 | unsigned char cmd_sid; |
kishino | 33:33f1bc919486 | 222 | unsigned char seq; |
kishino | 33:33f1bc919486 | 223 | unsigned char socket_id; |
kishino | 33:33f1bc919486 | 224 | unsigned char recv_bufsize[2]; |
kishino | 33:33f1bc919486 | 225 | }tagSNIC_UDP_START_RECV_REQ_T; |
kishino | 33:33f1bc919486 | 226 | |
kishino | 32:ae95309643aa | 227 | /** SNIC_GET_DHCP_INFO_REQ */ |
kishino | 32:ae95309643aa | 228 | typedef struct |
kishino | 32:ae95309643aa | 229 | { |
kishino | 32:ae95309643aa | 230 | unsigned char cmd_sid; |
kishino | 32:ae95309643aa | 231 | unsigned char seq; |
kishino | 32:ae95309643aa | 232 | unsigned char interface; |
kishino | 32:ae95309643aa | 233 | }tagSNIC_GET_DHCP_INFO_REQ_T; |
kishino | 32:ae95309643aa | 234 | |
kishino | 22:a9ec0cad4f84 | 235 | /** WIFI_ON_REQ Command */ |
kishino | 22:a9ec0cad4f84 | 236 | typedef struct |
kishino | 22:a9ec0cad4f84 | 237 | { |
kishino | 22:a9ec0cad4f84 | 238 | unsigned char cmd_sid; |
kishino | 22:a9ec0cad4f84 | 239 | unsigned char seq; |
kishino | 22:a9ec0cad4f84 | 240 | char country[COUNTRYC_CODE_LENTH]; |
kishino | 22:a9ec0cad4f84 | 241 | }tagWIFI_ON_REQ_T; |
kishino | 22:a9ec0cad4f84 | 242 | |
kishino | 22:a9ec0cad4f84 | 243 | /** WIFI_OFF_REQ Command */ |
kishino | 22:a9ec0cad4f84 | 244 | typedef struct |
kishino | 22:a9ec0cad4f84 | 245 | { |
kishino | 22:a9ec0cad4f84 | 246 | unsigned char cmd_sid; |
kishino | 22:a9ec0cad4f84 | 247 | unsigned char seq; |
kishino | 22:a9ec0cad4f84 | 248 | }tagWIFI_OFF_REQ_T; |
kishino | 22:a9ec0cad4f84 | 249 | |
kishino | 22:a9ec0cad4f84 | 250 | /** WIFI_DISCONNECT_REQ Command */ |
kishino | 22:a9ec0cad4f84 | 251 | typedef struct |
kishino | 22:a9ec0cad4f84 | 252 | { |
kishino | 22:a9ec0cad4f84 | 253 | unsigned char cmd_sid; |
kishino | 22:a9ec0cad4f84 | 254 | unsigned char seq; |
kishino | 22:a9ec0cad4f84 | 255 | }tagWIFI_DISCONNECT_REQ_T; |
kishino | 22:a9ec0cad4f84 | 256 | |
kishino | 22:a9ec0cad4f84 | 257 | /** WIFI_GET_STA_RSSI_REQ Command */ |
kishino | 22:a9ec0cad4f84 | 258 | typedef struct |
kishino | 22:a9ec0cad4f84 | 259 | { |
kishino | 22:a9ec0cad4f84 | 260 | unsigned char cmd_sid; |
kishino | 22:a9ec0cad4f84 | 261 | unsigned char seq; |
kishino | 22:a9ec0cad4f84 | 262 | }tagWIFI_GET_STA_RSSI_REQ_T; |
kishino | 22:a9ec0cad4f84 | 263 | |
kishino | 22:a9ec0cad4f84 | 264 | /** WIFI_SCAN_REQ Command */ |
kishino | 22:a9ec0cad4f84 | 265 | typedef struct |
kishino | 22:a9ec0cad4f84 | 266 | { |
kishino | 22:a9ec0cad4f84 | 267 | unsigned char cmd_sid; |
kishino | 22:a9ec0cad4f84 | 268 | unsigned char seq; |
kishino | 22:a9ec0cad4f84 | 269 | unsigned char scan_type; |
kishino | 22:a9ec0cad4f84 | 270 | unsigned char bss_type; |
kishino | 22:a9ec0cad4f84 | 271 | unsigned char bssid[BSSID_MAC_LENTH]; |
kishino | 22:a9ec0cad4f84 | 272 | unsigned char chan_list; |
kishino | 22:a9ec0cad4f84 | 273 | unsigned char ssid[SSID_MAX_LENGTH+1]; |
kishino | 22:a9ec0cad4f84 | 274 | }tagWIFI_SCAN_REQ_T; |
kishino | 22:a9ec0cad4f84 | 275 | |
kishino | 29:6a0ba999597d | 276 | /** WIFI_GET_STATUS_REQ Command */ |
kishino | 29:6a0ba999597d | 277 | typedef struct |
kishino | 29:6a0ba999597d | 278 | { |
kishino | 29:6a0ba999597d | 279 | unsigned char cmd_sid; |
kishino | 29:6a0ba999597d | 280 | unsigned char seq; |
kishino | 29:6a0ba999597d | 281 | unsigned char interface; |
kishino | 29:6a0ba999597d | 282 | }tagWIFI_GET_STATUS_REQ_T; |
kishino | 29:6a0ba999597d | 283 | |
kishino | 20:dd736d328de6 | 284 | /** Get buffer for command from memory pool. |
kishino | 20:dd736d328de6 | 285 | @return Pointer of buffer |
kishino | 20:dd736d328de6 | 286 | */ |
kishino | 29:6a0ba999597d | 287 | tagMEMPOOL_BLOCK_T *allocCmdBuf(); |
kishino | 20:dd736d328de6 | 288 | |
kishino | 20:dd736d328de6 | 289 | /** Release buffer to memory pool. |
kishino | 20:dd736d328de6 | 290 | @param buf_p Pointer of buffer |
kishino | 20:dd736d328de6 | 291 | */ |
kishino | 20:dd736d328de6 | 292 | void freeCmdBuf( tagMEMPOOL_BLOCK_T *buf_p ); |
kishino | 20:dd736d328de6 | 293 | |
kishino | 29:6a0ba999597d | 294 | /** Get buffer for command from memory pool. |
kishino | 29:6a0ba999597d | 295 | @return Pointer of buffer |
kishino | 29:6a0ba999597d | 296 | */ |
kishino | 29:6a0ba999597d | 297 | tagMEMPOOL_BLOCK_T *allocUartRcvBuf(); |
kishino | 29:6a0ba999597d | 298 | |
kishino | 29:6a0ba999597d | 299 | /** Release buffer to memory pool. |
kishino | 29:6a0ba999597d | 300 | @param buf_p Pointer of buffer |
kishino | 29:6a0ba999597d | 301 | */ |
kishino | 29:6a0ba999597d | 302 | void freeUartRecvBuf( tagMEMPOOL_BLOCK_T *buf_p ); |
kishino | 29:6a0ba999597d | 303 | |
kishino | 29:6a0ba999597d | 304 | /** Module Reset |
kishino | 29:6a0ba999597d | 305 | */ |
kishino | 29:6a0ba999597d | 306 | int resetModule( PinName reset ); |
kishino | 29:6a0ba999597d | 307 | |
kishino | 29:6a0ba999597d | 308 | /** Initialize UART |
kishino | 20:dd736d328de6 | 309 | */ |
kishino | 20:dd736d328de6 | 310 | int initUart( PinName tx, PinName rx, int baud ); |
kishino | 20:dd736d328de6 | 311 | |
kishino | 20:dd736d328de6 | 312 | /** Send data to UART |
kishino | 20:dd736d328de6 | 313 | @param len Length of send data |
kishino | 20:dd736d328de6 | 314 | @param data Pointer of send data |
kishino | 20:dd736d328de6 | 315 | @return 0:success/other:fail |
kishino | 20:dd736d328de6 | 316 | */ |
kishino | 20:dd736d328de6 | 317 | int sendUart( unsigned int len, unsigned char *data ); |
kishino | 20:dd736d328de6 | 318 | |
kishino | 20:dd736d328de6 | 319 | /** Preparation of the UART command |
kishino | 20:dd736d328de6 | 320 | @param cmd_id UART Command ID |
kishino | 20:dd736d328de6 | 321 | @param cmd_sid UART Command SubID |
kishino | 20:dd736d328de6 | 322 | @param req_buf_p Pointer of UART request buffer |
kishino | 20:dd736d328de6 | 323 | @param req_buf_len Length of UART request buffer |
kishino | 20:dd736d328de6 | 324 | @param response_buf_p Pointer of UART response buffer |
kishino | 20:dd736d328de6 | 325 | @param command_p Pointer of UART command[output] |
kishino | 20:dd736d328de6 | 326 | @return Length of UART command. |
kishino | 20:dd736d328de6 | 327 | */ |
kishino | 20:dd736d328de6 | 328 | unsigned int preparationSendCommand( unsigned char cmd_id, unsigned char cmd_sid |
kishino | 20:dd736d328de6 | 329 | , unsigned char *req_buf_p, unsigned int req_buf_len |
kishino | 20:dd736d328de6 | 330 | , unsigned char *response_buf_p, unsigned char *command_p ); |
kishino | 20:dd736d328de6 | 331 | |
kishino | 20:dd736d328de6 | 332 | /** |
kishino | 20:dd736d328de6 | 333 | Get pointer of connection information. |
kishino | 20:dd736d328de6 | 334 | @param socket_id Socket ID |
kishino | 20:dd736d328de6 | 335 | @return The pointer of connection information |
kishino | 20:dd736d328de6 | 336 | */ |
kishino | 22:a9ec0cad4f84 | 337 | C_SNIC_Core::tagCONNECT_INFO_T *getConnectInfo( int socket_id ); |
kishino | 20:dd736d328de6 | 338 | |
kishino | 33:33f1bc919486 | 339 | /** |
kishino | 33:33f1bc919486 | 340 | Get pointer of UDP Recv information. |
kishino | 33:33f1bc919486 | 341 | @param socket_id Socket ID |
kishino | 33:33f1bc919486 | 342 | @return The pointer of UDP Recv information |
kishino | 33:33f1bc919486 | 343 | */ |
kishino | 33:33f1bc919486 | 344 | C_SNIC_Core::tagUDP_RECVINFO_T *getUdpRecvInfo( int socket_id ); |
kishino | 33:33f1bc919486 | 345 | |
kishino | 33:33f1bc919486 | 346 | /** |
kishino | 20:dd736d328de6 | 347 | Get pointer of the instance of C_SNIC_UartCommandManager. |
kishino | 20:dd736d328de6 | 348 | @return The pointer of the instance of C_SNIC_UartCommandManager. |
kishino | 20:dd736d328de6 | 349 | */ |
kishino | 20:dd736d328de6 | 350 | C_SNIC_UartCommandManager *getUartCommand(); |
kishino | 20:dd736d328de6 | 351 | |
kishino | 29:6a0ba999597d | 352 | unsigned char *getCommandBuf(); |
kishino | 29:6a0ba999597d | 353 | |
kishino | 20:dd736d328de6 | 354 | /** Get an instance of the C_SNIC_Core class. |
kishino | 20:dd736d328de6 | 355 | @return Instance of the C_SNIC_Core class |
kishino | 20:dd736d328de6 | 356 | @note Please do not create an instance in the default constructor this class. |
kishino | 20:dd736d328de6 | 357 | Please use this method when you want to get an instance. |
kishino | 20:dd736d328de6 | 358 | */ |
kishino | 20:dd736d328de6 | 359 | static C_SNIC_Core *getInstance(); |
kishino | 20:dd736d328de6 | 360 | |
kishino | 20:dd736d328de6 | 361 | private: |
kishino | 20:dd736d328de6 | 362 | static C_SNIC_Core *mInstance_p; |
kishino | 20:dd736d328de6 | 363 | Thread *mUartRecvThread_p; |
kishino | 29:6a0ba999597d | 364 | Thread *mUartRecvDispatchThread_p; |
kishino | 20:dd736d328de6 | 365 | RawSerial *mUart_p; |
kishino | 20:dd736d328de6 | 366 | Mutex mUartMutex; |
kishino | 29:6a0ba999597d | 367 | |
kishino | 20:dd736d328de6 | 368 | // DigitalInOut mModuleReset; |
kishino | 20:dd736d328de6 | 369 | C_SNIC_UartCommandManager *mUartCommand_p; |
kishino | 29:6a0ba999597d | 370 | |
kishino | 29:6a0ba999597d | 371 | CircBuffer<char> *mUartRecvBuf_p; // UART RecvBuffer |
kishino | 29:6a0ba999597d | 372 | |
kishino | 20:dd736d328de6 | 373 | /** Socket buffer */ |
kishino | 20:dd736d328de6 | 374 | tagCONNECT_INFO_T mConnectInfo[MAX_SOCKET_ID+1]; |
kishino | 20:dd736d328de6 | 375 | |
kishino | 33:33f1bc919486 | 376 | /** UDP Information */ |
kishino | 33:33f1bc919486 | 377 | tagUDP_RECVINFO_T mUdpRecvInfo[MAX_SOCKET_ID+1]; |
kishino | 33:33f1bc919486 | 378 | |
kishino | 33:33f1bc919486 | 379 | /** Constructor |
kishino | 20:dd736d328de6 | 380 | */ |
kishino | 20:dd736d328de6 | 381 | C_SNIC_Core(); |
kishino | 20:dd736d328de6 | 382 | |
kishino | 26:f2e1030964e4 | 383 | virtual ~C_SNIC_Core(); |
kishino | 29:6a0ba999597d | 384 | |
kishino | 29:6a0ba999597d | 385 | static void uartRecvCallback( void ); |
kishino | 20:dd736d328de6 | 386 | /** Receiving thread of UART |
kishino | 20:dd736d328de6 | 387 | */ |
kishino | 29:6a0ba999597d | 388 | static void uartRecvDispatchThread( void const *args_p ); |
kishino | 20:dd736d328de6 | 389 | }; |
kishino | 20:dd736d328de6 | 390 | |
kishino | 20:dd736d328de6 | 391 | #endif |