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@2:0ba43344c814, 2014-03-11 (annotated)
- Committer:
- kishino
- Date:
- Tue Mar 11 10:38:36 2014 +0000
- Revision:
- 2:0ba43344c814
- Parent:
- 0:61c402886fbb
- Child:
- 3:9f90024d7fb2
Created the basic composition of SNIC UART command API.; Created the UART command for getting firmware's version.
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 | 0:61c402886fbb | 23 | e_SEC_OPEN = 0x00, |
| kishino | 0:61c402886fbb | 24 | e_SEC_WEP = 0x01, |
| kishino | 0:61c402886fbb | 25 | e_SEC_WPA_TKIP = 0x02, |
| kishino | 0:61c402886fbb | 26 | e_SEC_WPA2_AES = 0x04, |
| kishino | 0:61c402886fbb | 27 | e_SEC_WPA2_MIXED = 0x06, |
| kishino | 0:61c402886fbb | 28 | e_SEC_WPA_AES = 0x07 |
| kishino | 0:61c402886fbb | 29 | }E_SECURITY; |
| kishino | 0:61c402886fbb | 30 | |
| kishino | 0:61c402886fbb | 31 | // ----- YDwifi.cpp ----- |
| kishino | 0:61c402886fbb | 32 | /** Constructor |
| kishino | 0:61c402886fbb | 33 | * \param tx mbed pin to use for tx line of Serial interface |
| kishino | 0:61c402886fbb | 34 | * \param rx mbed pin to use for rx line of Serial interface |
| kishino | 0:61c402886fbb | 35 | * \param cts mbed pin to use for cts line of Serial interface |
| kishino | 0:61c402886fbb | 36 | * \param rts mbed pin to use for rts line of Serial interface |
| kishino | 0:61c402886fbb | 37 | * \param reset reset pin of the wifi module |
| kishino | 0:61c402886fbb | 38 | * \param alarm alarm pin of the wifi module |
| kishino | 0:61c402886fbb | 39 | * \param baud baud rate of Serial interface |
| kishino | 0:61c402886fbb | 40 | */ |
| kishino | 0:61c402886fbb | 41 | C_YDwifi (PinName tx, PinName rx, PinName cts, PinName rts, PinName reset, PinName alarm, int baud); |
| kishino | 0:61c402886fbb | 42 | |
| kishino | 0:61c402886fbb | 43 | int initUart(); |
| kishino | 0:61c402886fbb | 44 | |
| kishino | 0:61c402886fbb | 45 | static C_YDwifi * getInstance() { |
| kishino | 0:61c402886fbb | 46 | return mInstance_p; |
| kishino | 0:61c402886fbb | 47 | }; |
| kishino | 0:61c402886fbb | 48 | Thread *mUartRecvThread_p; |
| kishino | 0:61c402886fbb | 49 | |
| kishino | 2:0ba43344c814 | 50 | /** Send data to UART |
| kishino | 2:0ba43344c814 | 51 | @param len Length of send data |
| kishino | 2:0ba43344c814 | 52 | @param data Pointer of send data |
| kishino | 2:0ba43344c814 | 53 | @return 0:success/other:fail |
| kishino | 2:0ba43344c814 | 54 | */ |
| kishino | 2:0ba43344c814 | 55 | int sendUart( unsigned int len, unsigned char *data ); |
| kishino | 2:0ba43344c814 | 56 | |
| kishino | 2:0ba43344c814 | 57 | |
| kishino | 0:61c402886fbb | 58 | protected: |
| kishino | 2:0ba43344c814 | 59 | /** GEN_FW_VER_GET_REQ Command */ |
| kishino | 2:0ba43344c814 | 60 | typedef struct |
| kishino | 2:0ba43344c814 | 61 | { |
| kishino | 2:0ba43344c814 | 62 | unsigned char cmd_sid; |
| kishino | 2:0ba43344c814 | 63 | unsigned char seq; |
| kishino | 2:0ba43344c814 | 64 | }tagGEN_FW_VER_GET_REQ_T; |
| kishino | 2:0ba43344c814 | 65 | |
| kishino | 0:61c402886fbb | 66 | static C_YDwifi *mInstance_p; |
| kishino | 0:61c402886fbb | 67 | |
| kishino | 2:0ba43344c814 | 68 | Mutex mUartMutex; |
| kishino | 2:0ba43344c814 | 69 | DigitalInOut mModuleReset; |
| kishino | 2:0ba43344c814 | 70 | C_YDwifiUartCommand mUartCommand; |
| kishino | 2:0ba43344c814 | 71 | RawSerial mUart; |
| kishino | 2:0ba43344c814 | 72 | |
| kishino | 0:61c402886fbb | 73 | static void uartRecvThread( void const *args_p ); |
| kishino | 2:0ba43344c814 | 74 | |
| kishino | 0:61c402886fbb | 75 | }; |
| kishino | 2:0ba43344c814 | 76 | } |
| kishino | 0:61c402886fbb | 77 | |
| kishino | 0:61c402886fbb | 78 | #endif |
muRata

Murata TypeYD