update
Fork of WizFi310Interface_Legacynew by
WizFi310/WizFi310.h@4:81d7f0d73aa5, 2018-09-20 (annotated)
- Committer:
- HarshaDRAGNEEL
- Date:
- Thu Sep 20 11:06:02 2018 +0000
- Revision:
- 4:81d7f0d73aa5
- Parent:
- 2:a4890cc8be69
update
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
kaizen | 0:774ff1e8b26b | 1 | /* |
kaizen | 0:774ff1e8b26b | 2 | * Copyright (C) 2013 gsfan, MIT License |
kaizen | 0:774ff1e8b26b | 3 | * |
kaizen | 0:774ff1e8b26b | 4 | * Permission is hereby granted, free of charge, to any person obtaining a copy of this software |
kaizen | 0:774ff1e8b26b | 5 | * and associated documentation files (the "Software"), to deal in the Software without restriction, |
kaizen | 0:774ff1e8b26b | 6 | * including without limitation the rights to use, copy, modify, merge, publish, distribute, |
kaizen | 0:774ff1e8b26b | 7 | * sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is |
kaizen | 0:774ff1e8b26b | 8 | * furnished to do so, subject to the following conditions: |
kaizen | 0:774ff1e8b26b | 9 | * |
kaizen | 0:774ff1e8b26b | 10 | * The above copyright notice and this permission notice shall be included in all copies or |
kaizen | 0:774ff1e8b26b | 11 | * substantial portions of the Software. |
kaizen | 0:774ff1e8b26b | 12 | * |
kaizen | 0:774ff1e8b26b | 13 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING |
kaizen | 0:774ff1e8b26b | 14 | * BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND |
kaizen | 0:774ff1e8b26b | 15 | * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, |
kaizen | 0:774ff1e8b26b | 16 | * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, |
kaizen | 0:774ff1e8b26b | 17 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. |
kaizen | 0:774ff1e8b26b | 18 | */ |
kaizen | 0:774ff1e8b26b | 19 | /* Copyright (C) 2014 Wiznet, MIT License |
kaizen | 0:774ff1e8b26b | 20 | * port to the Wiznet Module WizFi250 |
kaizen | 0:774ff1e8b26b | 21 | */ |
kaizen | 0:774ff1e8b26b | 22 | /* Copyright (C) 2017 Wiznet, MIT License |
kaizen | 0:774ff1e8b26b | 23 | * port to the Wiznet Module WizFi310 |
kaizen | 0:774ff1e8b26b | 24 | */ |
kaizen | 0:774ff1e8b26b | 25 | |
kaizen | 0:774ff1e8b26b | 26 | #ifndef WIZFI310_H_ |
kaizen | 0:774ff1e8b26b | 27 | #define WIZFI310_H_ |
kaizen | 0:774ff1e8b26b | 28 | |
kaizen | 0:774ff1e8b26b | 29 | #include "WizFi310_conf.h" |
kaizen | 0:774ff1e8b26b | 30 | |
kaizen | 0:774ff1e8b26b | 31 | #include "mbed.h" |
kaizen | 0:774ff1e8b26b | 32 | #include "RawSerial.h" |
kaizen | 0:774ff1e8b26b | 33 | #include "Serial.h" |
kaizen | 0:774ff1e8b26b | 34 | #include "CBuffer.h" |
kaizen | 0:774ff1e8b26b | 35 | #include <ctype.h> |
kaizen | 0:774ff1e8b26b | 36 | #include <stdlib.h> |
kaizen | 0:774ff1e8b26b | 37 | #include <string> |
kaizen | 0:774ff1e8b26b | 38 | |
kaizen | 0:774ff1e8b26b | 39 | using namespace std; |
kaizen | 0:774ff1e8b26b | 40 | |
kaizen | 0:774ff1e8b26b | 41 | #define BUF_SIZE 1600 |
kaizen | 0:774ff1e8b26b | 42 | |
kaizen | 0:774ff1e8b26b | 43 | //Debug is disabled by default |
kaizen | 0:774ff1e8b26b | 44 | #if 1 |
kaizen | 0:774ff1e8b26b | 45 | #define WIZ_DBG(x, ...) std::printf("[WizFi310: DBG]" x "\r\n", ##__VA_ARGS__); |
kaizen | 0:774ff1e8b26b | 46 | #define WIZ_WARN(x, ...) std::printf("[WizFi310: WARN]" x "\r\n", ##__VA_ARGS__); |
kaizen | 0:774ff1e8b26b | 47 | #define WIZ_ERR(x, ...) std::printf("[WizFi310: ERR]" x "\r\n", ##__VA_ARGS__); |
kaizen | 0:774ff1e8b26b | 48 | #define WIZ_INFO(x, ...) std::printf("[WizFi310: INFO]" x "\r\n", ##__VA_ARGS__); |
kaizen | 0:774ff1e8b26b | 49 | #else |
kaizen | 0:774ff1e8b26b | 50 | #define WIZ_DBG(x, ...) |
kaizen | 0:774ff1e8b26b | 51 | #define WIZ_WARN(x, ...) |
kaizen | 0:774ff1e8b26b | 52 | #define WIZ_ERR(x, ...) |
kaizen | 0:774ff1e8b26b | 53 | #define WIZ_INFO(x, ...) |
kaizen | 0:774ff1e8b26b | 54 | #endif |
kaizen | 0:774ff1e8b26b | 55 | |
kaizen | 0:774ff1e8b26b | 56 | |
kaizen | 0:774ff1e8b26b | 57 | class WizFi310 |
kaizen | 0:774ff1e8b26b | 58 | { |
kaizen | 0:774ff1e8b26b | 59 | public: |
kaizen | 0:774ff1e8b26b | 60 | |
kaizen | 0:774ff1e8b26b | 61 | enum AntennaMode{ |
kaizen | 0:774ff1e8b26b | 62 | PCB = 0, |
kaizen | 0:774ff1e8b26b | 63 | UFL = 1, |
kaizen | 0:774ff1e8b26b | 64 | AUTO = 3, |
kaizen | 0:774ff1e8b26b | 65 | }; |
kaizen | 0:774ff1e8b26b | 66 | |
kaizen | 0:774ff1e8b26b | 67 | enum WiFiMode { |
kaizen | 0:774ff1e8b26b | 68 | WM_STATION = 0, |
kaizen | 0:774ff1e8b26b | 69 | WM_AP = 1, |
kaizen | 0:774ff1e8b26b | 70 | }; |
kaizen | 0:774ff1e8b26b | 71 | |
kaizen | 0:774ff1e8b26b | 72 | /** Wi-Fi security |
kaizen | 0:774ff1e8b26b | 73 | */ |
kaizen | 0:774ff1e8b26b | 74 | enum Security { |
kaizen | 0:774ff1e8b26b | 75 | // kaizen need to change |
kaizen | 0:774ff1e8b26b | 76 | SEC_AUTO = 0, |
kaizen | 0:774ff1e8b26b | 77 | SEC_OPEN = 1, |
kaizen | 0:774ff1e8b26b | 78 | SEC_WEP = 2, |
kaizen | 0:774ff1e8b26b | 79 | SEC_WPA_TKIP = 3, |
kaizen | 0:774ff1e8b26b | 80 | SEC_WPA_AES = 4, |
kaizen | 0:774ff1e8b26b | 81 | SEC_WPA2_AES = 5, |
kaizen | 0:774ff1e8b26b | 82 | SEC_WPA2_TKIP = 6, |
kaizen | 0:774ff1e8b26b | 83 | SEC_WPA2_MIXED = 7, |
kaizen | 0:774ff1e8b26b | 84 | }; |
kaizen | 0:774ff1e8b26b | 85 | |
kaizen | 0:774ff1e8b26b | 86 | /** TCP/IP protocol |
kaizen | 0:774ff1e8b26b | 87 | */ |
kaizen | 0:774ff1e8b26b | 88 | enum Protocol { |
kaizen | 0:774ff1e8b26b | 89 | PROTO_UDP = 0, |
kaizen | 0:774ff1e8b26b | 90 | PROTO_TCP = 1, |
kaizen | 0:774ff1e8b26b | 91 | }; |
kaizen | 0:774ff1e8b26b | 92 | |
kaizen | 0:774ff1e8b26b | 93 | /** Client/Server |
kaizen | 0:774ff1e8b26b | 94 | */ |
kaizen | 0:774ff1e8b26b | 95 | enum Type { |
kaizen | 0:774ff1e8b26b | 96 | TYPE_CLIENT = 0, |
kaizen | 0:774ff1e8b26b | 97 | TYPE_SERVER = 1, |
kaizen | 0:774ff1e8b26b | 98 | }; |
kaizen | 0:774ff1e8b26b | 99 | |
kaizen | 0:774ff1e8b26b | 100 | enum Response { |
kaizen | 0:774ff1e8b26b | 101 | RES_NULL, |
kaizen | 0:774ff1e8b26b | 102 | RES_MACADDRESS, |
kaizen | 0:774ff1e8b26b | 103 | RES_WJOIN, |
kaizen | 0:774ff1e8b26b | 104 | RES_CONNECT, |
kaizen | 0:774ff1e8b26b | 105 | RES_SSEND, |
kaizen | 0:774ff1e8b26b | 106 | RES_FDNS, |
kaizen | 0:774ff1e8b26b | 107 | RES_SMGMT, |
kaizen | 0:774ff1e8b26b | 108 | RES_WSTATUS, |
kaizen | 0:774ff1e8b26b | 109 | |
kaizen | 0:774ff1e8b26b | 110 | }; |
kaizen | 0:774ff1e8b26b | 111 | |
kaizen | 0:774ff1e8b26b | 112 | enum Mode { |
kaizen | 0:774ff1e8b26b | 113 | MODE_COMMAND, |
kaizen | 0:774ff1e8b26b | 114 | MODE_CMDRESP, |
kaizen | 0:774ff1e8b26b | 115 | MODE_DATA_RX, |
kaizen | 0:774ff1e8b26b | 116 | MODE_DATA_RXUDP, |
kaizen | 0:774ff1e8b26b | 117 | MODE_DATA_RXUDP_BULK, |
kaizen | 0:774ff1e8b26b | 118 | }; |
kaizen | 0:774ff1e8b26b | 119 | |
kaizen | 0:774ff1e8b26b | 120 | enum Status { |
kaizen | 0:774ff1e8b26b | 121 | STAT_NONE, |
kaizen | 0:774ff1e8b26b | 122 | STAT_READY, |
kaizen | 0:774ff1e8b26b | 123 | STAT_STANDBY, |
kaizen | 0:774ff1e8b26b | 124 | STAT_WAKEUP, |
kaizen | 0:774ff1e8b26b | 125 | STAT_DEEPSLEEP, |
kaizen | 0:774ff1e8b26b | 126 | }; |
kaizen | 0:774ff1e8b26b | 127 | |
kaizen | 0:774ff1e8b26b | 128 | |
kaizen | 0:774ff1e8b26b | 129 | WizFi310 (PinName tx, PinName rx, PinName cts, PinName rts, PinName reset, PinName alarm = NC, int baud = 115200); |
kaizen | 0:774ff1e8b26b | 130 | |
kaizen | 0:774ff1e8b26b | 131 | // --------- WizFi250_at.cpp --------- |
kaizen | 0:774ff1e8b26b | 132 | void clearFlags (); |
kaizen | 0:774ff1e8b26b | 133 | int sendCommand (const char * cmd, Response res = RES_NULL, int timeout = DEFAULT_WAIT_RESP_TIMEOUT, int opt = 1); |
kaizen | 0:774ff1e8b26b | 134 | |
kaizen | 0:774ff1e8b26b | 135 | int cmdAT (); |
kaizen | 0:774ff1e8b26b | 136 | int cmdMECHO (bool flg); |
kaizen | 0:774ff1e8b26b | 137 | int cmdUSET (int baud, char *flow); |
kaizen | 0:774ff1e8b26b | 138 | int cmdMMAC (const char *mac = NULL); |
kaizen | 0:774ff1e8b26b | 139 | int cmdWSET (WiFiMode mode, const char *ssid, const char *bssid = NULL, int channel = 1); |
kaizen | 0:774ff1e8b26b | 140 | int cmdWANT (AntennaMode mode); |
kaizen | 0:774ff1e8b26b | 141 | int cmdWNET (bool is_dhcp); |
kaizen | 0:774ff1e8b26b | 142 | int cmdWSEC (WiFiMode mode, const char *key, const char *sec = NULL); |
kaizen | 0:774ff1e8b26b | 143 | int cmdWJOIN (); |
kaizen | 0:774ff1e8b26b | 144 | int cmdWLEAVE (); |
kaizen | 0:774ff1e8b26b | 145 | int cmdWSTATUS (); |
kaizen | 0:774ff1e8b26b | 146 | int cmdSCON ( const char *openType, const char *socketType, int localPort, const char *dataMode = "0"); |
kaizen | 0:774ff1e8b26b | 147 | int cmdSCON ( const char *openType, const char *socketType, const char *remoteIp, int remotePort, int localPort = 0, const char *dataMode = "0"); |
kaizen | 0:774ff1e8b26b | 148 | int cmdSSEND ( const char *data, int cid, int sendSize, const char *remoteIp = NULL, int remotePort = 0, int Timeout = 2000 ); |
kaizen | 0:774ff1e8b26b | 149 | int cmdCLOSE ( int cid ); |
kaizen | 0:774ff1e8b26b | 150 | int cmdFDNS (const char *host); |
kaizen | 0:774ff1e8b26b | 151 | int cmdSMGMT ( int cid ); |
ajeet3004 | 2:a4890cc8be69 | 152 | int cmdTEST (); |
kaizen | 0:774ff1e8b26b | 153 | |
kaizen | 0:774ff1e8b26b | 154 | |
kaizen | 0:774ff1e8b26b | 155 | static WizFi310 * getInstance() { |
kaizen | 0:774ff1e8b26b | 156 | return _inst; |
kaizen | 0:774ff1e8b26b | 157 | }; |
kaizen | 0:774ff1e8b26b | 158 | |
kaizen | 0:774ff1e8b26b | 159 | |
kaizen | 0:774ff1e8b26b | 160 | // --------- WizFi2550_sock.cpp --------- |
kaizen | 0:774ff1e8b26b | 161 | int getHostByName (const char * host, char *ip); |
kaizen | 0:774ff1e8b26b | 162 | int open (Protocol proto, const char *ip, int remotePort, int localPort = 0, void(*func)(int) = NULL); |
kaizen | 0:774ff1e8b26b | 163 | int listen (Protocol proto, int port, void(*func)(int)=NULL); |
kaizen | 0:774ff1e8b26b | 164 | int close (int cid); |
kaizen | 0:774ff1e8b26b | 165 | void initCon (int cid, bool connected); |
kaizen | 0:774ff1e8b26b | 166 | int send (int cid, const char *buf, int len); |
kaizen | 0:774ff1e8b26b | 167 | int sendto (int cid, const char *buf, int len, const char *ip, int port); |
kaizen | 0:774ff1e8b26b | 168 | int recv (int cid, char *buf, int len); |
kaizen | 0:774ff1e8b26b | 169 | int recvfrom (int cid, char *buf, int len, char *ip, int *port); |
kaizen | 0:774ff1e8b26b | 170 | int readable (int cid); |
kaizen | 0:774ff1e8b26b | 171 | bool isConnected (int cid); |
kaizen | 0:774ff1e8b26b | 172 | int accept (int cid); |
kaizen | 0:774ff1e8b26b | 173 | int getRemote (int cid, char **ip, int *port); |
kaizen | 0:774ff1e8b26b | 174 | |
kaizen | 0:774ff1e8b26b | 175 | |
kaizen | 0:774ff1e8b26b | 176 | protected: |
kaizen | 0:774ff1e8b26b | 177 | static WizFi310 * _inst; |
kaizen | 0:774ff1e8b26b | 178 | |
kaizen | 0:774ff1e8b26b | 179 | |
kaizen | 0:774ff1e8b26b | 180 | // Serial _wizfi |
kaizen | 0:774ff1e8b26b | 181 | RawSerial _wizfi; |
kaizen | 0:774ff1e8b26b | 182 | int _baud; |
kaizen | 0:774ff1e8b26b | 183 | DigitalIn *_cts; |
kaizen | 0:774ff1e8b26b | 184 | DigitalOut *_rts; |
kaizen | 0:774ff1e8b26b | 185 | int _flow; |
kaizen | 0:774ff1e8b26b | 186 | |
kaizen | 0:774ff1e8b26b | 187 | DigitalInOut _reset; |
kaizen | 0:774ff1e8b26b | 188 | |
kaizen | 0:774ff1e8b26b | 189 | struct STATE { |
kaizen | 0:774ff1e8b26b | 190 | WiFiMode wm; |
kaizen | 0:774ff1e8b26b | 191 | |
kaizen | 0:774ff1e8b26b | 192 | Security sec; |
kaizen | 0:774ff1e8b26b | 193 | char ssid[35]; |
kaizen | 0:774ff1e8b26b | 194 | char pass[66]; |
kaizen | 0:774ff1e8b26b | 195 | char ip[16]; |
kaizen | 0:774ff1e8b26b | 196 | char netmask[16]; |
kaizen | 0:774ff1e8b26b | 197 | char gateway[16]; |
kaizen | 0:774ff1e8b26b | 198 | char nameserver[16]; |
kaizen | 0:774ff1e8b26b | 199 | char mac[18]; |
kaizen | 0:774ff1e8b26b | 200 | char resolv[16]; |
kaizen | 0:774ff1e8b26b | 201 | char name[32]; |
kaizen | 0:774ff1e8b26b | 202 | int rssi; |
kaizen | 0:774ff1e8b26b | 203 | bool dhcp; |
kaizen | 0:774ff1e8b26b | 204 | time_t time; |
kaizen | 0:774ff1e8b26b | 205 | |
kaizen | 0:774ff1e8b26b | 206 | bool initialized; |
kaizen | 0:774ff1e8b26b | 207 | bool associated; |
kaizen | 0:774ff1e8b26b | 208 | volatile Mode mode; |
kaizen | 0:774ff1e8b26b | 209 | volatile Status status; |
kaizen | 0:774ff1e8b26b | 210 | bool escape; |
kaizen | 0:774ff1e8b26b | 211 | volatile bool ok, failure; |
kaizen | 0:774ff1e8b26b | 212 | volatile Response res; |
kaizen | 0:774ff1e8b26b | 213 | int cid; |
kaizen | 0:774ff1e8b26b | 214 | int n; |
kaizen | 0:774ff1e8b26b | 215 | CircBuffer<char> *buf; |
kaizen | 0:774ff1e8b26b | 216 | char dbgRespBuf[BUF_SIZE]; |
kaizen | 0:774ff1e8b26b | 217 | //char dummyBuf[BUF_SIZE]; |
kaizen | 0:774ff1e8b26b | 218 | } _state; |
kaizen | 0:774ff1e8b26b | 219 | |
kaizen | 0:774ff1e8b26b | 220 | |
kaizen | 0:774ff1e8b26b | 221 | public: |
kaizen | 0:774ff1e8b26b | 222 | struct CONNECTION { |
kaizen | 0:774ff1e8b26b | 223 | Protocol protocol; |
kaizen | 0:774ff1e8b26b | 224 | Type type; |
kaizen | 0:774ff1e8b26b | 225 | bool connected; |
kaizen | 0:774ff1e8b26b | 226 | char ip[16]; |
kaizen | 0:774ff1e8b26b | 227 | int port; |
kaizen | 0:774ff1e8b26b | 228 | int send_length; |
kaizen | 0:774ff1e8b26b | 229 | int recv_length; |
kaizen | 0:774ff1e8b26b | 230 | CircBuffer<char> *buf; |
kaizen | 0:774ff1e8b26b | 231 | volatile bool received; |
kaizen | 0:774ff1e8b26b | 232 | volatile int parent; |
kaizen | 0:774ff1e8b26b | 233 | volatile bool accept; |
kaizen | 0:774ff1e8b26b | 234 | void(*func)(int); |
kaizen | 0:774ff1e8b26b | 235 | } _con[8]; |
kaizen | 0:774ff1e8b26b | 236 | |
kaizen | 0:774ff1e8b26b | 237 | // --------- WizFi310.cpp --------- |
kaizen | 0:774ff1e8b26b | 238 | |
kaizen | 0:774ff1e8b26b | 239 | int join(WiFiMode mode); |
kaizen | 0:774ff1e8b26b | 240 | bool isAssociated(); |
kaizen | 0:774ff1e8b26b | 241 | |
kaizen | 0:774ff1e8b26b | 242 | //int limitedap (); |
kaizen | 0:774ff1e8b26b | 243 | //int dissociate (); |
kaizen | 0:774ff1e8b26b | 244 | /* |
kaizen | 0:774ff1e8b26b | 245 | int disconnect () { |
kaizen | 0:774ff1e8b26b | 246 | return dissociate(); |
kaizen | 0:774ff1e8b26b | 247 | } |
kaizen | 0:774ff1e8b26b | 248 | */ |
kaizen | 0:774ff1e8b26b | 249 | |
kaizen | 0:774ff1e8b26b | 250 | Status getStatus (); |
kaizen | 0:774ff1e8b26b | 251 | |
kaizen | 0:774ff1e8b26b | 252 | int setMacAddress (const char *mac); |
kaizen | 0:774ff1e8b26b | 253 | int getMacAddress (char *mac); |
kaizen | 0:774ff1e8b26b | 254 | int setAddress (const char *name = NULL); |
kaizen | 0:774ff1e8b26b | 255 | int setAddress (const char *ip, const char *netmask, const char *gateway, const char *dns = NULL, const char *name = NULL); |
kaizen | 0:774ff1e8b26b | 256 | int getAddress (char *ip, char *netmask, char *gateway); |
kaizen | 0:774ff1e8b26b | 257 | int setSsid (const char *ssid); |
kaizen | 0:774ff1e8b26b | 258 | int setSec (Security sec, const char *phrase); |
kaizen | 0:774ff1e8b26b | 259 | |
kaizen | 0:774ff1e8b26b | 260 | const char* getIPAddress (void); |
kaizen | 0:774ff1e8b26b | 261 | const char* getMACAddress (void); |
kaizen | 0:774ff1e8b26b | 262 | |
kaizen | 0:774ff1e8b26b | 263 | // --------- WizFi250_msg.cpp --------- |
kaizen | 0:774ff1e8b26b | 264 | void recvData ( char c ); |
kaizen | 0:774ff1e8b26b | 265 | int parseMessage (); |
kaizen | 0:774ff1e8b26b | 266 | void msgOk (const char *buf); |
kaizen | 0:774ff1e8b26b | 267 | void msgError (const char *buf); |
kaizen | 0:774ff1e8b26b | 268 | void msgConnect (const char *buf); |
kaizen | 0:774ff1e8b26b | 269 | void msgDisconnect (const char *buf); |
kaizen | 0:774ff1e8b26b | 270 | void msgListen (const char *buf); |
kaizen | 0:774ff1e8b26b | 271 | //daniel |
kaizen | 0:774ff1e8b26b | 272 | void msgMQTTConnect (const char *buf); |
kaizen | 0:774ff1e8b26b | 273 | void msgMQTTDisconnect (const char *buf); |
kaizen | 0:774ff1e8b26b | 274 | |
kaizen | 0:774ff1e8b26b | 275 | void resMacAddress (const char *buf); |
kaizen | 0:774ff1e8b26b | 276 | void resWJOIN (const char *buf); |
kaizen | 0:774ff1e8b26b | 277 | void resConnect (const char *buf); |
kaizen | 0:774ff1e8b26b | 278 | void resSSEND (const char *buf); |
kaizen | 0:774ff1e8b26b | 279 | void resFDNS (const char *buf); |
kaizen | 0:774ff1e8b26b | 280 | void resSMGMT (const char *buf); |
kaizen | 0:774ff1e8b26b | 281 | void resWSTATUS (const char *buf); |
kaizen | 0:774ff1e8b26b | 282 | |
kaizen | 0:774ff1e8b26b | 283 | |
kaizen | 0:774ff1e8b26b | 284 | // --------- WizFi250_hal.cpp --------- |
kaizen | 0:774ff1e8b26b | 285 | void setReset (bool flg); |
kaizen | 0:774ff1e8b26b | 286 | void isrUart (); |
kaizen | 0:774ff1e8b26b | 287 | int getUart (); |
kaizen | 0:774ff1e8b26b | 288 | void putUart (char c); |
kaizen | 0:774ff1e8b26b | 289 | void setRts (bool flg); |
kaizen | 0:774ff1e8b26b | 290 | int lockUart (int ms); |
kaizen | 0:774ff1e8b26b | 291 | void unlockUart (); |
kaizen | 0:774ff1e8b26b | 292 | void initUart (PinName cts, PinName rts, PinName alarm, int baud); |
kaizen | 0:774ff1e8b26b | 293 | |
kaizen | 0:774ff1e8b26b | 294 | |
kaizen | 0:774ff1e8b26b | 295 | // --------- WizFi2550_util.cpp --------- |
kaizen | 0:774ff1e8b26b | 296 | int x2i (char c); |
kaizen | 0:774ff1e8b26b | 297 | int i2x (int i); |
kaizen | 0:774ff1e8b26b | 298 | |
kaizen | 0:774ff1e8b26b | 299 | // --------- WizFi250_ifc.cpp (For NetworkSocketAPI) --------- |
kaizen | 0:774ff1e8b26b | 300 | /** |
kaizen | 0:774ff1e8b26b | 301 | * Startup the WizFi310 |
kaizen | 0:774ff1e8b26b | 302 | * |
kaizen | 0:774ff1e8b26b | 303 | * @return true only if WizFi310 was setup correctly |
kaizen | 0:774ff1e8b26b | 304 | */ |
kaizen | 0:774ff1e8b26b | 305 | bool startup(void); |
kaizen | 0:774ff1e8b26b | 306 | |
kaizen | 0:774ff1e8b26b | 307 | /** |
kaizen | 0:774ff1e8b26b | 308 | * Reset WizFi310 |
kaizen | 0:774ff1e8b26b | 309 | * |
kaizen | 0:774ff1e8b26b | 310 | * @return true only if WizFi310 resets successfully |
kaizen | 0:774ff1e8b26b | 311 | */ |
kaizen | 0:774ff1e8b26b | 312 | bool reset(void); |
kaizen | 0:774ff1e8b26b | 313 | |
kaizen | 0:774ff1e8b26b | 314 | /** |
kaizen | 0:774ff1e8b26b | 315 | * Disconnect WizFi310 from AP |
kaizen | 0:774ff1e8b26b | 316 | * |
kaizen | 0:774ff1e8b26b | 317 | * @return true only if WizFi310 is disconnected successfully |
kaizen | 0:774ff1e8b26b | 318 | */ |
kaizen | 0:774ff1e8b26b | 319 | bool disconnect(void); |
kaizen | 0:774ff1e8b26b | 320 | |
kaizen | 0:774ff1e8b26b | 321 | /** |
kaizen | 0:774ff1e8b26b | 322 | * Check if WizFi310 is conenected |
kaizen | 0:774ff1e8b26b | 323 | * |
kaizen | 0:774ff1e8b26b | 324 | * @return true only if the chip has an IP address |
kaizen | 0:774ff1e8b26b | 325 | */ |
kaizen | 0:774ff1e8b26b | 326 | bool isConnected(void); |
kaizen | 0:774ff1e8b26b | 327 | |
kaizen | 0:774ff1e8b26b | 328 | |
kaizen | 0:774ff1e8b26b | 329 | //daniel for mqtt |
kaizen | 0:774ff1e8b26b | 330 | char rcvd_mqtt_topic[128]; |
kaizen | 0:774ff1e8b26b | 331 | |
kaizen | 0:774ff1e8b26b | 332 | }; |
kaizen | 0:774ff1e8b26b | 333 | |
kaizen | 0:774ff1e8b26b | 334 | #endif /* WIZFI250_H_ */ |