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.
Fork of NySNICInterface by
Diff: YDwifiInterface.cpp
- Revision:
- 6:70f522934032
- Parent:
- 5:ef3befe3edad
- Child:
- 7:e88ccbe0225f
--- a/YDwifiInterface.cpp Thu Mar 13 08:44:33 2014 +0000
+++ b/YDwifiInterface.cpp Thu Mar 13 10:33:18 2014 +0000
@@ -475,3 +475,72 @@
gMEMPOOL_PAYLOAD.free( payload_buf );
return 0;
}
+
+int C_YDwifiInterface::getWifiStatus( tagWIFI_STATUS_T *status_p)
+{
+ if( status_p == NULL )
+ {
+ printf("getWifiStatus parameter error\r\n");
+ return -1;
+ }
+
+ // Get buffer for response payload from MemoryPool
+ tagMEMPOOL_BLOCK_T *payload_buf = gMEMPOOL_PAYLOAD.alloc();
+ if( payload_buf == NULL )
+ {
+ printf("getWifiStatus payload_buf NULL\r\n");
+ return -1;
+ }
+
+ tagWIFI_GET_STATUS_REQ_T req;
+ unsigned char payload_array[UART_REQUEST_PAYLOAD_MAX];
+ unsigned char command_array[UART_REQUEST_PAYLOAD_MAX];
+ unsigned short payload_len;
+ unsigned int command_len;
+ int ret;
+
+ // Make request
+ req.cmd_sid = UART_CMD_SID_WIFI_GET_STATUS_REQ;
+ req.seq = mUartRequestSeq++;
+ req.interface = 0;
+
+ // Make command payload
+ payload_len = C_YD_UartMsg::makePayload( sizeof(tagWIFI_GET_STATUS_REQ_T), (unsigned char *)&req, payload_array );
+ // Make all command request
+ command_len = C_YD_UartMsg::makeRequest( UART_CMD_ID_WIFI, payload_array, payload_len, command_array );
+
+ // Set data for response
+ mUartCommand.setCommandID( UART_CMD_ID_WIFI );
+ mUartCommand.setCommandSID( req.cmd_sid );
+ mUartCommand.setResponseBuf( payload_buf->buf );
+
+ // Send uart command request
+ sendUart( command_len, command_array );
+
+ // Wait UART response
+ ret = mUartCommand.wait();
+ if( ret != 0 )
+ {
+ printf( "getWifiStatus failed\r\n" );
+ gMEMPOOL_PAYLOAD.free( payload_buf );
+ return -1;
+ }
+
+ // set status
+ status_p->status = (E_WIFI_STATUS)payload_buf->buf[2];
+
+ // set Mac address
+ if( status_p->status != e_STATUS_OFF )
+ {
+ memcpy( status_p->mac_address, &payload_buf->buf[3], BSSID_MAC_LENTH );
+ }
+
+ // set SSID
+ if( ( status_p->status == e_STA_JOINED ) == ( status_p->status == e_AP_STARTED ) )
+ {
+ memcpy( status_p->ssid, &payload_buf->buf[9], strlen( (char *)&payload_buf->buf[9]) );
+ }
+
+ gMEMPOOL_PAYLOAD.free( payload_buf );
+ return 0;
+}
