Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Dependents: SNIC-httpclient-example SNIC-ntpclient-example
Fork of SNICInterface by
YDwifi/YDwifiUartCommand.cpp@2:0ba43344c814, 2014-03-11 (annotated)
- Committer:
- kishino
- Date:
- Tue Mar 11 10:38:36 2014 +0000
- Revision:
- 2:0ba43344c814
- 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 | 2:0ba43344c814 | 1 | #include "YDwifiUartCommand.h" |
| kishino | 2:0ba43344c814 | 2 | |
| kishino | 2:0ba43344c814 | 3 | using namespace murata_wifi; |
| kishino | 2:0ba43344c814 | 4 | |
| kishino | 2:0ba43344c814 | 5 | void C_YDwifiUartCommand::setCommandID( unsigned char cmd_id ) |
| kishino | 2:0ba43344c814 | 6 | { |
| kishino | 2:0ba43344c814 | 7 | mCommandID = cmd_id; |
| kishino | 2:0ba43344c814 | 8 | } |
| kishino | 2:0ba43344c814 | 9 | |
| kishino | 2:0ba43344c814 | 10 | unsigned char C_YDwifiUartCommand::getCommandID() |
| kishino | 2:0ba43344c814 | 11 | { |
| kishino | 2:0ba43344c814 | 12 | return mCommandID; |
| kishino | 2:0ba43344c814 | 13 | } |
| kishino | 2:0ba43344c814 | 14 | |
| kishino | 2:0ba43344c814 | 15 | void C_YDwifiUartCommand::setCommandSID( unsigned char cmd_sid ) |
| kishino | 2:0ba43344c814 | 16 | { |
| kishino | 2:0ba43344c814 | 17 | mCommandSID = cmd_sid; |
| kishino | 2:0ba43344c814 | 18 | } |
| kishino | 2:0ba43344c814 | 19 | |
| kishino | 2:0ba43344c814 | 20 | unsigned char C_YDwifiUartCommand::getCommandSID() |
| kishino | 2:0ba43344c814 | 21 | { |
| kishino | 2:0ba43344c814 | 22 | return mCommandSID; |
| kishino | 2:0ba43344c814 | 23 | } |
| kishino | 2:0ba43344c814 | 24 | |
| kishino | 2:0ba43344c814 | 25 | void C_YDwifiUartCommand::setCommandStatus( unsigned char status ) |
| kishino | 2:0ba43344c814 | 26 | { |
| kishino | 2:0ba43344c814 | 27 | mCommandStatus = status; |
| kishino | 2:0ba43344c814 | 28 | } |
| kishino | 2:0ba43344c814 | 29 | |
| kishino | 2:0ba43344c814 | 30 | unsigned char C_YDwifiUartCommand::getCommandStatus() |
| kishino | 2:0ba43344c814 | 31 | { |
| kishino | 2:0ba43344c814 | 32 | return mCommandStatus; |
| kishino | 2:0ba43344c814 | 33 | } |
| kishino | 2:0ba43344c814 | 34 | |
| kishino | 2:0ba43344c814 | 35 | void C_YDwifiUartCommand::setResponseBuf( unsigned char *buf_p ) |
| kishino | 2:0ba43344c814 | 36 | { |
| kishino | 2:0ba43344c814 | 37 | mResponseBuf_p = buf_p; |
| kishino | 2:0ba43344c814 | 38 | } |
| kishino | 2:0ba43344c814 | 39 | |
| kishino | 2:0ba43344c814 | 40 | unsigned char *C_YDwifiUartCommand::getResponseBuf() |
| kishino | 2:0ba43344c814 | 41 | { |
| kishino | 2:0ba43344c814 | 42 | return mResponseBuf_p; |
| kishino | 2:0ba43344c814 | 43 | } |
| kishino | 2:0ba43344c814 | 44 | |
| kishino | 2:0ba43344c814 | 45 | |
| kishino | 2:0ba43344c814 | 46 | int C_YDwifiUartCommand::wait() |
| kishino | 2:0ba43344c814 | 47 | { |
| kishino | 2:0ba43344c814 | 48 | int ret = 0; |
| kishino | 2:0ba43344c814 | 49 | // Get thread ID |
| kishino | 2:0ba43344c814 | 50 | mCommandThreadID = osThreadGetId(); |
| kishino | 2:0ba43344c814 | 51 | |
| kishino | 2:0ba43344c814 | 52 | // Signal flags that are reported as event are automatically cleared. |
| kishino | 2:0ba43344c814 | 53 | osEvent event_ret = osSignalWait( UART_COMMAND_SIGNAL, UART_COMMAND_WAIT_TIMEOUT); |
| kishino | 2:0ba43344c814 | 54 | if( event_ret.status != osEventSignal ) |
| kishino | 2:0ba43344c814 | 55 | { |
| kishino | 2:0ba43344c814 | 56 | ret = -1; |
| kishino | 2:0ba43344c814 | 57 | } |
| kishino | 2:0ba43344c814 | 58 | return ret; |
| kishino | 2:0ba43344c814 | 59 | } |
| kishino | 2:0ba43344c814 | 60 | |
| kishino | 2:0ba43344c814 | 61 | int C_YDwifiUartCommand::signal() |
| kishino | 2:0ba43344c814 | 62 | { |
| kishino | 2:0ba43344c814 | 63 | // set signal |
| kishino | 2:0ba43344c814 | 64 | return osSignalSet(mCommandThreadID, UART_COMMAND_SIGNAL);; |
| kishino | 2:0ba43344c814 | 65 | } |
| kishino | 2:0ba43344c814 | 66 | |
| kishino | 2:0ba43344c814 | 67 | bool C_YDwifiUartCommand::isWaitingCommand( unsigned int command_id, unsigned char *payload_p ) |
| kishino | 2:0ba43344c814 | 68 | { |
| kishino | 2:0ba43344c814 | 69 | bool ret = false; |
| kishino | 2:0ba43344c814 | 70 | |
| kishino | 2:0ba43344c814 | 71 | if( (command_id == getCommandID()) |
| kishino | 2:0ba43344c814 | 72 | && (payload_p[0] == (getCommandSID() | 0x80) ) ) |
| kishino | 2:0ba43344c814 | 73 | { |
| kishino | 2:0ba43344c814 | 74 | ret = true; |
| kishino | 2:0ba43344c814 | 75 | } |
| kishino | 2:0ba43344c814 | 76 | return ret; |
| kishino | 2:0ba43344c814 | 77 | } |
| kishino | 2:0ba43344c814 | 78 |
