// The task status
printf(
" [4] +%lu Tx Device Connection Error,Time=%lu(ms)rn",
nTxFile.m_nIOTime.m_dwX32SN,
dwTimerX );
// END the color
END_Console_Color();
}
break;
case TXD_TASK_STATUS_ERR_ABANDON:
{
// NEW the color
NEW_Console_Color( FOREGROUND_GREEN | BACKGROUND_BLUE );
// The task status
printf(
" [4] +%lu Tx Device Transmit Give Up,Time=%lu(ms)rn",
nTxFile.m_nIOTime.m_dwX32SN,
dwTimerX );
// END the color
END_Console_Color();
}
break;
default:
{
// NEW the color
NEW_Console_Color( FOREGROUND_GREEN | BACKGROUND_BLUE );
// The task status
printf(
" [4] +%lu Tx Completed With Unknown Error,Time=%lu(ms)rn",
nTxFile.m_nIOTime.m_dwX32SN,
dwTimerX );
// END the color
END_Console_Color();
}
break;
}
}
// *****************************************************************************
// Design Notes:
// -----------------------------------------------------------------------------
void Sub_Sample_CallBack_Notice_AirTCP( unsigned char iShell )
{
unsigned char iTaskID;
WiMinet_IOT_Record nAirTCP;
WiMinet_TxReport * pTxReport;
// The event information
printf( "Notice.AirTCPrn" );
// Get the event contents
WiMinet_GetNotice_AirTCP( iShell, &nAirTCP );
// The task time information
PrintTaskInfomation_Time( &nAirTCP.m_nIOTime );
// The task node information
PrintTaskInfomation_Node( &nAirTCP.m_nPacket );
// The event of the object
switch ( nAirTCP.m_nPacket.m_iAttrib )
{
case WIMINET_EVENT_COMMUTE_END:
{
// The TxReport status
pTxReport = ( WiMinet_TxReport * )nAirTCP.m_nPacket.m_pBuffer;
// The report status
printf( " [4] Events=TCP Commute Endrn" );
// The TaskID number
printf( " [5] TaskID=%urn", pTxReport->m_iTaskID );
// The Tx data size
printf( " [6] RxSize=%u Bytesrn", pTxReport->m_iNotUse );
// The Tx data size
printf( " [7] TxSize=%lu Bytesrn", pTxReport->m_dwCount );
// The report status
printf( " [8] Errors=0X%02X", pTxReport->m_iQError );
// The detailed error code: No Header
if ( pTxReport->m_iQError & WIMINET_IO_REPORT_NO_HEADER )
{
printf( "[No Header]" );
}
// The detailed error code: Invalid Size
if ( pTxReport->m_iQError & WIMINET_IO_REPORT_ER_AMOUNT )
{
printf( "[Invalid Size]" );
}
// The detailed error code: Invalid CRC32
if ( pTxReport->m_iQError & WIMINET_IO_REPORT_ER_CRCODE )
{
printf( "[Invalid CRC32]" );
}
// The end of this line
printf( "rn" );
}
break;
case WIMINET_EVENT_COMMUTE_ERR:
{
// The report status
printf( " [4] Events=TCP Commute Errorrn" );
// Get the taskid
iTaskID = nAirTCP.m_nPacket.m_pBuffer[0X00];
// The TaskID number
printf( " [5] TaskID=%urn", iTaskID );
}
break;
case WIMINET_EVENT_CONNECT_ERR:
{
// The report status
printf( " [4] Events=TCP Connect Errorrn" );
// Get the taskid
iTaskID = nAirTCP.m_nPacket.m_pBuffer[0X00];
// The TaskID number
printf( " [5] TaskID=%urn", iTaskID );
}
break;
default:
{
// The report status
printf( " [4] Events=Unknown Eventsrn" );
}
break;
}
}
// *****************************************************************************
// Design Notes:
// -----------------------------------------------------------------------------
void Sub_Sample_CallBack_Report_Client( unsigned char iShell )
{
unsigned long dwSize;
WiMinet_IOT_Record nReport;
WiMinet_RxReport * pRxReport;
// The event information
printf( "Report.Clientrn" );
// Get the event contents
WiMinet_GetReport_Client( iShell, &nReport );
// The task time information
PrintTaskInfomation_Time( &nReport.m_nIOTime );
// The task node information
PrintTaskInfomation_Node( &nReport.m_nPacket );
// The TxReport status
pRxReport = ( WiMinet_RxReport * )nReport.m_nPacket.m_pBuffer;
// Get the device information
printf(
" [4] Device=0X%02X(%d)rn",
pRxReport->m_iDevice,
pRxReport->m_iDevice );
// Get the firmware version
printf( " [5] Version=0X%08lX", pRxReport->m_dwBuild );
// The build version for firmware update
printf(
" --> [20%u.%u.%u+R%u]rn",
( unsigned char )( pRxReport->m_dwBuild >> 0X18 ),
( unsigned char )( pRxReport->m_dwBuild >> 0X10 ),
( unsigned char )( pRxReport->m_dwBuild >> 0X08 ),
( unsigned char )( pRxReport->m_dwBuild >> 0X00 ) );
// The received byte size by the remote endpoint
dwSize = ( ( unsigned long )pRxReport->m_iMBSize << 0X10 );
// The LSB value
dwSize += pRxReport->m_iLBSize;
// The client received byte size
printf( " [6] Counter=%lu Bytesrn", dwSize );
// The battery voltage
printf( " [7] Battery=%.3f(V)rn", pRxReport->m_iBATVol * 0.001f );
// The RxRSSI voltage
printf( " [8] RxRSSI=%d(dBm)rn", pRxReport->m_iRxRSSI );
// The RxRSSI voltage
printf( " [9] TxRSSI=%d(dBm)rn", pRxReport->m_iTxRSSI );
// The client receive error code
printf( " [A] Errors=0X%02X", pRxReport->m_iQError );
// The detailed error code: Rx Time Out
if ( pRxReport->m_iQError & WIMIET_IO_REPORT_RX_TIMEOUT )
{
printf( " [Rx Time Out]" );
}
// The detailed error code: No Header
if ( pRxReport->m_iQError & WIMINET_IO_REPORT_NO_HEADER )
{
printf( "[No Header]" );
}
// The detailed error code: Invalid Size
if ( pRxReport->m_iQError & WIMINET_IO_REPORT_ER_AMOUNT )
{
printf( "[Invalid Size]" );
}
// The detailed error code: Invalid CRC32
if ( pRxReport->m_iQError & WIMINET_IO_REPORT_ER_CRCODE )
{
printf( "[Invalid CRC32]" );
}
// The end of this line
printf( "rn" );
}
// *****************************************************************************
// Design Notes:
// -----------------------------------------------------------------------------
void Sub_Sample_CallBack_Task_Complete( unsigned char iShell )
{
unsigned char iSize;
unsigned char iStatus;
unsigned char iRetVal;
unsigned long dwSerial;
// The event information
printf( "Task.Completern" );
// Get the task complete status
iRetVal = WiMinet_GetTask_Complete( iShell, &iStatus, &dwSerial );
// The task serial number
printf( " [1] Serial=%lurn", dwSerial );
// The task over status
printf( " [2] TxOver=%drn", iRetVal );
// The error bit mask
printf( " [3] ERMask=0X%02X", iStatus );
// Check the error status:Wakeup
if ( iStatus & WIMINET_MASK_NOTICE_WAKEUP )
{
printf( " + Wakeup" );
}
// Check the error status:AirTCP
if ( iStatus & WIMINET_MASK_NOTICE_AIRTCP )
{
printf( " + AirTCP" );
}
// Check the error status:TxFile
if ( iStatus & WIMINET_MASK_STATUS_TXFILE )
{
printf( " + TxFile" );
}
// Check the error status:Report
if ( iStatus & WIMINET_MASK_REPORT_CLIENT )
{
printf( " + Report" );
}
// Check the error status:Submit
if ( iStatus & WIMINET_MASK_SUBMIT_PACKET )
{
printf( " + Submit" );
}
// Get the writable status
iStatus = WiMinet_GetTask_Writable( iShell, &iSize );
// The new writable status
printf( "rn [4] Submit=%d/%drn", iStatus, iSize );
// The end of line status
printf( "rnrn" );
printf( "==========================================" );
printf( "==========================================" );
printf( "rn" );
}
// *****************************************************************************
// Design Notes:
// -----------------------------------------------------------------------------
void Sample_CallBack( unsigned char iShell, unsigned char iStatus )
{
printf( "rnShell[%d]:Status=0X%02X,Event=", iShell, iStatus );
// Process all the events
switch ( iStatus )
{
case WIMINET_NOTICE_WAKEUP:
{
Sub_Sample_CallBack_Notice_Wakeup( iShell );
}
break;
case WIMINET_STATUS_TXFILE:
{
Sub_Sample_CallBack_Status_TxFile( iShell );
}
break;
case WIMINET_NOTICE_AIRTCP:
{
Sub_Sample_CallBack_Notice_AirTCP( iShell );
}
break;
case WIMINET_REPORT_CLIENT:
{
Sub_Sample_CallBack_Report_Client( iShell );
}
break;
case WIMINET_TASK_COMPLETE:
{
Sub_Sample_CallBack_Task_Complete( iShell );
}
break;
default:
{
}
break;
}
}
// *****************************************************************************
// Design Notes:
// -----------------------------------------------------------------------------
void Active_Poll_Task_Status_X1( unsigned char iShell )
{
unsigned char index;
unsigned char iStatus;
unsigned char iTxOver;
unsigned long dwSerial;
// Get the complete status
iTxOver = WiMinet_GetTask_Complete( iShell, &iStatus, &dwSerial );
// Check if task completed
if ( !iTxOver )
{
return;
}
// Get the shell index
index = ( iShell - 0X01 );
// Compare the task serial
if ( dwSerial == dwStatic_Serial[index] )
{
return;
}
// Update current task serial
dwStatic_Serial[index] = dwSerial;
// Print the notice.wakeup
Sample_CallBack( iShell, WIMINET_NOTICE_WAKEUP );
// Print the status.txfile
Sample_CallBack( iShell, WIMINET_STATUS_TXFILE );