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