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
SNIC_WifiInterface.h
00001 /* Copyright (C) 2014 Murata Manufacturing Co.,Ltd., MIT License 00002 * muRata, SWITCH SCIENCE Wi-FI module TypeYD-SNIC UART. 00003 * 00004 * Permission is hereby granted, free of charge, to any person obtaining a copy of this software 00005 * and associated documentation files (the "Software"), to deal in the Software without restriction, 00006 * including without limitation the rights to use, copy, modify, merge, publish, distribute, 00007 * sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is 00008 * furnished to do so, subject to the following conditions: 00009 * 00010 * The above copyright notice and this permission notice shall be included in all copies or 00011 * substantial portions of the Software. 00012 * 00013 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING 00014 * BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 00015 * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, 00016 * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 00017 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 00018 */ 00019 #ifndef _SNIC_WIFIINTERFACE_H_ 00020 #define _SNIC_WIFIINTERFACE_H_ 00021 00022 #include "SNIC_Core.h" 00023 #include "MurataObject.h" 00024 00025 /** Wi-Fi status used by getWifiStatus(). */ 00026 typedef struct 00027 { 00028 /** status */ 00029 E_WIFI_STATUS status; 00030 /** Mac address */ 00031 char mac_address[BSSID_MAC_LENTH]; 00032 /** SSID */ 00033 char ssid[SSID_MAX_LENGTH+1]; 00034 }tagWIFI_STATUS_T; 00035 00036 /** Interface class for using SNIC UART. 00037 */ 00038 class C_SNIC_WifiInterface : public C_MurataObject { 00039 00040 public: 00041 /** Default constructor 00042 */ 00043 C_SNIC_WifiInterface() {}; 00044 00045 /** Constructor 00046 @param tx mbed pin to use for tx line of Serial interface 00047 @param rx mbed pin to use for rx line of Serial interface 00048 @param cts mbed pin to use for cts line of Serial interface 00049 @param rts mbed pin to use for rts line of Serial interface 00050 @param reset reset pin of the wifi module 00051 @param alarm alarm pin of the wifi module (default: NC) 00052 @param baud baud rate of Serial interface (default: 115200) 00053 */ 00054 C_SNIC_WifiInterface(PinName tx, PinName rx, PinName cts, PinName rts, PinName reset, PinName alarm = NC, int baud = 115200); 00055 virtual ~C_SNIC_WifiInterface(); 00056 00057 /** Create instance. 00058 */ 00059 void create(PinName tx, PinName rx, PinName cts, PinName rts, PinName reset, PinName alarm = NC, int baud = 115200); 00060 00061 /** Initialize the interface. 00062 @return 0 on success, a negative number on failure 00063 */ 00064 int init(); 00065 00066 /** Get Firmware version string. 00067 @param version_p Pointer of FW version string.(null terminated)[output] 00068 @return 0:success/other:fail 00069 @note This function is blocked until a returns. 00070 When you use it by UI thread, be careful. 00071 */ 00072 int getFWVersion( unsigned char *version_p ); 00073 00074 /** Connect to AP 00075 @param ssid_p Wi-Fi SSID(null terminated) 00076 @param ssid_len Wi-Fi SSID length 00077 @param sec_type Wi-Fi security type. 00078 @param sec_key_len Wi-Fi passphrase or security key length 00079 @param sec_key_p Wi-Fi passphrase or security key 00080 @return 0 on success, a negative number on failure 00081 @note This function is blocked until a returns. 00082 When you use it by UI thread, be careful. 00083 */ 00084 int connect(const char *ssid_p, unsigned char ssid_len, E_SECURITY sec_type, const char *sec_key_p, unsigned char sec_key_len); 00085 00086 /** Disconnect from AP 00087 @return 0 on success, a negative number on failure 00088 @note This function is blocked until a returns. 00089 When you use it by UI thread, be careful. 00090 */ 00091 int disconnect(); 00092 00093 /** Scan AP 00094 @param ssid_p Wi-Fi SSID(null terminated) 00095 If do not specify SSID, set to NULL. 00096 @param bssid_p Wi-Fi BSSID(null terminated) 00097 If do not specify SSID, set to NULL. 00098 @param result_handler_p Pointer of scan result callback function. 00099 @return 0 on success, a negative number on failure 00100 @note This function is blocked until a returns. 00101 When you use it by UI thread, be careful. 00102 Scan results will be notified by asynchronous callback function. 00103 If there is no continuity data, scan_result will be set NULL.. 00104 */ 00105 int scan( const char *ssid_p, unsigned char *bssid_p 00106 ,void (*result_handler_p)(tagSCAN_RESULT_T *scan_result) ); 00107 00108 /** Wi-Fi Turn on 00109 @param country_p Pointer of country code. 00110 @return 0 on success, a negative number on failure 00111 @note This function is blocked until a returns. 00112 When you use it by UI thread, be careful. 00113 */ 00114 int wifi_on( const char *country_p ); 00115 00116 /** Wi-Fi Turn off 00117 @return 0 on success, a negative number on failure 00118 @note This function is blocked until a returns. 00119 When you use it by UI thread, be careful. 00120 */ 00121 int wifi_off(); 00122 00123 /** Get Wi-Fi RSSI 00124 @param rssi_p Pointer of RSSI.[output] 00125 @return 0 on success, a negative number on failure 00126 @note This function is blocked until a returns. 00127 When you use it by UI thread, be careful. 00128 */ 00129 int getRssi( signed char *rssi_p ); 00130 00131 /** Get Wi-Fi status 00132 @param status_p Pointer of status structure.[output] 00133 @return 0 on success, a negative number on failure 00134 @note This function is blocked until a returns. 00135 When you use it by UI thread, be careful. 00136 */ 00137 int getWifiStatus( tagWIFI_STATUS_T *status_p); 00138 00139 /** Set IP configuration 00140 @param is_DHCP true:DHCP false:static IP. 00141 @param ip_p Pointer of strings of IP address.(null terminate). 00142 @param mask_p Pointer of strings of Netmask.(null terminate). 00143 @param gateway_p Pointer of strings of gateway address.(null terminate). 00144 @return 0 on success, a negative number on failure 00145 @note This function is blocked until a returns. 00146 When you use it by UI thread, be careful. 00147 */ 00148 int setIPConfig( bool is_DHCP, const char *ip_p=NULL, const char *mask_p=NULL, const char *gateway_p=NULL ); 00149 00150 /** Get the IP address of your SNIC interface 00151 * \return a pointer to a string containing the IP address 00152 */ 00153 static char* getIPAddress(); 00154 00155 private: 00156 PinName mUART_tx; 00157 PinName mUART_rx; 00158 PinName mUART_cts; 00159 PinName mUART_rts; 00160 int mUART_baud; 00161 PinName mModuleReset; 00162 }; 00163 #endif /* _YD_WIFIINTERFACE_H_ */
Generated on Thu Jul 14 2022 10:07:54 by 1.7.2