This is GR_PEACH_WlanBP3595 class library. The base library is EthernetInterface.
Dependents: GR-PEACH_WlanBP3595AP GR-PEACH_WlanBP3595STA
GR_PEACH_WlanBP3595.h@0:41941ba775eb, 2016-05-24 (annotated)
- Committer:
- tousaki
- Date:
- Tue May 24 10:17:15 2016 +0000
- Revision:
- 0:41941ba775eb
Created 1st version.
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
tousaki | 0:41941ba775eb | 1 | /* GR_PEACH_WlanBP3595.h */ |
tousaki | 0:41941ba775eb | 2 | /* Copyright (C) 2016 Grape Systems, Inc. */ |
tousaki | 0:41941ba775eb | 3 | /* The base file is EthernetInterface.h. */ |
tousaki | 0:41941ba775eb | 4 | |
tousaki | 0:41941ba775eb | 5 | /* EthernetInterface.h */ |
tousaki | 0:41941ba775eb | 6 | /* Copyright (C) 2012 mbed.org, MIT License |
tousaki | 0:41941ba775eb | 7 | * |
tousaki | 0:41941ba775eb | 8 | * Permission is hereby granted, free of charge, to any person obtaining a copy of this software |
tousaki | 0:41941ba775eb | 9 | * and associated documentation files (the "Software"), to deal in the Software without restriction, |
tousaki | 0:41941ba775eb | 10 | * including without limitation the rights to use, copy, modify, merge, publish, distribute, |
tousaki | 0:41941ba775eb | 11 | * sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is |
tousaki | 0:41941ba775eb | 12 | * furnished to do so, subject to the following conditions: |
tousaki | 0:41941ba775eb | 13 | * |
tousaki | 0:41941ba775eb | 14 | * The above copyright notice and this permission notice shall be included in all copies or |
tousaki | 0:41941ba775eb | 15 | * substantial portions of the Software. |
tousaki | 0:41941ba775eb | 16 | * |
tousaki | 0:41941ba775eb | 17 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING |
tousaki | 0:41941ba775eb | 18 | * BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND |
tousaki | 0:41941ba775eb | 19 | * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, |
tousaki | 0:41941ba775eb | 20 | * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, |
tousaki | 0:41941ba775eb | 21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. |
tousaki | 0:41941ba775eb | 22 | */ |
tousaki | 0:41941ba775eb | 23 | |
tousaki | 0:41941ba775eb | 24 | #ifndef GR_PEACH_WLANBP3595_H_ |
tousaki | 0:41941ba775eb | 25 | #define GR_PEACH_WLANBP3595_H_ |
tousaki | 0:41941ba775eb | 26 | |
tousaki | 0:41941ba775eb | 27 | #if !defined(TARGET_RZ_A1H) |
tousaki | 0:41941ba775eb | 28 | #error The GR_PEACH_WlanBP3595 is not supported on this target |
tousaki | 0:41941ba775eb | 29 | #endif |
tousaki | 0:41941ba775eb | 30 | |
tousaki | 0:41941ba775eb | 31 | #include "rtos.h" |
tousaki | 0:41941ba775eb | 32 | #include "lwip/netif.h" |
tousaki | 0:41941ba775eb | 33 | |
tousaki | 0:41941ba775eb | 34 | /** Enum of WiFi encryption types |
tousaki | 0:41941ba775eb | 35 | * |
tousaki | 0:41941ba775eb | 36 | * The security type specifies a particular security to use when |
tousaki | 0:41941ba775eb | 37 | * connected to a WiFi network |
tousaki | 0:41941ba775eb | 38 | * |
tousaki | 0:41941ba775eb | 39 | * @enum nsapi_protocol_t |
tousaki | 0:41941ba775eb | 40 | */ |
tousaki | 0:41941ba775eb | 41 | enum nsapi_security_t { |
tousaki | 0:41941ba775eb | 42 | NSAPI_SECURITY_NONE = 0, /*!< open access point */ |
tousaki | 0:41941ba775eb | 43 | NSAPI_SECURITY_WEP, /*!< phrase conforms to WEP */ |
tousaki | 0:41941ba775eb | 44 | NSAPI_SECURITY_WPA, /*!< phrase conforms to WPA */ |
tousaki | 0:41941ba775eb | 45 | NSAPI_SECURITY_WPA2, /*!< phrase conforms to WPA2 */ |
tousaki | 0:41941ba775eb | 46 | }; |
tousaki | 0:41941ba775eb | 47 | |
tousaki | 0:41941ba775eb | 48 | /** Interface using Wlan to connect to an IP-based network |
tousaki | 0:41941ba775eb | 49 | * |
tousaki | 0:41941ba775eb | 50 | */ |
tousaki | 0:41941ba775eb | 51 | class GR_PEACH_WlanBP3595 { |
tousaki | 0:41941ba775eb | 52 | public: |
tousaki | 0:41941ba775eb | 53 | /** Initialize the interface with DHCP. |
tousaki | 0:41941ba775eb | 54 | * Initialize the interface and configure it to use DHCP (no connection at this point). |
tousaki | 0:41941ba775eb | 55 | * @return 0 on success, a negative number on failure |
tousaki | 0:41941ba775eb | 56 | */ |
tousaki | 0:41941ba775eb | 57 | static int init(); //With DHCP |
tousaki | 0:41941ba775eb | 58 | |
tousaki | 0:41941ba775eb | 59 | /** Initialize the interface with a static IP address. |
tousaki | 0:41941ba775eb | 60 | * Initialize the interface and configure it with the following static configuration (no connection at this point). |
tousaki | 0:41941ba775eb | 61 | * @param ip the IP address to use |
tousaki | 0:41941ba775eb | 62 | * @param mask the IP address mask |
tousaki | 0:41941ba775eb | 63 | * @param gateway the gateway to use |
tousaki | 0:41941ba775eb | 64 | * @return 0 on success, a negative number on failure |
tousaki | 0:41941ba775eb | 65 | */ |
tousaki | 0:41941ba775eb | 66 | static int init(const char* ip, const char* mask, const char* gateway); |
tousaki | 0:41941ba775eb | 67 | |
tousaki | 0:41941ba775eb | 68 | /** Connect |
tousaki | 0:41941ba775eb | 69 | * Bring the interface up, start DHCP if needed. |
tousaki | 0:41941ba775eb | 70 | * @param ssid Name of the network to connect to |
tousaki | 0:41941ba775eb | 71 | * @param pass Security passphrase to connect to the network |
tousaki | 0:41941ba775eb | 72 | * @param security Type of encryption to connect with |
tousaki | 0:41941ba775eb | 73 | * @param timeout_ms timeout in ms (default: (15)s). |
tousaki | 0:41941ba775eb | 74 | * @return 0 on success, a negative number on failure |
tousaki | 0:41941ba775eb | 75 | */ |
tousaki | 0:41941ba775eb | 76 | static int connect( |
tousaki | 0:41941ba775eb | 77 | const char *ssid, |
tousaki | 0:41941ba775eb | 78 | const char *pass, |
tousaki | 0:41941ba775eb | 79 | nsapi_security_t security = NSAPI_SECURITY_WPA2, |
tousaki | 0:41941ba775eb | 80 | unsigned int timeout_ms=1800000); |
tousaki | 0:41941ba775eb | 81 | |
tousaki | 0:41941ba775eb | 82 | /** Disconnect |
tousaki | 0:41941ba775eb | 83 | * Bring the interface down |
tousaki | 0:41941ba775eb | 84 | * @return 0 on success, a negative number on failure |
tousaki | 0:41941ba775eb | 85 | */ |
tousaki | 0:41941ba775eb | 86 | static int disconnect(); |
tousaki | 0:41941ba775eb | 87 | |
tousaki | 0:41941ba775eb | 88 | /** Get the MAC address of your Wlan interface |
tousaki | 0:41941ba775eb | 89 | * @return a pointer to a string containing the MAC address |
tousaki | 0:41941ba775eb | 90 | */ |
tousaki | 0:41941ba775eb | 91 | static char* getMACAddress(); |
tousaki | 0:41941ba775eb | 92 | |
tousaki | 0:41941ba775eb | 93 | /** Get the IP address of your Wlan interface |
tousaki | 0:41941ba775eb | 94 | * @return a pointer to a string containing the IP address |
tousaki | 0:41941ba775eb | 95 | */ |
tousaki | 0:41941ba775eb | 96 | static char* getIPAddress(); |
tousaki | 0:41941ba775eb | 97 | |
tousaki | 0:41941ba775eb | 98 | /** Get the Gateway address of your Wlan interface |
tousaki | 0:41941ba775eb | 99 | * @return a pointer to a string containing the Gateway address |
tousaki | 0:41941ba775eb | 100 | */ |
tousaki | 0:41941ba775eb | 101 | static char* getGateway(); |
tousaki | 0:41941ba775eb | 102 | |
tousaki | 0:41941ba775eb | 103 | /** Get the Network mask of your Wlan interface |
tousaki | 0:41941ba775eb | 104 | * @return a pointer to a string containing the Network mask |
tousaki | 0:41941ba775eb | 105 | */ |
tousaki | 0:41941ba775eb | 106 | static char* getNetworkMask(); |
tousaki | 0:41941ba775eb | 107 | |
tousaki | 0:41941ba775eb | 108 | /** Execute WID function |
tousaki | 0:41941ba775eb | 109 | * Please see "WID" of document "Software development specs of BP3595" for the details. "https://developer.mbed.org/teams/Rohm/wiki/Datasheet" |
tousaki | 0:41941ba775eb | 110 | * @param ulFunc A function number |
tousaki | 0:41941ba775eb | 111 | * @param pvParam The data buffer (the parameter) |
tousaki | 0:41941ba775eb | 112 | * @return 0 on success, "The others" on failure |
tousaki | 0:41941ba775eb | 113 | */ |
tousaki | 0:41941ba775eb | 114 | static int WlanIoctl(uint32_t ulFunc, void *pvParam); |
tousaki | 0:41941ba775eb | 115 | |
tousaki | 0:41941ba775eb | 116 | /** Set WLAN Information callback function |
tousaki | 0:41941ba775eb | 117 | * @param fptr WLAN Information callback function |
tousaki | 0:41941ba775eb | 118 | */ |
tousaki | 0:41941ba775eb | 119 | static void setWlanCbFunction(void(*fptr)(uint8_t ucType, uint16_t usWid, uint16_t usSize, uint8_t *pucData)); |
tousaki | 0:41941ba775eb | 120 | |
tousaki | 0:41941ba775eb | 121 | }; |
tousaki | 0:41941ba775eb | 122 | |
tousaki | 0:41941ba775eb | 123 | #include "TCPSocketConnection.h" |
tousaki | 0:41941ba775eb | 124 | #include "TCPSocketServer.h" |
tousaki | 0:41941ba775eb | 125 | |
tousaki | 0:41941ba775eb | 126 | #include "Endpoint.h" |
tousaki | 0:41941ba775eb | 127 | #include "UDPSocket.h" |
tousaki | 0:41941ba775eb | 128 | |
tousaki | 0:41941ba775eb | 129 | #endif /* GR_PEACH_WLANBP3595_H_ */ |