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
YDwifi/YDwifi.h@6:70f522934032, 2014-03-13 (annotated)
- Committer:
- kishino
- Date:
- Thu Mar 13 10:33:18 2014 +0000
- Revision:
- 6:70f522934032
- Parent:
- 5:ef3befe3edad
Create get status command
Who changed what in which revision?
| User | Revision | Line number | New contents of line |
|---|---|---|---|
| kishino | 0:61c402886fbb | 1 | #ifndef _YD_WIFI_H_ |
| kishino | 0:61c402886fbb | 2 | #define _YD_WIFI_H_ |
| kishino | 0:61c402886fbb | 3 | |
| kishino | 0:61c402886fbb | 4 | #include "mbed.h" |
| kishino | 0:61c402886fbb | 5 | #include "rtos.h" |
| kishino | 0:61c402886fbb | 6 | #include "RawSerial.h" |
| kishino | 2:0ba43344c814 | 7 | |
| kishino | 2:0ba43344c814 | 8 | #include "YDwifiUartCommand.h" |
| kishino | 0:61c402886fbb | 9 | //#include "CBuffer.h" |
| kishino | 0:61c402886fbb | 10 | |
| kishino | 2:0ba43344c814 | 11 | namespace murata_wifi |
| kishino | 2:0ba43344c814 | 12 | { |
| kishino | 2:0ba43344c814 | 13 | |
| kishino | 0:61c402886fbb | 14 | /** C_YDwifi class |
| kishino | 0:61c402886fbb | 15 | */ |
| kishino | 0:61c402886fbb | 16 | class C_YDwifi |
| kishino | 0:61c402886fbb | 17 | { |
| kishino | 0:61c402886fbb | 18 | |
| kishino | 0:61c402886fbb | 19 | public: |
| kishino | 0:61c402886fbb | 20 | /** Wi-Fi security |
| kishino | 0:61c402886fbb | 21 | */ |
| kishino | 0:61c402886fbb | 22 | typedef enum SECURITY { |
| kishino | 3:9f90024d7fb2 | 23 | /** Securiry Open */ |
| kishino | 0:61c402886fbb | 24 | e_SEC_OPEN = 0x00, |
| kishino | 3:9f90024d7fb2 | 25 | /** Securiry WEP */ |
| kishino | 0:61c402886fbb | 26 | e_SEC_WEP = 0x01, |
| kishino | 3:9f90024d7fb2 | 27 | /** Securiry WPA-PSK(TKIP) */ |
| kishino | 0:61c402886fbb | 28 | e_SEC_WPA_TKIP = 0x02, |
| kishino | 3:9f90024d7fb2 | 29 | /** Securiry WPA2-PSK(AES) */ |
| kishino | 0:61c402886fbb | 30 | e_SEC_WPA2_AES = 0x04, |
| kishino | 3:9f90024d7fb2 | 31 | /** Securiry WPA2-PSK(TKIP/AES) */ |
| kishino | 0:61c402886fbb | 32 | e_SEC_WPA2_MIXED = 0x06, |
| kishino | 3:9f90024d7fb2 | 33 | /** Securiry WPA-PSK(AES) */ |
| kishino | 0:61c402886fbb | 34 | e_SEC_WPA_AES = 0x07 |
| kishino | 0:61c402886fbb | 35 | }E_SECURITY; |
| kishino | 0:61c402886fbb | 36 | |
| kishino | 3:9f90024d7fb2 | 37 | /** Wi-Fi Network type |
| kishino | 3:9f90024d7fb2 | 38 | */ |
| kishino | 3:9f90024d7fb2 | 39 | typedef enum NETWORK_TYPE { |
| kishino | 3:9f90024d7fb2 | 40 | /** Infrastructure */ |
| kishino | 3:9f90024d7fb2 | 41 | e_INFRA = 0, |
| kishino | 3:9f90024d7fb2 | 42 | /** Adhoc */ |
| kishino | 3:9f90024d7fb2 | 43 | e_ADHOC = 1 |
| kishino | 3:9f90024d7fb2 | 44 | }E_NETWORK_TYPE; |
| kishino | 3:9f90024d7fb2 | 45 | |
| kishino | 6:70f522934032 | 46 | /** Wi-Fi status |
| kishino | 6:70f522934032 | 47 | */ |
| kishino | 6:70f522934032 | 48 | typedef enum WIFI_STATUS { |
| kishino | 6:70f522934032 | 49 | /** Wi-Fi OFF */ |
| kishino | 6:70f522934032 | 50 | e_STATUS_OFF = 0, |
| kishino | 6:70f522934032 | 51 | /** No network */ |
| kishino | 6:70f522934032 | 52 | e_NO_NETWORK, |
| kishino | 6:70f522934032 | 53 | /** Connected to AP (STA mode) */ |
| kishino | 6:70f522934032 | 54 | e_STA_JOINED, |
| kishino | 6:70f522934032 | 55 | /** Started on AP mode */ |
| kishino | 6:70f522934032 | 56 | e_AP_STARTED |
| kishino | 6:70f522934032 | 57 | }E_WIFI_STATUS; |
| kishino | 6:70f522934032 | 58 | |
| kishino | 0:61c402886fbb | 59 | protected: |
| kishino | 2:0ba43344c814 | 60 | /** GEN_FW_VER_GET_REQ Command */ |
| kishino | 2:0ba43344c814 | 61 | typedef struct |
| kishino | 2:0ba43344c814 | 62 | { |
| kishino | 2:0ba43344c814 | 63 | unsigned char cmd_sid; |
| kishino | 2:0ba43344c814 | 64 | unsigned char seq; |
| kishino | 2:0ba43344c814 | 65 | }tagGEN_FW_VER_GET_REQ_T; |
| kishino | 2:0ba43344c814 | 66 | |
| kishino | 5:ef3befe3edad | 67 | /** WIFI_ON_REQ Command */ |
| kishino | 5:ef3befe3edad | 68 | typedef struct |
| kishino | 5:ef3befe3edad | 69 | { |
| kishino | 5:ef3befe3edad | 70 | unsigned char cmd_sid; |
| kishino | 5:ef3befe3edad | 71 | unsigned char seq; |
| kishino | 5:ef3befe3edad | 72 | char country[COUNTRYC_CODE_LENTH]; |
| kishino | 5:ef3befe3edad | 73 | }tagWIFI_ON_REQ_T; |
| kishino | 5:ef3befe3edad | 74 | |
| kishino | 5:ef3befe3edad | 75 | /** WIFI_OFF_REQ Command */ |
| kishino | 5:ef3befe3edad | 76 | typedef struct |
| kishino | 5:ef3befe3edad | 77 | { |
| kishino | 5:ef3befe3edad | 78 | unsigned char cmd_sid; |
| kishino | 5:ef3befe3edad | 79 | unsigned char seq; |
| kishino | 5:ef3befe3edad | 80 | }tagWIFI_OFF_REQ_T; |
| kishino | 5:ef3befe3edad | 81 | |
| kishino | 3:9f90024d7fb2 | 82 | /** WIFI_DISCONNECT_REQ Command */ |
| kishino | 3:9f90024d7fb2 | 83 | typedef struct |
| kishino | 3:9f90024d7fb2 | 84 | { |
| kishino | 3:9f90024d7fb2 | 85 | unsigned char cmd_sid; |
| kishino | 3:9f90024d7fb2 | 86 | unsigned char seq; |
| kishino | 3:9f90024d7fb2 | 87 | }tagWIFI_DISCONNECT_REQ_T; |
| kishino | 3:9f90024d7fb2 | 88 | |
| kishino | 5:ef3befe3edad | 89 | /** WIFI_GET_STA_RSSI_REQ Command */ |
| kishino | 5:ef3befe3edad | 90 | typedef struct |
| kishino | 5:ef3befe3edad | 91 | { |
| kishino | 5:ef3befe3edad | 92 | unsigned char cmd_sid; |
| kishino | 5:ef3befe3edad | 93 | unsigned char seq; |
| kishino | 5:ef3befe3edad | 94 | }tagWIFI_GET_STA_RSSI_REQ_T; |
| kishino | 5:ef3befe3edad | 95 | |
| kishino | 6:70f522934032 | 96 | /** WIFI_GET_STATUS_REQ Command */ |
| kishino | 6:70f522934032 | 97 | typedef struct |
| kishino | 6:70f522934032 | 98 | { |
| kishino | 6:70f522934032 | 99 | unsigned char cmd_sid; |
| kishino | 6:70f522934032 | 100 | unsigned char seq; |
| kishino | 6:70f522934032 | 101 | unsigned char interface; |
| kishino | 6:70f522934032 | 102 | }tagWIFI_GET_STATUS_REQ_T; |
| kishino | 6:70f522934032 | 103 | |
| kishino | 3:9f90024d7fb2 | 104 | /** WIFI_SCAN_REQ Command */ |
| kishino | 3:9f90024d7fb2 | 105 | typedef struct |
| kishino | 3:9f90024d7fb2 | 106 | { |
| kishino | 3:9f90024d7fb2 | 107 | unsigned char cmd_sid; |
| kishino | 3:9f90024d7fb2 | 108 | unsigned char seq; |
| kishino | 3:9f90024d7fb2 | 109 | unsigned char scan_type; |
| kishino | 3:9f90024d7fb2 | 110 | unsigned char bss_type; |
| kishino | 3:9f90024d7fb2 | 111 | unsigned char bssid[BSSID_MAC_LENTH]; |
| kishino | 3:9f90024d7fb2 | 112 | unsigned char chan_list; |
| kishino | 3:9f90024d7fb2 | 113 | unsigned char ssid[SSID_MAX_LENGTH+1]; |
| kishino | 3:9f90024d7fb2 | 114 | }tagWIFI_SCAN_REQ_T; |
| kishino | 3:9f90024d7fb2 | 115 | |
| kishino | 4:99cc93fe7d88 | 116 | static C_YDwifi *mInstance_p; |
| kishino | 4:99cc93fe7d88 | 117 | Thread *mUartRecvThread_p; |
| kishino | 2:0ba43344c814 | 118 | Mutex mUartMutex; |
| kishino | 6:70f522934032 | 119 | // DigitalInOut mModuleReset; |
| kishino | 2:0ba43344c814 | 120 | C_YDwifiUartCommand mUartCommand; |
| kishino | 2:0ba43344c814 | 121 | RawSerial mUart; |
| kishino | 2:0ba43344c814 | 122 | |
| kishino | 4:99cc93fe7d88 | 123 | /** Constructor |
| kishino | 4:99cc93fe7d88 | 124 | * \param tx mbed pin to use for tx line of Serial interface |
| kishino | 4:99cc93fe7d88 | 125 | * \param rx mbed pin to use for rx line of Serial interface |
| kishino | 4:99cc93fe7d88 | 126 | * \param cts mbed pin to use for cts line of Serial interface |
| kishino | 4:99cc93fe7d88 | 127 | * \param rts mbed pin to use for rts line of Serial interface |
| kishino | 4:99cc93fe7d88 | 128 | * \param reset reset pin of the wifi module |
| kishino | 4:99cc93fe7d88 | 129 | * \param alarm alarm pin of the wifi module |
| kishino | 4:99cc93fe7d88 | 130 | * \param baud baud rate of Serial interface |
| kishino | 4:99cc93fe7d88 | 131 | */ |
| kishino | 4:99cc93fe7d88 | 132 | C_YDwifi (PinName tx, PinName rx, PinName cts, PinName rts, PinName reset, PinName alarm, int baud); |
| kishino | 4:99cc93fe7d88 | 133 | |
| kishino | 4:99cc93fe7d88 | 134 | /** Initialize UART |
| kishino | 4:99cc93fe7d88 | 135 | */ |
| kishino | 4:99cc93fe7d88 | 136 | int initUart(); |
| kishino | 4:99cc93fe7d88 | 137 | |
| kishino | 4:99cc93fe7d88 | 138 | static C_YDwifi * getInstance() { |
| kishino | 4:99cc93fe7d88 | 139 | return mInstance_p; |
| kishino | 4:99cc93fe7d88 | 140 | }; |
| kishino | 4:99cc93fe7d88 | 141 | |
| kishino | 4:99cc93fe7d88 | 142 | /** Send data to UART |
| kishino | 4:99cc93fe7d88 | 143 | @param len Length of send data |
| kishino | 4:99cc93fe7d88 | 144 | @param data Pointer of send data |
| kishino | 4:99cc93fe7d88 | 145 | @return 0:success/other:fail |
| kishino | 4:99cc93fe7d88 | 146 | */ |
| kishino | 4:99cc93fe7d88 | 147 | int sendUart( unsigned int len, unsigned char *data ); |
| kishino | 4:99cc93fe7d88 | 148 | |
| kishino | 4:99cc93fe7d88 | 149 | /** Receiving thread of UART |
| kishino | 4:99cc93fe7d88 | 150 | */ |
| kishino | 0:61c402886fbb | 151 | static void uartRecvThread( void const *args_p ); |
| kishino | 2:0ba43344c814 | 152 | |
| kishino | 0:61c402886fbb | 153 | }; |
| kishino | 2:0ba43344c814 | 154 | } |
| kishino | 0:61c402886fbb | 155 | |
| kishino | 0:61c402886fbb | 156 | #endif |
muRata

Murata TypeYD