Customized SNICInterface
Fork of NySNICInterface by
SNIC/SNIC_UartCommandManager.h@14:54378c96d285, 2014-03-26 (annotated)
- Committer:
- kishino
- Date:
- Wed Mar 26 04:38:12 2014 +0000
- Revision:
- 14:54378c96d285
- Parent:
- 12:0254eaccfda2
Added a comment of copyright.
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_UartCommandManager.h |
kishino | 14:54378c96d285 | 4 | * |
kishino | 14:54378c96d285 | 5 | * Purpose: This module has define of function for management of |
kishino | 14:54378c96d285 | 6 | SNIC UART Command. |
kishino | 14:54378c96d285 | 7 | * |
kishino | 14:54378c96d285 | 8 | * $Author: kishino $ |
kishino | 14:54378c96d285 | 9 | * |
kishino | 14:54378c96d285 | 10 | * $Date: 2014/03/26 $ |
kishino | 14:54378c96d285 | 11 | * |
kishino | 14:54378c96d285 | 12 | * $Revision: 0.0.0.1 $ |
kishino | 14:54378c96d285 | 13 | * ***********************************************************************/ |
kishino | 12:0254eaccfda2 | 14 | #ifndef _SNIC_UART_COMMAND_MANAGER_H_ |
kishino | 12:0254eaccfda2 | 15 | #define _SNIC_UART_COMMAND_MANAGER_H_ |
kishino | 12:0254eaccfda2 | 16 | #include "mbed.h" |
kishino | 12:0254eaccfda2 | 17 | #include "rtos.h" |
kishino | 12:0254eaccfda2 | 18 | |
kishino | 12:0254eaccfda2 | 19 | namespace murata_wifi |
kishino | 12:0254eaccfda2 | 20 | { |
kishino | 12:0254eaccfda2 | 21 | /** Max length of SSID */ |
kishino | 12:0254eaccfda2 | 22 | #define SSID_MAX_LENGTH 32 |
kishino | 12:0254eaccfda2 | 23 | /** Max length of BSSID */ |
kishino | 12:0254eaccfda2 | 24 | #define BSSID_MAC_LENTH 6 |
kishino | 12:0254eaccfda2 | 25 | /** Length of Country code */ |
kishino | 12:0254eaccfda2 | 26 | #define COUNTRYC_CODE_LENTH 2 |
kishino | 12:0254eaccfda2 | 27 | |
kishino | 12:0254eaccfda2 | 28 | /** Wait signal ID of UART command */ |
kishino | 12:0254eaccfda2 | 29 | #define UART_COMMAND_SIGNAL 0x00000001 |
kishino | 12:0254eaccfda2 | 30 | /** Timeout of UART command wait(ms)*/ |
kishino | 12:0254eaccfda2 | 31 | #define UART_COMMAND_WAIT_TIMEOUT 10000 |
kishino | 12:0254eaccfda2 | 32 | |
kishino | 12:0254eaccfda2 | 33 | /** Scan result |
kishino | 12:0254eaccfda2 | 34 | */ |
kishino | 12:0254eaccfda2 | 35 | typedef struct { |
kishino | 12:0254eaccfda2 | 36 | bool is_complete; |
kishino | 12:0254eaccfda2 | 37 | /** Channel */ |
kishino | 12:0254eaccfda2 | 38 | unsigned char channel; |
kishino | 12:0254eaccfda2 | 39 | /** RSSI */ |
kishino | 12:0254eaccfda2 | 40 | signed char rssi; |
kishino | 12:0254eaccfda2 | 41 | /** Security type */ |
kishino | 12:0254eaccfda2 | 42 | unsigned char security; |
kishino | 12:0254eaccfda2 | 43 | /** BSSID */ |
kishino | 12:0254eaccfda2 | 44 | unsigned char bssid[BSSID_MAC_LENTH]; |
kishino | 12:0254eaccfda2 | 45 | /** Network type */ |
kishino | 12:0254eaccfda2 | 46 | unsigned char network_type; |
kishino | 12:0254eaccfda2 | 47 | /** Max data rate */ |
kishino | 12:0254eaccfda2 | 48 | unsigned char max_rate; |
kishino | 12:0254eaccfda2 | 49 | /** SSID */ |
kishino | 12:0254eaccfda2 | 50 | char ssid[SSID_MAX_LENGTH+1]; |
kishino | 12:0254eaccfda2 | 51 | }tagSCAN_RESULT_T; |
kishino | 12:0254eaccfda2 | 52 | |
kishino | 12:0254eaccfda2 | 53 | /** C_SNIC_UartCommandManager class |
kishino | 12:0254eaccfda2 | 54 | */ |
kishino | 12:0254eaccfda2 | 55 | class C_SNIC_UartCommandManager |
kishino | 12:0254eaccfda2 | 56 | { |
kishino | 12:0254eaccfda2 | 57 | public: |
kishino | 12:0254eaccfda2 | 58 | /** Set Command ID |
kishino | 12:0254eaccfda2 | 59 | @param cmd_id Command ID |
kishino | 12:0254eaccfda2 | 60 | */ |
kishino | 12:0254eaccfda2 | 61 | void setCommandID( unsigned char cmd_id ); |
kishino | 12:0254eaccfda2 | 62 | |
kishino | 12:0254eaccfda2 | 63 | /** Get Command ID |
kishino | 12:0254eaccfda2 | 64 | @return Command ID |
kishino | 12:0254eaccfda2 | 65 | */ |
kishino | 12:0254eaccfda2 | 66 | unsigned char getCommandID(); |
kishino | 12:0254eaccfda2 | 67 | |
kishino | 12:0254eaccfda2 | 68 | /** Set Command SubID |
kishino | 12:0254eaccfda2 | 69 | @param cmd_sid Command Sub ID |
kishino | 12:0254eaccfda2 | 70 | */ |
kishino | 12:0254eaccfda2 | 71 | void setCommandSID( unsigned char cmd_sid ); |
kishino | 12:0254eaccfda2 | 72 | |
kishino | 12:0254eaccfda2 | 73 | /** Get Command SubID |
kishino | 12:0254eaccfda2 | 74 | @return Command Sub ID |
kishino | 12:0254eaccfda2 | 75 | */ |
kishino | 12:0254eaccfda2 | 76 | unsigned char getCommandSID(); |
kishino | 12:0254eaccfda2 | 77 | |
kishino | 12:0254eaccfda2 | 78 | /** Set Command status |
kishino | 12:0254eaccfda2 | 79 | @param status Command status |
kishino | 12:0254eaccfda2 | 80 | */ |
kishino | 12:0254eaccfda2 | 81 | void setCommandStatus( unsigned char status ); |
kishino | 12:0254eaccfda2 | 82 | |
kishino | 12:0254eaccfda2 | 83 | /** Get Command status |
kishino | 12:0254eaccfda2 | 84 | @return Command status |
kishino | 12:0254eaccfda2 | 85 | */ |
kishino | 12:0254eaccfda2 | 86 | unsigned char getCommandStatus(); |
kishino | 12:0254eaccfda2 | 87 | |
kishino | 12:0254eaccfda2 | 88 | /** Set Response buffer |
kishino | 12:0254eaccfda2 | 89 | @param buf_p Pointer of response buffer |
kishino | 12:0254eaccfda2 | 90 | */ |
kishino | 12:0254eaccfda2 | 91 | void setResponseBuf( unsigned char *buf_p ); |
kishino | 12:0254eaccfda2 | 92 | |
kishino | 12:0254eaccfda2 | 93 | /** Get Response buffer |
kishino | 12:0254eaccfda2 | 94 | @return Pointer of response buffer |
kishino | 12:0254eaccfda2 | 95 | */ |
kishino | 12:0254eaccfda2 | 96 | unsigned char *getResponseBuf(); |
kishino | 12:0254eaccfda2 | 97 | |
kishino | 12:0254eaccfda2 | 98 | /** Set scan result callback hander |
kishino | 12:0254eaccfda2 | 99 | @param handler_p Pointer of callback function |
kishino | 12:0254eaccfda2 | 100 | */ |
kishino | 12:0254eaccfda2 | 101 | void setScanResultHandler( void (*handler_p)(tagSCAN_RESULT_T *scan_result) ); |
kishino | 12:0254eaccfda2 | 102 | |
kishino | 12:0254eaccfda2 | 103 | void bufferredPacket( unsigned char *payload_p, int payload_len ); |
kishino | 12:0254eaccfda2 | 104 | |
kishino | 12:0254eaccfda2 | 105 | void scanResultIndicate( unsigned char *payload_p, int payload_len ); |
kishino | 12:0254eaccfda2 | 106 | |
kishino | 12:0254eaccfda2 | 107 | /** Checks in the command which is waiting from Command ID and Sub ID. |
kishino | 12:0254eaccfda2 | 108 | @param command_id Command ID |
kishino | 12:0254eaccfda2 | 109 | @param payload_p Command payload |
kishino | 12:0254eaccfda2 | 110 | @return true: Waiting command / false: Not waiting command |
kishino | 12:0254eaccfda2 | 111 | */ |
kishino | 12:0254eaccfda2 | 112 | bool isWaitingCommand( unsigned int command_id, unsigned char *payload_p ); |
kishino | 12:0254eaccfda2 | 113 | |
kishino | 12:0254eaccfda2 | 114 | int wait(); |
kishino | 12:0254eaccfda2 | 115 | |
kishino | 12:0254eaccfda2 | 116 | int signal(); |
kishino | 12:0254eaccfda2 | 117 | |
kishino | 12:0254eaccfda2 | 118 | private: |
kishino | 12:0254eaccfda2 | 119 | /** Command request thread ID */ |
kishino | 12:0254eaccfda2 | 120 | osThreadId mCommandThreadID; |
kishino | 12:0254eaccfda2 | 121 | /** Command ID */ |
kishino | 12:0254eaccfda2 | 122 | unsigned char mCommandID; |
kishino | 12:0254eaccfda2 | 123 | /** Command SubID */ |
kishino | 12:0254eaccfda2 | 124 | unsigned char mCommandSID; |
kishino | 12:0254eaccfda2 | 125 | /** Status of command response */ |
kishino | 12:0254eaccfda2 | 126 | unsigned char mCommandStatus; |
kishino | 12:0254eaccfda2 | 127 | /** ResponseData of command response */ |
kishino | 12:0254eaccfda2 | 128 | unsigned char *mResponseBuf_p; |
kishino | 12:0254eaccfda2 | 129 | /** Scan result handler */ |
kishino | 12:0254eaccfda2 | 130 | void (*mScanResultHandler_p)(tagSCAN_RESULT_T *scan_result); |
kishino | 12:0254eaccfda2 | 131 | }; |
kishino | 12:0254eaccfda2 | 132 | |
kishino | 12:0254eaccfda2 | 133 | } |
kishino | 12:0254eaccfda2 | 134 | #endif |