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