WizFi310station
Fork of WizFi310Interface_Legacy by
WizFi310/WizFi310.h@0:774ff1e8b26b, 2017-04-19 (annotated)
- Committer:
- kaizen
- Date:
- Wed Apr 19 00:46:44 2017 +0000
- Revision:
- 0:774ff1e8b26b
- Child:
- 2:6f9444b6e733
First release WizFi310Interface for mbed OS2 ( Legacy version )
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 ); |
kaizen | 0:774ff1e8b26b | 152 | |
kaizen | 0:774ff1e8b26b | 153 | |
kaizen | 0:774ff1e8b26b | 154 | static WizFi310 * getInstance() { |
kaizen | 0:774ff1e8b26b | 155 | return _inst; |
kaizen | 0:774ff1e8b26b | 156 | }; |
kaizen | 0:774ff1e8b26b | 157 | |
kaizen | 0:774ff1e8b26b | 158 | |
kaizen | 0:774ff1e8b26b | 159 | // --------- WizFi2550_sock.cpp --------- |
kaizen | 0:774ff1e8b26b | 160 | int getHostByName (const char * host, char *ip); |
kaizen | 0:774ff1e8b26b | 161 | int open (Protocol proto, const char *ip, int remotePort, int localPort = 0, void(*func)(int) = NULL); |
kaizen | 0:774ff1e8b26b | 162 | int listen (Protocol proto, int port, void(*func)(int)=NULL); |
kaizen | 0:774ff1e8b26b | 163 | int close (int cid); |
kaizen | 0:774ff1e8b26b | 164 | void initCon (int cid, bool connected); |
kaizen | 0:774ff1e8b26b | 165 | int send (int cid, const char *buf, int len); |
kaizen | 0:774ff1e8b26b | 166 | int sendto (int cid, const char *buf, int len, const char *ip, int port); |
kaizen | 0:774ff1e8b26b | 167 | int recv (int cid, char *buf, int len); |
kaizen | 0:774ff1e8b26b | 168 | int recvfrom (int cid, char *buf, int len, char *ip, int *port); |
kaizen | 0:774ff1e8b26b | 169 | int readable (int cid); |
kaizen | 0:774ff1e8b26b | 170 | bool isConnected (int cid); |
kaizen | 0:774ff1e8b26b | 171 | int accept (int cid); |
kaizen | 0:774ff1e8b26b | 172 | int getRemote (int cid, char **ip, int *port); |
kaizen | 0:774ff1e8b26b | 173 | |
kaizen | 0:774ff1e8b26b | 174 | |
kaizen | 0:774ff1e8b26b | 175 | protected: |
kaizen | 0:774ff1e8b26b | 176 | static WizFi310 * _inst; |
kaizen | 0:774ff1e8b26b | 177 | |
kaizen | 0:774ff1e8b26b | 178 | |
kaizen | 0:774ff1e8b26b | 179 | // Serial _wizfi |
kaizen | 0:774ff1e8b26b | 180 | RawSerial _wizfi; |
kaizen | 0:774ff1e8b26b | 181 | int _baud; |
kaizen | 0:774ff1e8b26b | 182 | DigitalIn *_cts; |
kaizen | 0:774ff1e8b26b | 183 | DigitalOut *_rts; |
kaizen | 0:774ff1e8b26b | 184 | int _flow; |
kaizen | 0:774ff1e8b26b | 185 | |
kaizen | 0:774ff1e8b26b | 186 | DigitalInOut _reset; |
kaizen | 0:774ff1e8b26b | 187 | |
kaizen | 0:774ff1e8b26b | 188 | struct STATE { |
kaizen | 0:774ff1e8b26b | 189 | WiFiMode wm; |
kaizen | 0:774ff1e8b26b | 190 | |
kaizen | 0:774ff1e8b26b | 191 | Security sec; |
kaizen | 0:774ff1e8b26b | 192 | char ssid[35]; |
kaizen | 0:774ff1e8b26b | 193 | char pass[66]; |
kaizen | 0:774ff1e8b26b | 194 | char ip[16]; |
kaizen | 0:774ff1e8b26b | 195 | char netmask[16]; |
kaizen | 0:774ff1e8b26b | 196 | char gateway[16]; |
kaizen | 0:774ff1e8b26b | 197 | char nameserver[16]; |
kaizen | 0:774ff1e8b26b | 198 | char mac[18]; |
kaizen | 0:774ff1e8b26b | 199 | char resolv[16]; |
kaizen | 0:774ff1e8b26b | 200 | char name[32]; |
kaizen | 0:774ff1e8b26b | 201 | int rssi; |
kaizen | 0:774ff1e8b26b | 202 | bool dhcp; |
kaizen | 0:774ff1e8b26b | 203 | time_t time; |
kaizen | 0:774ff1e8b26b | 204 | |
kaizen | 0:774ff1e8b26b | 205 | bool initialized; |
kaizen | 0:774ff1e8b26b | 206 | bool associated; |
kaizen | 0:774ff1e8b26b | 207 | volatile Mode mode; |
kaizen | 0:774ff1e8b26b | 208 | volatile Status status; |
kaizen | 0:774ff1e8b26b | 209 | bool escape; |
kaizen | 0:774ff1e8b26b | 210 | volatile bool ok, failure; |
kaizen | 0:774ff1e8b26b | 211 | volatile Response res; |
kaizen | 0:774ff1e8b26b | 212 | int cid; |
kaizen | 0:774ff1e8b26b | 213 | int n; |
kaizen | 0:774ff1e8b26b | 214 | CircBuffer<char> *buf; |
kaizen | 0:774ff1e8b26b | 215 | char dbgRespBuf[BUF_SIZE]; |
kaizen | 0:774ff1e8b26b | 216 | //char dummyBuf[BUF_SIZE]; |
kaizen | 0:774ff1e8b26b | 217 | } _state; |
kaizen | 0:774ff1e8b26b | 218 | |
kaizen | 0:774ff1e8b26b | 219 | |
kaizen | 0:774ff1e8b26b | 220 | public: |
kaizen | 0:774ff1e8b26b | 221 | struct CONNECTION { |
kaizen | 0:774ff1e8b26b | 222 | Protocol protocol; |
kaizen | 0:774ff1e8b26b | 223 | Type type; |
kaizen | 0:774ff1e8b26b | 224 | bool connected; |
kaizen | 0:774ff1e8b26b | 225 | char ip[16]; |
kaizen | 0:774ff1e8b26b | 226 | int port; |
kaizen | 0:774ff1e8b26b | 227 | int send_length; |
kaizen | 0:774ff1e8b26b | 228 | int recv_length; |
kaizen | 0:774ff1e8b26b | 229 | CircBuffer<char> *buf; |
kaizen | 0:774ff1e8b26b | 230 | volatile bool received; |
kaizen | 0:774ff1e8b26b | 231 | volatile int parent; |
kaizen | 0:774ff1e8b26b | 232 | volatile bool accept; |
kaizen | 0:774ff1e8b26b | 233 | void(*func)(int); |
kaizen | 0:774ff1e8b26b | 234 | } _con[8]; |
kaizen | 0:774ff1e8b26b | 235 | |
kaizen | 0:774ff1e8b26b | 236 | // --------- WizFi310.cpp --------- |
kaizen | 0:774ff1e8b26b | 237 | |
kaizen | 0:774ff1e8b26b | 238 | int join(WiFiMode mode); |
kaizen | 0:774ff1e8b26b | 239 | bool isAssociated(); |
kaizen | 0:774ff1e8b26b | 240 | |
kaizen | 0:774ff1e8b26b | 241 | //int limitedap (); |
kaizen | 0:774ff1e8b26b | 242 | //int dissociate (); |
kaizen | 0:774ff1e8b26b | 243 | /* |
kaizen | 0:774ff1e8b26b | 244 | int disconnect () { |
kaizen | 0:774ff1e8b26b | 245 | return dissociate(); |
kaizen | 0:774ff1e8b26b | 246 | } |
kaizen | 0:774ff1e8b26b | 247 | */ |
kaizen | 0:774ff1e8b26b | 248 | |
kaizen | 0:774ff1e8b26b | 249 | Status getStatus (); |
kaizen | 0:774ff1e8b26b | 250 | |
kaizen | 0:774ff1e8b26b | 251 | int setMacAddress (const char *mac); |
kaizen | 0:774ff1e8b26b | 252 | int getMacAddress (char *mac); |
kaizen | 0:774ff1e8b26b | 253 | int setAddress (const char *name = NULL); |
kaizen | 0:774ff1e8b26b | 254 | int setAddress (const char *ip, const char *netmask, const char *gateway, const char *dns = NULL, const char *name = NULL); |
kaizen | 0:774ff1e8b26b | 255 | int getAddress (char *ip, char *netmask, char *gateway); |
kaizen | 0:774ff1e8b26b | 256 | int setSsid (const char *ssid); |
kaizen | 0:774ff1e8b26b | 257 | int setSec (Security sec, const char *phrase); |
kaizen | 0:774ff1e8b26b | 258 | |
kaizen | 0:774ff1e8b26b | 259 | const char* getIPAddress (void); |
kaizen | 0:774ff1e8b26b | 260 | const char* getMACAddress (void); |
kaizen | 0:774ff1e8b26b | 261 | |
kaizen | 0:774ff1e8b26b | 262 | // --------- WizFi250_msg.cpp --------- |
kaizen | 0:774ff1e8b26b | 263 | void recvData ( char c ); |
kaizen | 0:774ff1e8b26b | 264 | int parseMessage (); |
kaizen | 0:774ff1e8b26b | 265 | void msgOk (const char *buf); |
kaizen | 0:774ff1e8b26b | 266 | void msgError (const char *buf); |
kaizen | 0:774ff1e8b26b | 267 | void msgConnect (const char *buf); |
kaizen | 0:774ff1e8b26b | 268 | void msgDisconnect (const char *buf); |
kaizen | 0:774ff1e8b26b | 269 | void msgListen (const char *buf); |
kaizen | 0:774ff1e8b26b | 270 | //daniel |
kaizen | 0:774ff1e8b26b | 271 | void msgMQTTConnect (const char *buf); |
kaizen | 0:774ff1e8b26b | 272 | void msgMQTTDisconnect (const char *buf); |
kaizen | 0:774ff1e8b26b | 273 | |
kaizen | 0:774ff1e8b26b | 274 | void resMacAddress (const char *buf); |
kaizen | 0:774ff1e8b26b | 275 | void resWJOIN (const char *buf); |
kaizen | 0:774ff1e8b26b | 276 | void resConnect (const char *buf); |
kaizen | 0:774ff1e8b26b | 277 | void resSSEND (const char *buf); |
kaizen | 0:774ff1e8b26b | 278 | void resFDNS (const char *buf); |
kaizen | 0:774ff1e8b26b | 279 | void resSMGMT (const char *buf); |
kaizen | 0:774ff1e8b26b | 280 | void resWSTATUS (const char *buf); |
kaizen | 0:774ff1e8b26b | 281 | |
kaizen | 0:774ff1e8b26b | 282 | |
kaizen | 0:774ff1e8b26b | 283 | // --------- WizFi250_hal.cpp --------- |
kaizen | 0:774ff1e8b26b | 284 | void setReset (bool flg); |
kaizen | 0:774ff1e8b26b | 285 | void isrUart (); |
kaizen | 0:774ff1e8b26b | 286 | int getUart (); |
kaizen | 0:774ff1e8b26b | 287 | void putUart (char c); |
kaizen | 0:774ff1e8b26b | 288 | void setRts (bool flg); |
kaizen | 0:774ff1e8b26b | 289 | int lockUart (int ms); |
kaizen | 0:774ff1e8b26b | 290 | void unlockUart (); |
kaizen | 0:774ff1e8b26b | 291 | void initUart (PinName cts, PinName rts, PinName alarm, int baud); |
kaizen | 0:774ff1e8b26b | 292 | |
kaizen | 0:774ff1e8b26b | 293 | |
kaizen | 0:774ff1e8b26b | 294 | // --------- WizFi2550_util.cpp --------- |
kaizen | 0:774ff1e8b26b | 295 | int x2i (char c); |
kaizen | 0:774ff1e8b26b | 296 | int i2x (int i); |
kaizen | 0:774ff1e8b26b | 297 | |
kaizen | 0:774ff1e8b26b | 298 | // --------- WizFi250_ifc.cpp (For NetworkSocketAPI) --------- |
kaizen | 0:774ff1e8b26b | 299 | /** |
kaizen | 0:774ff1e8b26b | 300 | * Startup the WizFi310 |
kaizen | 0:774ff1e8b26b | 301 | * |
kaizen | 0:774ff1e8b26b | 302 | * @return true only if WizFi310 was setup correctly |
kaizen | 0:774ff1e8b26b | 303 | */ |
kaizen | 0:774ff1e8b26b | 304 | bool startup(void); |
kaizen | 0:774ff1e8b26b | 305 | |
kaizen | 0:774ff1e8b26b | 306 | /** |
kaizen | 0:774ff1e8b26b | 307 | * Reset WizFi310 |
kaizen | 0:774ff1e8b26b | 308 | * |
kaizen | 0:774ff1e8b26b | 309 | * @return true only if WizFi310 resets successfully |
kaizen | 0:774ff1e8b26b | 310 | */ |
kaizen | 0:774ff1e8b26b | 311 | bool reset(void); |
kaizen | 0:774ff1e8b26b | 312 | |
kaizen | 0:774ff1e8b26b | 313 | /** |
kaizen | 0:774ff1e8b26b | 314 | * Disconnect WizFi310 from AP |
kaizen | 0:774ff1e8b26b | 315 | * |
kaizen | 0:774ff1e8b26b | 316 | * @return true only if WizFi310 is disconnected successfully |
kaizen | 0:774ff1e8b26b | 317 | */ |
kaizen | 0:774ff1e8b26b | 318 | bool disconnect(void); |
kaizen | 0:774ff1e8b26b | 319 | |
kaizen | 0:774ff1e8b26b | 320 | /** |
kaizen | 0:774ff1e8b26b | 321 | * Check if WizFi310 is conenected |
kaizen | 0:774ff1e8b26b | 322 | * |
kaizen | 0:774ff1e8b26b | 323 | * @return true only if the chip has an IP address |
kaizen | 0:774ff1e8b26b | 324 | */ |
kaizen | 0:774ff1e8b26b | 325 | bool isConnected(void); |
kaizen | 0:774ff1e8b26b | 326 | |
kaizen | 0:774ff1e8b26b | 327 | |
kaizen | 0:774ff1e8b26b | 328 | //daniel for mqtt |
kaizen | 0:774ff1e8b26b | 329 | char rcvd_mqtt_topic[128]; |
kaizen | 0:774ff1e8b26b | 330 | |
kaizen | 0:774ff1e8b26b | 331 | }; |
kaizen | 0:774ff1e8b26b | 332 | |
kaizen | 0:774ff1e8b26b | 333 | #endif /* WIZFI250_H_ */ |