This is GR_PEACH_WlanBP3595 class library. The base library is EthernetInterface.

Dependents:   GR-PEACH_WlanBP3595AP GR-PEACH_WlanBP3595STA

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers GR_PEACH_WlanBP3595.h Source File

GR_PEACH_WlanBP3595.h

00001 /* GR_PEACH_WlanBP3595.h */
00002 /* Copyright (C) 2016 Grape Systems, Inc. */
00003 /* The base file is EthernetInterface.h. */
00004 
00005 /* EthernetInterface.h */
00006 /* Copyright (C) 2012 mbed.org, MIT License
00007  *
00008  * Permission is hereby granted, free of charge, to any person obtaining a copy of this software
00009  * and associated documentation files (the "Software"), to deal in the Software without restriction,
00010  * including without limitation the rights to use, copy, modify, merge, publish, distribute,
00011  * sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is
00012  * furnished to do so, subject to the following conditions:
00013  *
00014  * The above copyright notice and this permission notice shall be included in all copies or
00015  * substantial portions of the Software.
00016  *
00017  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING
00018  * BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
00019  * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
00020  * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
00021  * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
00022  */
00023 
00024 #ifndef GR_PEACH_WLANBP3595_H_
00025 #define GR_PEACH_WLANBP3595_H_
00026 
00027 #if !defined(TARGET_RZ_A1H)
00028 #error The GR_PEACH_WlanBP3595 is not supported on this target
00029 #endif
00030 
00031 #include "rtos.h"
00032 #include "lwip/netif.h"
00033 
00034 /** Enum of WiFi encryption types
00035  *
00036  *  The security type specifies a particular security to use when
00037  *  connected to a WiFi network
00038  *
00039  *  @enum nsapi_protocol_t
00040  */
00041 enum nsapi_security_t {
00042     NSAPI_SECURITY_NONE = 0,   /*!< open access point */
00043     NSAPI_SECURITY_WEP,        /*!< phrase conforms to WEP */
00044     NSAPI_SECURITY_WPA,        /*!< phrase conforms to WPA */
00045     NSAPI_SECURITY_WPA2,       /*!< phrase conforms to WPA2 */
00046 };
00047 
00048  /** Interface using Wlan to connect to an IP-based network
00049  *
00050  */
00051 class GR_PEACH_WlanBP3595 {
00052 public:
00053     /** Initialize the interface with DHCP.
00054      * Initialize the interface and configure it to use DHCP (no connection at this point).
00055      * @return 0 on success, a negative number on failure
00056      */
00057     static int init(); //With DHCP
00058 
00059     /** Initialize the interface with a static IP address.
00060      * Initialize the interface and configure it with the following static configuration (no connection at this point).
00061      * @param ip the IP address to use
00062      * @param mask the IP address mask
00063      * @param gateway the gateway to use
00064      * @return 0 on success, a negative number on failure
00065      */
00066     static int init(const char* ip, const char* mask, const char* gateway);
00067 
00068     /** Connect
00069      * Bring the interface up, start DHCP if needed.
00070      * @param ssid Name of the network to connect to
00071      * @param pass Security passphrase to connect to the network
00072      * @param security Type of encryption to connect with
00073      * @param timeout_ms  timeout in ms (default: (15)s).
00074      * @return 0 on success, a negative number on failure
00075      */
00076     static int connect(
00077         const char *ssid,
00078         const char *pass,
00079         nsapi_security_t security = NSAPI_SECURITY_WPA2,
00080         unsigned int timeout_ms=1800000);
00081 
00082     /** Disconnect
00083      * Bring the interface down
00084      * @return 0 on success, a negative number on failure
00085      */
00086     static int disconnect();
00087 
00088     /** Get the MAC address of your Wlan interface
00089      * @return a pointer to a string containing the MAC address
00090      */
00091     static char* getMACAddress();
00092 
00093     /** Get the IP address of your Wlan interface
00094      * @return a pointer to a string containing the IP address
00095      */
00096     static char* getIPAddress();
00097 
00098     /** Get the Gateway address of your Wlan interface
00099      * @return a pointer to a string containing the Gateway address
00100      */
00101     static char* getGateway();
00102 
00103     /** Get the Network mask of your Wlan interface
00104      * @return a pointer to a string containing the Network mask
00105      */
00106     static char* getNetworkMask();
00107 
00108     /** Execute WID function
00109     * Please see "WID" of document "Software development specs of BP3595" for the details. "https://developer.mbed.org/teams/Rohm/wiki/Datasheet"
00110     * @param ulFunc A function number
00111     * @param pvParam The data buffer (the parameter)
00112     * @return 0 on success, "The others" on failure
00113     */
00114     static int WlanIoctl(uint32_t ulFunc, void *pvParam);
00115 
00116     /** Set WLAN Information callback function
00117     * @param fptr WLAN Information callback function
00118     */
00119     static void setWlanCbFunction(void(*fptr)(uint8_t ucType, uint16_t usWid, uint16_t usSize, uint8_t *pucData));
00120 
00121 };
00122 
00123 #include "TCPSocketConnection.h"
00124 #include "TCPSocketServer.h"
00125 
00126 #include "Endpoint.h"
00127 #include "UDPSocket.h"
00128 
00129 #endif /* GR_PEACH_WLANBP3595_H_ */