SNIC UART Interface library: Serial to Wi-Fi library for Murata TypeYD Wi-Fi module. For more information about TypeYD: http://www.murata.co.jp/products/microwave/module/lbwb1zzydz/index.html
Dependents: SNIC-xively-jumpstart-demo SNIC-FluentLogger-example TCPEchoServer murataDemo ... more
Fork of YDwifiInterface by
Revision 4:99cc93fe7d88, committed 2014-03-13
- Comitter:
- kishino
- Date:
- Thu Mar 13 03:38:25 2014 +0000
- Parent:
- 3:9f90024d7fb2
- Child:
- 5:ef3befe3edad
- Commit message:
- Commit stub of socket class
Changed in this revision
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Socket/Endpoint.cpp Thu Mar 13 03:38:25 2014 +0000 @@ -0,0 +1,56 @@ +/* Copyright (C) 2012 mbed.org, MIT License + * + * Permission is hereby granted, free of charge, to any person obtaining a copy of this software + * and associated documentation files (the "Software"), to deal in the Software without restriction, + * including without limitation the rights to use, copy, modify, merge, publish, distribute, + * sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all copies or + * substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING + * BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND + * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, + * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + */ +#include "Socket.h" +#include "Endpoint.h" +#include <cstring> +#include <cstdio> + +using namespace murata_wifi; + +Endpoint::Endpoint() +{ + reset_address(); +} + +Endpoint::~Endpoint() +{ +} + +void Endpoint::reset_address(void) +{ + _ipAddress[0] = '\0'; +} + +#include "stdio.h" + +int Endpoint::set_address(const char* host, const int port) +{ + reset_address(); + + return 0; +} + +char* Endpoint::get_address() +{ + return 0; +} + +int Endpoint::get_port() +{ + return 0; +}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Socket/Endpoint.h Thu Mar 13 03:38:25 2014 +0000 @@ -0,0 +1,66 @@ +/* Copyright (C) 2012 mbed.org, MIT License + * + * Permission is hereby granted, free of charge, to any person obtaining a copy of this software + * and associated documentation files (the "Software"), to deal in the Software without restriction, + * including without limitation the rights to use, copy, modify, merge, publish, distribute, + * sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all copies or + * substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING + * BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND + * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, + * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + */ +#ifndef ENDPOINT_H +#define ENDPOINT_H + +namespace murata_wifi +{ + +class UDPSocket; + +/** +IP Endpoint (address, port) +*/ +class Endpoint { + friend class UDPSocket; + +public: + /** IP Endpoint (address, port) + */ + Endpoint(void); + + ~Endpoint(void); + + /** Reset the address of this endpoint + */ + void reset_address(void); + + /** Set the address of this endpoint + \param host The endpoint address (it can either be an IP Address or a hostname that will be resolved with DNS). + \param port The endpoint port + \return 0 on success, -1 on failure (when an hostname cannot be resolved by DNS). + */ + int set_address(const char* host, const int port); + + /** Get the IP address of this endpoint + \return The IP address of this endpoint. + */ + char* get_address(void); + + /** Get the port of this endpoint + \return The port of this endpoint + */ + int get_port(void); + +protected: + char _ipAddress[17]; +// struct sockaddr_in _remoteHost; + +}; +} +#endif
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Socket/Socket.cpp Thu Mar 13 03:38:25 2014 +0000 @@ -0,0 +1,51 @@ +/* Copyright (C) 2012 mbed.org, MIT License + * + * Permission is hereby granted, free of charge, to any person obtaining a copy of this software + * and associated documentation files (the "Software"), to deal in the Software without restriction, + * including without limitation the rights to use, copy, modify, merge, publish, distribute, + * sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all copies or + * substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING + * BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND + * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, + * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + */ +#include "Socket.h" +#include <cstring> + +using namespace murata_wifi; + +Socket::Socket() +{ + +} + +Socket::~Socket() { +// close(); //Don't want to leak +} + +int Socket::set_option(int level, int optname, const void *optval, socklen_t optlen) { + return 0; +} + +int Socket::get_option(int level, int optname, void *optval, socklen_t *optlen) { + return 0; +} + +int Socket::close(bool shutdown) +{ + + return 0; +} + +#if 0 +int Socket::select(struct timeval *timeout, bool read, bool write) +{ + return 0; +} +#endif \ No newline at end of file
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Socket/Socket.h Thu Mar 13 03:38:25 2014 +0000 @@ -0,0 +1,77 @@ +/* Copyright (C) 2012 mbed.org, MIT License + * + * Permission is hereby granted, free of charge, to any person obtaining a copy of this software + * and associated documentation files (the "Software"), to deal in the Software without restriction, + * including without limitation the rights to use, copy, modify, merge, publish, distribute, + * sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all copies or + * substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING + * BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND + * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, + * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + */ +#ifndef SOCKET_H_ +#define SOCKET_H_ + +#include "YDwifi.h" + +typedef unsigned long socklen_t; + +namespace murata_wifi +{ + +/** Socket file descriptor and select wrapper + */ +class Socket { +public: + /** Socket + */ + Socket(); + + /** Set socket options + \param level stack level (see: lwip/sockets.h) + \param optname option ID + \param optval option value + \param socklen_t length of the option value + \return 0 on success, -1 on failure + */ + int set_option(int level, int optname, const void *optval, socklen_t optlen); + + /** Get socket options + \param level stack level (see: lwip/sockets.h) + \param optname option ID + \param optval buffer pointer where to write the option value + \param socklen_t length of the option value + \return 0 on success, -1 on failure + */ + int get_option(int level, int optname, void *optval, socklen_t *optlen); + + /** Close the socket + \param shutdown free the left-over data in message queues + */ + int close(bool shutdown=true); + + ~Socket(); + +protected: +#if 0 + bool _blocking; + int _timeout; + GSwifi * _wifi; + + bool _server; + int _cid; + int _port; +#endif + +private: +// int select(struct timeval *timeout, bool read, bool write); +}; +} + +#endif /* SOCKET_H_ */
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Socket/TCPSocketConnection.cpp Thu Mar 13 03:38:25 2014 +0000 @@ -0,0 +1,48 @@ +/* Copyright (C) 2012 mbed.org, MIT License + * + * Permission is hereby granted, free of charge, to any person obtaining a copy of this software + * and associated documentation files (the "Software"), to deal in the Software without restriction, + * including without limitation the rights to use, copy, modify, merge, publish, distribute, + * sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all copies or + * substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING + * BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND + * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, + * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + */ +#include "TCPSocketConnection.h" +#include <cstring> + +using namespace murata_wifi; + +TCPSocketConnection::TCPSocketConnection() : + _is_connected(false) { +} + +int TCPSocketConnection::connect(const char* host, const int port) +{ + _is_connected = true; + + return 0; +} + +bool TCPSocketConnection::is_connected(void) +{ + return _is_connected; +} + +int TCPSocketConnection::send(char* data, int length) +{ + return 0; +} + +int TCPSocketConnection::receive(char* data, int length) +{ + return 0; +} +
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Socket/TCPSocketConnection.h Thu Mar 13 03:38:25 2014 +0000 @@ -0,0 +1,69 @@ +/* Copyright (C) 2012 mbed.org, MIT License + * + * Permission is hereby granted, free of charge, to any person obtaining a copy of this software + * and associated documentation files (the "Software"), to deal in the Software without restriction, + * including without limitation the rights to use, copy, modify, merge, publish, distribute, + * sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all copies or + * substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING + * BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND + * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, + * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + */ + +#ifndef TCPSOCKET_H +#define TCPSOCKET_H + +#include "Socket.h" +#include "Endpoint.h" + +namespace murata_wifi +{ + +/** +TCP socket connection +*/ +class TCPSocketConnection : public Socket, public Endpoint { + +public: + /** TCP socket connection + */ + TCPSocketConnection(); + + /** Connects this TCP socket to the server + \param host The host to connect to. It can either be an IP Address or a hostname that will be resolved with DNS. + \param port The host's port to connect to. + \return 0 on success, -1 on failure. + */ + int connect(const char* host, const int port); + + /** Check if the socket is connected + \return true if connected, false otherwise. + */ + bool is_connected(void); + + /** Send data to the remote host. + \param data The buffer to send to the host. + \param length The length of the buffer to send. + \return the number of written bytes on success (>=0) or -1 on failure + */ + int send(char* data, int length); + + /** Receive data from the remote host. + \param data The buffer in which to store the data received from the host. + \param length The maximum length of the buffer. + \return the number of received bytes on success (>=0) or -1 on failure + */ + int receive(char* data, int length); + +private: + bool _is_connected; + +}; +} +#endif
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Socket/TCPSocketServer.cpp Thu Mar 13 03:38:25 2014 +0000 @@ -0,0 +1,41 @@ +/* Copyright (C) 2012 mbed.org, MIT License + * + * Permission is hereby granted, free of charge, to any person obtaining a copy of this software + * and associated documentation files (the "Software"), to deal in the Software without restriction, + * including without limitation the rights to use, copy, modify, merge, publish, distribute, + * sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all copies or + * substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING + * BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND + * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, + * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + */ +#include "TCPSocketServer.h" + +#include <cstring> + +using namespace murata_wifi; + +TCPSocketServer::TCPSocketServer() +{ +} + +int TCPSocketServer::bind(int port) +{ + return 0; +} + +int TCPSocketServer::listen(int max) +{ + return 0; +} + +int TCPSocketServer::accept(TCPSocketConnection& connection) +{ + return 0; +}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Socket/TCPSocketServer.h Thu Mar 13 03:38:25 2014 +0000 @@ -0,0 +1,56 @@ +/* Copyright (C) 2012 mbed.org, MIT License + * + * Permission is hereby granted, free of charge, to any person obtaining a copy of this software + * and associated documentation files (the "Software"), to deal in the Software without restriction, + * including without limitation the rights to use, copy, modify, merge, publish, distribute, + * sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all copies or + * substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING + * BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND + * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, + * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + */ +#ifndef TCPSOCKETSERVER_H +#define TCPSOCKETSERVER_H + +#include "Socket.h" +#include "TCPSocketConnection.h" + +namespace murata_wifi +{ + +/** TCP Server. + */ +class TCPSocketServer : public Socket { + public: + /** Instantiate a TCP Server. + */ + TCPSocketServer(); + + /** Bind a socket to a specific port. + \param port The port to listen for incoming connections on. + \return 0 on success, -1 on failure. + */ + int bind(int port); + + /** Start listening for incoming connections. + \param backlog number of pending connections that can be queued up at any + one time [Default: 1]. + \return 0 on success, -1 on failure. + */ + int listen(int backlog=1); + + /** Accept a new connection. + \param connection A TCPSocketConnection instance that will handle the incoming connection. + \return 0 on success, -1 on failure. + */ + int accept(TCPSocketConnection& connection); +}; +} + +#endif
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Socket/UDPSocket.cpp Thu Mar 13 03:38:25 2014 +0000 @@ -0,0 +1,49 @@ +/* Copyright (C) 2012 mbed.org, MIT License + * + * Permission is hereby granted, free of charge, to any person obtaining a copy of this software + * and associated documentation files (the "Software"), to deal in the Software without restriction, + * including without limitation the rights to use, copy, modify, merge, publish, distribute, + * sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all copies or + * substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING + * BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND + * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, + * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + */ + +#include "Socket/UDPSocket.h" + +#include <cstring> + +using namespace murata_wifi; + +UDPSocket::UDPSocket() { +} + +int UDPSocket::init(void) +{ + return 0; +} + +// Server initialization +int UDPSocket::bind(int port) +{ + return 0; +} + +// -1 if unsuccessful, else number of bytes written +int UDPSocket::sendTo(Endpoint &remote, char *packet, int length) +{ + return 0; +} + +// -1 if unsuccessful, else number of bytes received +int UDPSocket::receiveFrom(Endpoint &remote, char *buffer, int length) +{ + return 0; +}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Socket/UDPSocket.h Thu Mar 13 03:38:25 2014 +0000 @@ -0,0 +1,68 @@ +/* Copyright (C) 2012 mbed.org, MIT License + * + * Permission is hereby granted, free of charge, to any person obtaining a copy of this software + * and associated documentation files (the "Software"), to deal in the Software without restriction, + * including without limitation the rights to use, copy, modify, merge, publish, distribute, + * sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all copies or + * substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING + * BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND + * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, + * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + */ + +#ifndef UDPSOCKET_H +#define UDPSOCKET_H + +#include "Socket.h" +#include "Endpoint.h" + +namespace murata_wifi +{ + +/** +UDP Socket +*/ +class UDPSocket : public Socket { + +public: + /** Instantiate an UDP Socket. + */ + UDPSocket(); + + /** Init the UDP Client Socket without binding it to any specific port + \return 0 on success, -1 on failure. + */ + int init(void); + + /** Bind a UDP Server Socket to a specific port + \param port The port to listen for incoming connections on + \return 0 on success, -1 on failure. + */ + int bind(int port); + + /** Send a packet to a remote endpoint + \param remote The remote endpoint + \param packet The packet to be sent + \param length The length of the packet to be sent + \return the number of written bytes on success (>=0) or -1 on failure + */ + int sendTo(Endpoint &remote, char *packet, int length); + + /** Receive a packet from a remote endpoint + \param remote The remote endpoint + \param buffer The buffer for storing the incoming packet data. If a packet + is too long to fit in the supplied buffer, excess bytes are discarded + \param length The length of the buffer + \return the number of received bytes on success (>=0) or -1 on failure + */ + int receiveFrom(Endpoint &remote, char *buffer, int length); +}; +} + +#endif
--- a/YDwifi/YDwifi.h Thu Mar 13 01:34:56 2014 +0000 +++ b/YDwifi/YDwifi.h Thu Mar 13 03:38:25 2014 +0000 @@ -43,33 +43,6 @@ e_ADHOC = 1 }E_NETWORK_TYPE; - // ----- YDwifi.cpp ----- - /** Constructor - * \param tx mbed pin to use for tx line of Serial interface - * \param rx mbed pin to use for rx line of Serial interface - * \param cts mbed pin to use for cts line of Serial interface - * \param rts mbed pin to use for rts line of Serial interface - * \param reset reset pin of the wifi module - * \param alarm alarm pin of the wifi module - * \param baud baud rate of Serial interface - */ - C_YDwifi (PinName tx, PinName rx, PinName cts, PinName rts, PinName reset, PinName alarm, int baud); - - int initUart(); - - static C_YDwifi * getInstance() { - return mInstance_p; - }; - Thread *mUartRecvThread_p; - - /** Send data to UART - @param len Length of send data - @param data Pointer of send data - @return 0:success/other:fail - */ - int sendUart( unsigned int len, unsigned char *data ); - - protected: /** GEN_FW_VER_GET_REQ Command */ typedef struct @@ -97,13 +70,41 @@ unsigned char ssid[SSID_MAX_LENGTH+1]; }tagWIFI_SCAN_REQ_T; - static C_YDwifi *mInstance_p; - + static C_YDwifi *mInstance_p; + Thread *mUartRecvThread_p; Mutex mUartMutex; DigitalInOut mModuleReset; C_YDwifiUartCommand mUartCommand; RawSerial mUart; + /** Constructor + * \param tx mbed pin to use for tx line of Serial interface + * \param rx mbed pin to use for rx line of Serial interface + * \param cts mbed pin to use for cts line of Serial interface + * \param rts mbed pin to use for rts line of Serial interface + * \param reset reset pin of the wifi module + * \param alarm alarm pin of the wifi module + * \param baud baud rate of Serial interface + */ + C_YDwifi (PinName tx, PinName rx, PinName cts, PinName rts, PinName reset, PinName alarm, int baud); + + /** Initialize UART + */ + int initUart(); + + static C_YDwifi * getInstance() { + return mInstance_p; + }; + + /** Send data to UART + @param len Length of send data + @param data Pointer of send data + @return 0:success/other:fail + */ + int sendUart( unsigned int len, unsigned char *data ); + + /** Receiving thread of UART + */ static void uartRecvThread( void const *args_p ); };