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/YDwifiUartCommand.h@5:ef3befe3edad, 2014-03-13 (annotated)
- Committer:
- kishino
- Date:
- Thu Mar 13 08:44:33 2014 +0000
- Revision:
- 5:ef3befe3edad
- Parent:
- 3:9f90024d7fb2
- Child:
- 7:e88ccbe0225f
Create Wi-Fi turn on command; Create Wi-Fi turn off command; Create get RSSI command
Who changed what in which revision?
| User | Revision | Line number | New contents of line |
|---|---|---|---|
| kishino | 2:0ba43344c814 | 1 | #ifndef _YD_WIFI_UART_COMMAND_H_ |
| kishino | 2:0ba43344c814 | 2 | #define _YD_WIFI_UART_COMMAND_H_ |
| kishino | 2:0ba43344c814 | 3 | #include "mbed.h" |
| kishino | 2:0ba43344c814 | 4 | #include "rtos.h" |
| kishino | 2:0ba43344c814 | 5 | |
| kishino | 2:0ba43344c814 | 6 | namespace murata_wifi |
| kishino | 2:0ba43344c814 | 7 | { |
| kishino | 3:9f90024d7fb2 | 8 | /** Max length of SSID */ |
| kishino | 3:9f90024d7fb2 | 9 | #define SSID_MAX_LENGTH 32 |
| kishino | 3:9f90024d7fb2 | 10 | /** Max length of BSSID */ |
| kishino | 3:9f90024d7fb2 | 11 | #define BSSID_MAC_LENTH 6 |
| kishino | 5:ef3befe3edad | 12 | /** Length of Country code */ |
| kishino | 5:ef3befe3edad | 13 | #define COUNTRYC_CODE_LENTH 2 |
| kishino | 2:0ba43344c814 | 14 | |
| kishino | 2:0ba43344c814 | 15 | /** Wait signal ID of UART command */ |
| kishino | 2:0ba43344c814 | 16 | #define UART_COMMAND_SIGNAL 0x00000001 |
| kishino | 2:0ba43344c814 | 17 | /** Timeout of UART command wait(ms)*/ |
| kishino | 2:0ba43344c814 | 18 | #define UART_COMMAND_WAIT_TIMEOUT 10000 |
| kishino | 2:0ba43344c814 | 19 | |
| kishino | 3:9f90024d7fb2 | 20 | /** Scan result |
| kishino | 3:9f90024d7fb2 | 21 | */ |
| kishino | 3:9f90024d7fb2 | 22 | typedef struct { |
| kishino | 3:9f90024d7fb2 | 23 | /** Channel */ |
| kishino | 3:9f90024d7fb2 | 24 | unsigned char channel; |
| kishino | 3:9f90024d7fb2 | 25 | /** RSSI */ |
| kishino | 3:9f90024d7fb2 | 26 | signed char rssi; |
| kishino | 3:9f90024d7fb2 | 27 | /** Security type */ |
| kishino | 3:9f90024d7fb2 | 28 | unsigned char security; |
| kishino | 3:9f90024d7fb2 | 29 | /** BSSID */ |
| kishino | 3:9f90024d7fb2 | 30 | unsigned char bssid[BSSID_MAC_LENTH]; |
| kishino | 3:9f90024d7fb2 | 31 | /** Network type */ |
| kishino | 3:9f90024d7fb2 | 32 | unsigned char network_type; |
| kishino | 3:9f90024d7fb2 | 33 | /** Max data rate */ |
| kishino | 3:9f90024d7fb2 | 34 | unsigned char max_rate; |
| kishino | 3:9f90024d7fb2 | 35 | /** SSID */ |
| kishino | 3:9f90024d7fb2 | 36 | char ssid[SSID_MAX_LENGTH+1]; |
| kishino | 3:9f90024d7fb2 | 37 | }tagSCAN_RESULT_T; |
| kishino | 3:9f90024d7fb2 | 38 | |
| kishino | 3:9f90024d7fb2 | 39 | /** C_YDwifiUartCommand class |
| kishino | 3:9f90024d7fb2 | 40 | */ |
| kishino | 2:0ba43344c814 | 41 | class C_YDwifiUartCommand |
| kishino | 2:0ba43344c814 | 42 | { |
| kishino | 2:0ba43344c814 | 43 | public: |
| kishino | 2:0ba43344c814 | 44 | /** Set Command ID |
| kishino | 2:0ba43344c814 | 45 | @param cmd_id Command ID |
| kishino | 2:0ba43344c814 | 46 | */ |
| kishino | 2:0ba43344c814 | 47 | void setCommandID( unsigned char cmd_id ); |
| kishino | 2:0ba43344c814 | 48 | |
| kishino | 2:0ba43344c814 | 49 | /** Get Command ID |
| kishino | 2:0ba43344c814 | 50 | @return Command ID |
| kishino | 2:0ba43344c814 | 51 | */ |
| kishino | 2:0ba43344c814 | 52 | unsigned char getCommandID(); |
| kishino | 2:0ba43344c814 | 53 | |
| kishino | 2:0ba43344c814 | 54 | /** Set Command SubID |
| kishino | 2:0ba43344c814 | 55 | @param cmd_sid Command Sub ID |
| kishino | 2:0ba43344c814 | 56 | */ |
| kishino | 2:0ba43344c814 | 57 | void setCommandSID( unsigned char cmd_sid ); |
| kishino | 2:0ba43344c814 | 58 | |
| kishino | 2:0ba43344c814 | 59 | /** Get Command SubID |
| kishino | 2:0ba43344c814 | 60 | @return Command Sub ID |
| kishino | 2:0ba43344c814 | 61 | */ |
| kishino | 2:0ba43344c814 | 62 | unsigned char getCommandSID(); |
| kishino | 2:0ba43344c814 | 63 | |
| kishino | 2:0ba43344c814 | 64 | /** Set Command status |
| kishino | 2:0ba43344c814 | 65 | @param status Command status |
| kishino | 2:0ba43344c814 | 66 | */ |
| kishino | 2:0ba43344c814 | 67 | void setCommandStatus( unsigned char status ); |
| kishino | 2:0ba43344c814 | 68 | |
| kishino | 2:0ba43344c814 | 69 | /** Get Command status |
| kishino | 2:0ba43344c814 | 70 | @return Command status |
| kishino | 2:0ba43344c814 | 71 | */ |
| kishino | 2:0ba43344c814 | 72 | unsigned char getCommandStatus(); |
| kishino | 2:0ba43344c814 | 73 | |
| kishino | 2:0ba43344c814 | 74 | /** Set Response buffer |
| kishino | 2:0ba43344c814 | 75 | @param buf_p Pointer of response buffer |
| kishino | 2:0ba43344c814 | 76 | */ |
| kishino | 2:0ba43344c814 | 77 | void setResponseBuf( unsigned char *buf_p ); |
| kishino | 2:0ba43344c814 | 78 | |
| kishino | 2:0ba43344c814 | 79 | /** Get Response buffer |
| kishino | 2:0ba43344c814 | 80 | @return Pointer of response buffer |
| kishino | 2:0ba43344c814 | 81 | */ |
| kishino | 2:0ba43344c814 | 82 | unsigned char *getResponseBuf(); |
| kishino | 3:9f90024d7fb2 | 83 | |
| kishino | 3:9f90024d7fb2 | 84 | /** Set scan result callback hander |
| kishino | 3:9f90024d7fb2 | 85 | @param handler_p Pointer of callback function |
| kishino | 3:9f90024d7fb2 | 86 | */ |
| kishino | 3:9f90024d7fb2 | 87 | void setScanResultHandler( void (*handler_p)(tagSCAN_RESULT_T *scan_result) ); |
| kishino | 3:9f90024d7fb2 | 88 | |
| kishino | 3:9f90024d7fb2 | 89 | void scanResultIndicate( unsigned char *payload_p, int payload_len ); |
| kishino | 2:0ba43344c814 | 90 | |
| kishino | 2:0ba43344c814 | 91 | /** Checks in the command which is waiting from Command ID and Sub ID. |
| kishino | 2:0ba43344c814 | 92 | @param command_id Command ID |
| kishino | 2:0ba43344c814 | 93 | @param payload_p Command payload |
| kishino | 2:0ba43344c814 | 94 | @return true: Waiting command / false: Not waiting command |
| kishino | 2:0ba43344c814 | 95 | */ |
| kishino | 2:0ba43344c814 | 96 | bool isWaitingCommand( unsigned int command_id, unsigned char *payload_p ); |
| kishino | 2:0ba43344c814 | 97 | |
| kishino | 2:0ba43344c814 | 98 | int wait(); |
| kishino | 2:0ba43344c814 | 99 | |
| kishino | 2:0ba43344c814 | 100 | int signal(); |
| kishino | 2:0ba43344c814 | 101 | |
| kishino | 2:0ba43344c814 | 102 | protected: |
| kishino | 2:0ba43344c814 | 103 | /** Command request thread ID */ |
| kishino | 2:0ba43344c814 | 104 | osThreadId mCommandThreadID; |
| kishino | 2:0ba43344c814 | 105 | /** Command ID */ |
| kishino | 2:0ba43344c814 | 106 | unsigned char mCommandID; |
| kishino | 2:0ba43344c814 | 107 | /** Command SubID */ |
| kishino | 2:0ba43344c814 | 108 | unsigned char mCommandSID; |
| kishino | 2:0ba43344c814 | 109 | /** Status of command response */ |
| kishino | 2:0ba43344c814 | 110 | unsigned char mCommandStatus; |
| kishino | 2:0ba43344c814 | 111 | /** ResponseData of command response */ |
| kishino | 2:0ba43344c814 | 112 | unsigned char *mResponseBuf_p; |
| kishino | 3:9f90024d7fb2 | 113 | /** Scan result handler */ |
| kishino | 3:9f90024d7fb2 | 114 | void (*mScanResultHandler_p)(tagSCAN_RESULT_T *scan_result); |
| kishino | 2:0ba43344c814 | 115 | }; |
| kishino | 2:0ba43344c814 | 116 | |
| kishino | 2:0ba43344c814 | 117 | } |
| kishino | 2:0ba43344c814 | 118 | #endif |
muRata

Murata TypeYD