This library can be used in mbed driver or mbed OS2. So If you want to use WizFi310 on mbed OS5, You have to use another WizFi310 library(wizfi310-driver). That is git repository for wizfi310-driver. - https://github.com/ARMmbed/wizfi310-driver

Dependents:   KT_IoTMakers_WizFi310_Example WizFi310_STATION_HelloWorld WizFi310_DNS_TCP_HelloWorld WizFi310_Ubidots ... more

This library can be used in mbed driver or mbed OS2. So If you want to use WizFi310 on mbed OS5, You have to use another WizFi310 library(wizfi310-driver).

That is git repository for wizfi310-driver. - https://github.com/ARMmbed/wizfi310-driver

Committer:
jehoon
Date:
Wed Oct 05 09:40:30 2016 +0000
Revision:
0:df571f8f8c03
Child:
1:16e57103a7dd
This is a WizFi310 Library. It supports new mbed5 features including NetworkInterfaceAPI.

Who changed what in which revision?

UserRevisionLine numberNew contents of line
jehoon 0:df571f8f8c03 1 /* WizFi310 implementation of NetworkInterfaceAPI
jehoon 0:df571f8f8c03 2 * Copyright (c) 2015 ARM Limited
jehoon 0:df571f8f8c03 3 *
jehoon 0:df571f8f8c03 4 * Licensed under the Apache License, Version 2.0 (the "License");
jehoon 0:df571f8f8c03 5 * you may not use this file except in compliance with the License.
jehoon 0:df571f8f8c03 6 * You may obtain a copy of the License at
jehoon 0:df571f8f8c03 7 *
jehoon 0:df571f8f8c03 8 * http://www.apache.org/licenses/LICENSE-2.0
jehoon 0:df571f8f8c03 9 *
jehoon 0:df571f8f8c03 10 * Unless required by applicable law or agreed to in writing, software
jehoon 0:df571f8f8c03 11 * distributed under the License is distributed on an "AS IS" BASIS,
jehoon 0:df571f8f8c03 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
jehoon 0:df571f8f8c03 13 * See the License for the specific language governing permissions and
jehoon 0:df571f8f8c03 14 * limitations under the License.
jehoon 0:df571f8f8c03 15 */
jehoon 0:df571f8f8c03 16
jehoon 0:df571f8f8c03 17 #ifndef WIZFI250_INTERFACE_H
jehoon 0:df571f8f8c03 18 #define WIZFI250_INTERFACE_H
jehoon 0:df571f8f8c03 19
jehoon 0:df571f8f8c03 20 #include "WiFiInterface.h"
jehoon 0:df571f8f8c03 21 #include "WizFi310.h"
jehoon 0:df571f8f8c03 22
jehoon 0:df571f8f8c03 23 #define WIZFI310_SOCKET_COUNT 8
jehoon 0:df571f8f8c03 24
jehoon 0:df571f8f8c03 25 /** WizFi310Interface class
jehoon 0:df571f8f8c03 26 * Implementation of the NetworkStack for the WizFi310
jehoon 0:df571f8f8c03 27 */
jehoon 0:df571f8f8c03 28 class WizFi310Interface : public NetworkStack, public WiFiInterface
jehoon 0:df571f8f8c03 29 {
jehoon 0:df571f8f8c03 30 public:
jehoon 0:df571f8f8c03 31 WizFi310Interface(PinName tx, PinName rx, PinName cts, PinName rts, PinName reset, PinName alarm, int baud=115200 );
jehoon 0:df571f8f8c03 32
jehoon 0:df571f8f8c03 33 virtual int connect(
jehoon 0:df571f8f8c03 34 const char *ssid,
jehoon 0:df571f8f8c03 35 const char *pass,
jehoon 0:df571f8f8c03 36 nsapi_security_t security);
jehoon 0:df571f8f8c03 37
jehoon 0:df571f8f8c03 38 /** Stop the interface
jehoon 0:df571f8f8c03 39 * @return 0 on success, negative on failure
jehoon 0:df571f8f8c03 40 */
jehoon 0:df571f8f8c03 41 virtual int disconnect();
jehoon 0:df571f8f8c03 42
jehoon 0:df571f8f8c03 43 /** Get the internally stored IP address
jehoon 0:df571f8f8c03 44 * @return IP address of the interface or null if not yet connected
jehoon 0:df571f8f8c03 45 */
jehoon 0:df571f8f8c03 46 virtual const char *get_ip_address();
jehoon 0:df571f8f8c03 47
jehoon 0:df571f8f8c03 48 /** Get the internally stored MAC address
jehoon 0:df571f8f8c03 49 * @return MAC address of the interface
jehoon 0:df571f8f8c03 50 */
jehoon 0:df571f8f8c03 51 virtual const char *get_mac_address();
jehoon 0:df571f8f8c03 52
jehoon 0:df571f8f8c03 53 protected:
jehoon 0:df571f8f8c03 54 /** Open a socket
jehoon 0:df571f8f8c03 55 * @param handle Handle in which to store new socket
jehoon 0:df571f8f8c03 56 * @param proto Type of socket to open, NSAPI_TCP or NSAPI_UDP
jehoon 0:df571f8f8c03 57 * @return 0 on success, negative on failure
jehoon 0:df571f8f8c03 58 */
jehoon 0:df571f8f8c03 59 virtual int socket_open(void **handle, nsapi_protocol_t proto);
jehoon 0:df571f8f8c03 60
jehoon 0:df571f8f8c03 61 /** Close the socket
jehoon 0:df571f8f8c03 62 * @param handle Socket handle
jehoon 0:df571f8f8c03 63 * @return 0 on success, negative on failure
jehoon 0:df571f8f8c03 64 * @note On failure, any memory associated with the socket must still
jehoon 0:df571f8f8c03 65 * be cleaned up
jehoon 0:df571f8f8c03 66 */
jehoon 0:df571f8f8c03 67 virtual int socket_close(void *handle);
jehoon 0:df571f8f8c03 68
jehoon 0:df571f8f8c03 69 /** Bind a server socket to a specific port
jehoon 0:df571f8f8c03 70 * @param handle Socket handle
jehoon 0:df571f8f8c03 71 * @param address Local address to listen for incoming connections on
jehoon 0:df571f8f8c03 72 * @return 0 on success, negative on failure.
jehoon 0:df571f8f8c03 73 */
jehoon 0:df571f8f8c03 74 virtual int socket_bind(void *handle, const SocketAddress &address);
jehoon 0:df571f8f8c03 75
jehoon 0:df571f8f8c03 76 /** Start listening for incoming connections
jehoon 0:df571f8f8c03 77 * @param handle Socket handle
jehoon 0:df571f8f8c03 78 * @param backlog Number of pending connections that can be queued up at any
jehoon 0:df571f8f8c03 79 * one time [Default: 1]
jehoon 0:df571f8f8c03 80 * @return 0 on success, negative on failure
jehoon 0:df571f8f8c03 81 */
jehoon 0:df571f8f8c03 82 virtual int socket_listen(void *handle, int backlog);
jehoon 0:df571f8f8c03 83
jehoon 0:df571f8f8c03 84 /** Connects this TCP socket to the server
jehoon 0:df571f8f8c03 85 * @param handle Socket handle
jehoon 0:df571f8f8c03 86 * @param address SocketAddress to connect to
jehoon 0:df571f8f8c03 87 * @return 0 on success, negative on failure
jehoon 0:df571f8f8c03 88 */
jehoon 0:df571f8f8c03 89 virtual int socket_connect(void *handle, const SocketAddress &address);
jehoon 0:df571f8f8c03 90
jehoon 0:df571f8f8c03 91 /** Accept a new connection.
jehoon 0:df571f8f8c03 92 * @param handle Handle in which to store new socket
jehoon 0:df571f8f8c03 93 * @param server Socket handle to server to accept from
jehoon 0:df571f8f8c03 94 * @return 0 on success, negative on failure
jehoon 0:df571f8f8c03 95 * @note This call is not-blocking, if this call would block, must
jehoon 0:df571f8f8c03 96 * immediately return NSAPI_ERROR_WOULD_WAIT
jehoon 0:df571f8f8c03 97 */
jehoon 0:df571f8f8c03 98 virtual int socket_accept(void **handle, void *server);
jehoon 0:df571f8f8c03 99
jehoon 0:df571f8f8c03 100 /** Send data to the remote host
jehoon 0:df571f8f8c03 101 * @param handle Socket handle
jehoon 0:df571f8f8c03 102 * @param data The buffer to send to the host
jehoon 0:df571f8f8c03 103 * @param size The length of the buffer to send
jehoon 0:df571f8f8c03 104 * @return Number of written bytes on success, negative on failure
jehoon 0:df571f8f8c03 105 * @note This call is not-blocking, if this call would block, must
jehoon 0:df571f8f8c03 106 * immediately return NSAPI_ERROR_WOULD_WAIT
jehoon 0:df571f8f8c03 107 */
jehoon 0:df571f8f8c03 108 virtual int socket_send(void *handle, const void *data, unsigned size);
jehoon 0:df571f8f8c03 109
jehoon 0:df571f8f8c03 110 /** Receive data from the remote host
jehoon 0:df571f8f8c03 111 * @param handle Socket handle
jehoon 0:df571f8f8c03 112 * @param data The buffer in which to store the data received from the host
jehoon 0:df571f8f8c03 113 * @param size The maximum length of the buffer
jehoon 0:df571f8f8c03 114 * @return Number of received bytes on success, negative on failure
jehoon 0:df571f8f8c03 115 * @note This call is not-blocking, if this call would block, must
jehoon 0:df571f8f8c03 116 * immediately return NSAPI_ERROR_WOULD_WAIT
jehoon 0:df571f8f8c03 117 */
jehoon 0:df571f8f8c03 118 virtual int socket_recv(void *handle, void *data, unsigned size);
jehoon 0:df571f8f8c03 119
jehoon 0:df571f8f8c03 120 /** Send a packet to a remote endpoint
jehoon 0:df571f8f8c03 121 * @param handle Socket handle
jehoon 0:df571f8f8c03 122 * @param address The remote SocketAddress
jehoon 0:df571f8f8c03 123 * @param data The packet to be sent
jehoon 0:df571f8f8c03 124 * @param size The length of the packet to be sent
jehoon 0:df571f8f8c03 125 * @return The number of written bytes on success, negative on failure
jehoon 0:df571f8f8c03 126 * @note This call is not-blocking, if this call would block, must
jehoon 0:df571f8f8c03 127 * immediately return NSAPI_ERROR_WOULD_WAIT
jehoon 0:df571f8f8c03 128 */
jehoon 0:df571f8f8c03 129 virtual int socket_sendto(void *handle, const SocketAddress &address, const void *data, unsigned size);
jehoon 0:df571f8f8c03 130
jehoon 0:df571f8f8c03 131 /** Receive a packet from a remote endpoint
jehoon 0:df571f8f8c03 132 * @param handle Socket handle
jehoon 0:df571f8f8c03 133 * @param address Destination for the remote SocketAddress or null
jehoon 0:df571f8f8c03 134 * @param buffer The buffer for storing the incoming packet data
jehoon 0:df571f8f8c03 135 * If a packet is too long to fit in the supplied buffer,
jehoon 0:df571f8f8c03 136 * excess bytes are discarded
jehoon 0:df571f8f8c03 137 * @param size The length of the buffer
jehoon 0:df571f8f8c03 138 * @return The number of received bytes on success, negative on failure
jehoon 0:df571f8f8c03 139 * @note This call is not-blocking, if this call would block, must
jehoon 0:df571f8f8c03 140 * immediately return NSAPI_ERROR_WOULD_WAIT
jehoon 0:df571f8f8c03 141 */
jehoon 0:df571f8f8c03 142 virtual int socket_recvfrom(void *handle, SocketAddress *address, void *buffer, unsigned size);
jehoon 0:df571f8f8c03 143
jehoon 0:df571f8f8c03 144 /** Register a callback on state change of the socket
jehoon 0:df571f8f8c03 145 * @param handle Socket handle
jehoon 0:df571f8f8c03 146 * @param callback Function to call on state change
jehoon 0:df571f8f8c03 147 * @param data Argument to pass to callback
jehoon 0:df571f8f8c03 148 * @note Callback may be called in an interrupt context.
jehoon 0:df571f8f8c03 149 */
jehoon 0:df571f8f8c03 150 virtual void socket_attach(void *handle, void (*callback)(void *), void *data);
jehoon 0:df571f8f8c03 151
jehoon 0:df571f8f8c03 152 private:
jehoon 0:df571f8f8c03 153 WizFi310 _wizfi310;
jehoon 0:df571f8f8c03 154 bool _ids[WIZFI310_SOCKET_COUNT];
jehoon 0:df571f8f8c03 155 };
jehoon 0:df571f8f8c03 156
jehoon 0:df571f8f8c03 157 #endif
jehoon 0:df571f8f8c03 158