Customized

Dependents:   MurataTypeYD_RPC_Sample

Fork of SNICInterface_mod by Toyomasa Watarai

Committer:
kishino
Date:
Tue Mar 25 01:42:25 2014 +0000
Revision:
12:0254eaccfda2
Child:
14:54378c96d285
Refactoring of the class name

Who changed what in which revision?

UserRevisionLine numberNew contents of line
kishino 12:0254eaccfda2 1 #ifndef _SNIC_WIFIINTERFACE_H_
kishino 12:0254eaccfda2 2 #define _SNIC_WIFIINTERFACE_H_
kishino 12:0254eaccfda2 3
kishino 12:0254eaccfda2 4 #include "SNIC_Core.h"
kishino 12:0254eaccfda2 5
kishino 12:0254eaccfda2 6 namespace murata_wifi
kishino 12:0254eaccfda2 7 {
kishino 12:0254eaccfda2 8
kishino 12:0254eaccfda2 9 /** Wi-Fi status */
kishino 12:0254eaccfda2 10 typedef struct
kishino 12:0254eaccfda2 11 {
kishino 12:0254eaccfda2 12 /** status */
kishino 12:0254eaccfda2 13 E_WIFI_STATUS status;
kishino 12:0254eaccfda2 14 /** Mac address */
kishino 12:0254eaccfda2 15 char mac_address[BSSID_MAC_LENTH];
kishino 12:0254eaccfda2 16 /** SSID */
kishino 12:0254eaccfda2 17 char ssid[SSID_MAX_LENGTH+1];
kishino 12:0254eaccfda2 18 }tagWIFI_STATUS_T;
kishino 12:0254eaccfda2 19
kishino 12:0254eaccfda2 20 /** C_SNIC_WifiInterface class
kishino 12:0254eaccfda2 21 */
kishino 12:0254eaccfda2 22 class C_SNIC_WifiInterface {
kishino 12:0254eaccfda2 23 public:
kishino 12:0254eaccfda2 24 /** Constructor
kishino 12:0254eaccfda2 25 @param tx mbed pin to use for tx line of Serial interface
kishino 12:0254eaccfda2 26 @param rx mbed pin to use for rx line of Serial interface
kishino 12:0254eaccfda2 27 @param cts mbed pin to use for cts line of Serial interface
kishino 12:0254eaccfda2 28 @param rts mbed pin to use for rts line of Serial interface
kishino 12:0254eaccfda2 29 @param reset reset pin of the wifi module
kishino 12:0254eaccfda2 30 @param alarm alarm pin of the wifi module (default: NC)
kishino 12:0254eaccfda2 31 @param baud baud rate of Serial interface (default: 9600)
kishino 12:0254eaccfda2 32 */
kishino 12:0254eaccfda2 33 C_SNIC_WifiInterface(PinName tx, PinName rx, PinName cts, PinName rts, PinName reset, PinName alarm = NC, int baud = 115200);
kishino 12:0254eaccfda2 34
kishino 12:0254eaccfda2 35 /** Initialize the interface.
kishino 12:0254eaccfda2 36 @return 0 on success, a negative number on failure
kishino 12:0254eaccfda2 37 */
kishino 12:0254eaccfda2 38 int init();
kishino 12:0254eaccfda2 39
kishino 12:0254eaccfda2 40 /** Get Firmware version string.
kishino 12:0254eaccfda2 41 @param version_p Pointer of FW version string.(null terminated)[output]
kishino 12:0254eaccfda2 42 @return 0:success/other:fail
kishino 12:0254eaccfda2 43 @note This function is blocked until a returns.
kishino 12:0254eaccfda2 44 When you use it by UI thread, be careful.
kishino 12:0254eaccfda2 45 */
kishino 12:0254eaccfda2 46 int getFWVersion( unsigned char *version_p );
kishino 12:0254eaccfda2 47
kishino 12:0254eaccfda2 48 /** Connect to AP
kishino 12:0254eaccfda2 49 @param ssid_p Wi-Fi SSID(null terminated)
kishino 12:0254eaccfda2 50 @param ssid_len Wi-Fi SSID length
kishino 12:0254eaccfda2 51 @param sec_type Wi-Fi security type.
kishino 12:0254eaccfda2 52 @param sec_key_len Wi-Fi passphrase or security key length
kishino 12:0254eaccfda2 53 @param sec_key_p Wi-Fi passphrase or security key
kishino 12:0254eaccfda2 54 @return 0 on success, a negative number on failure
kishino 12:0254eaccfda2 55 @note This function is blocked until a returns.
kishino 12:0254eaccfda2 56 When you use it by UI thread, be careful.
kishino 12:0254eaccfda2 57 */
kishino 12:0254eaccfda2 58 int connect(const char *ssid_p, unsigned char ssid_len, E_SECURITY sec_type, const char *sec_key_p, unsigned char sec_key_len);
kishino 12:0254eaccfda2 59
kishino 12:0254eaccfda2 60 /** Disconnect from AP
kishino 12:0254eaccfda2 61 @return 0 on success, a negative number on failure
kishino 12:0254eaccfda2 62 @note This function is blocked until a returns.
kishino 12:0254eaccfda2 63 When you use it by UI thread, be careful.
kishino 12:0254eaccfda2 64 */
kishino 12:0254eaccfda2 65 int disconnect();
kishino 12:0254eaccfda2 66
kishino 12:0254eaccfda2 67 /** Scan AP
kishino 12:0254eaccfda2 68 @param ssid_p Wi-Fi SSID(null terminated)
kishino 12:0254eaccfda2 69 If do not specify SSID, set to NULL.
kishino 12:0254eaccfda2 70 @param bssid_p Wi-Fi BSSID(null terminated)
kishino 12:0254eaccfda2 71 If do not specify SSID, set to NULL.
kishino 12:0254eaccfda2 72 @param result_handler_p Pointer of scan result callback function.
kishino 12:0254eaccfda2 73 @return 0 on success, a negative number on failure
kishino 12:0254eaccfda2 74 @note This function is blocked until a returns.
kishino 12:0254eaccfda2 75 When you use it by UI thread, be careful.
kishino 12:0254eaccfda2 76 Scan results will be notified by asynchronous callback function.
kishino 12:0254eaccfda2 77 If there is no continuity data, result_handler_p will be set NULL..
kishino 12:0254eaccfda2 78 */
kishino 12:0254eaccfda2 79 int scan( const char *ssid_p, unsigned char *bssid_p
kishino 12:0254eaccfda2 80 ,void (*result_handler_p)(tagSCAN_RESULT_T *scan_result) );
kishino 12:0254eaccfda2 81
kishino 12:0254eaccfda2 82 /** Wi-Fi Turn on
kishino 12:0254eaccfda2 83 @param country_p Pointer of country code.
kishino 12:0254eaccfda2 84 @return 0 on success, a negative number on failure
kishino 12:0254eaccfda2 85 @note This function is blocked until a returns.
kishino 12:0254eaccfda2 86 When you use it by UI thread, be careful.
kishino 12:0254eaccfda2 87 */
kishino 12:0254eaccfda2 88 int wifi_on( const char *country_p );
kishino 12:0254eaccfda2 89
kishino 12:0254eaccfda2 90 /** Wi-Fi Turn off
kishino 12:0254eaccfda2 91 @return 0 on success, a negative number on failure
kishino 12:0254eaccfda2 92 @note This function is blocked until a returns.
kishino 12:0254eaccfda2 93 When you use it by UI thread, be careful.
kishino 12:0254eaccfda2 94 */
kishino 12:0254eaccfda2 95 int wifi_off();
kishino 12:0254eaccfda2 96
kishino 12:0254eaccfda2 97 /** Get Wi-Fi RSSI
kishino 12:0254eaccfda2 98 @param rssi_p Pointer of RSSI.[output]
kishino 12:0254eaccfda2 99 @return 0 on success, a negative number on failure
kishino 12:0254eaccfda2 100 @note This function is blocked until a returns.
kishino 12:0254eaccfda2 101 When you use it by UI thread, be careful.
kishino 12:0254eaccfda2 102 */
kishino 12:0254eaccfda2 103 int getRssi( signed char *rssi_p );
kishino 12:0254eaccfda2 104
kishino 12:0254eaccfda2 105 /** Get Wi-Fi status
kishino 12:0254eaccfda2 106 @param status_p Pointer of status structure.[output]
kishino 12:0254eaccfda2 107 @return 0 on success, a negative number on failure
kishino 12:0254eaccfda2 108 @note This function is blocked until a returns.
kishino 12:0254eaccfda2 109 When you use it by UI thread, be careful.
kishino 12:0254eaccfda2 110 */
kishino 12:0254eaccfda2 111 int getWifiStatus( tagWIFI_STATUS_T *status_p);
kishino 12:0254eaccfda2 112
kishino 12:0254eaccfda2 113 #if 0
kishino 12:0254eaccfda2 114 /** Get the MAC address of your Ethernet interface
kishino 12:0254eaccfda2 115 * \return a pointer to a string containing the MAC address
kishino 12:0254eaccfda2 116 */
kishino 12:0254eaccfda2 117 char* getMACAddress();
kishino 12:0254eaccfda2 118
kishino 12:0254eaccfda2 119 /** Get the IP address of your Ethernet interface
kishino 12:0254eaccfda2 120 * \return a pointer to a string containing the IP address
kishino 12:0254eaccfda2 121 */
kishino 12:0254eaccfda2 122 char* getIPAddress();
kishino 12:0254eaccfda2 123
kishino 12:0254eaccfda2 124 /** Get the Gateway address of your Ethernet interface
kishino 12:0254eaccfda2 125 * \return a pointer to a string containing the Gateway address
kishino 12:0254eaccfda2 126 */
kishino 12:0254eaccfda2 127 char* getGateway();
kishino 12:0254eaccfda2 128
kishino 12:0254eaccfda2 129 /** Get the Network mask of your Ethernet interface
kishino 12:0254eaccfda2 130 * \return a pointer to a string containing the Network mask
kishino 12:0254eaccfda2 131 */
kishino 12:0254eaccfda2 132 char* getNetworkMask();
kishino 12:0254eaccfda2 133 #endif
kishino 12:0254eaccfda2 134
kishino 12:0254eaccfda2 135 private:
kishino 12:0254eaccfda2 136 C_SNIC_Core *mSNICWifi_p;
kishino 12:0254eaccfda2 137
kishino 12:0254eaccfda2 138 PinName mUART_tx;
kishino 12:0254eaccfda2 139 PinName mUART_rx;
kishino 12:0254eaccfda2 140 PinName mUART_cts;
kishino 12:0254eaccfda2 141 PinName mUART_rts;
kishino 12:0254eaccfda2 142 int mUART_baud;
kishino 12:0254eaccfda2 143 PinName mModuleReset;
kishino 12:0254eaccfda2 144 };
kishino 12:0254eaccfda2 145 }
kishino 12:0254eaccfda2 146 #endif /* _YD_WIFIINTERFACE_H_ */