📄 states.c
字号:
|
| Return : No return value
|
*------------------------------------------------------------------------------------------------------------------------------*/
TBX_VOID
TB640FskDeactivateInternal (
IN TBX_UINT32 in_un32AdapterIdx,
IN TBX_UINT32 in_un32TrunkIdx,
IN TBX_UINT32 in_un32TimeslotIdx )
{
TBX_RESULT result;
PTB640_FSK_ADAPTER_INFO pAdapterInfo;
PTB640_FSK_TRUNK_INFO pTrunkInfo;
PTB640_FSK_TRUNK_RESOURCE_INFO pTrunkResInfo;
PTBX_ASYNC_OP_CONTEXT pOpContext;
PTB640_FSK_CALL_CONTEXT pCallContext;
/*---------------------------------------------------------------------------------------------------------------------------
| Code section
*--------------------------------------------------------------------------------------------------------------------------*/
CODE
{
/* Initialize local variables */
pAdapterInfo = &(g_AppContext->ahAdapterInfo [in_un32AdapterIdx]);
pTrunkInfo = &(pAdapterInfo->aTrunkInfo [in_un32TrunkIdx]);
pTrunkResInfo = &(pTrunkInfo->aResourceInfo [in_un32TimeslotIdx]);
/* Make sure the timeslot is in 'ready' state */
if (pTrunkResInfo->State == TB640_FSK_CALL_APP_STATE_IDLE || !pTrunkResInfo->fInUse )
{
TBX_EXIT_SUCCESS (TBX_RESULT_OK);
}
/* Retrieve the operation context */
result = TBXAsyncRetrieveOp
(
pAdapterInfo->ahOperationLib [pTrunkInfo->un32OpLibIdx],
pTrunkResInfo->hVPResource,
&pOpContext,
(PTBX_VOID*)&pCallContext
);
if (TBX_RESULT_FAILURE(result))
{
TBX_EXIT_ERROR(TBX_RESULT_FAIL, 0, "Unable to retrieve operation context for selected timeslot");
}
/* Tell remote we are closing sequence */
TB640FskSendCloseRemote( pCallContext );
/* Return the timeslot to 'idle' and unused state */
pTrunkResInfo->State = TB640_FSK_CALL_APP_STATE_IDLE;
pTrunkResInfo->fInUse = TBX_FALSE;
TB640_FSK_DECREMENT_TRANSIANT_CALL (1);
/* End of the code (skip to cleanup) */
TBX_EXIT_SUCCESS (TBX_RESULT_OK);
}
/*---------------------------------------------------------------------------------------------------------------------------
| Error handling section
*--------------------------------------------------------------------------------------------------------------------------*/
ERROR_HANDLING
{
/* Print error message */
TB640_FSK_LOG (TRACE_LEVEL_ALWAYS, "%s (Result = 0x%08X, %s, line %d)\n", TBX_ERROR_DESCRIPTION, TBX_ERROR_RESULT, __FILE__, TBX_ERROR_LINE);
}
/*---------------------------------------------------------------------------------------------------------------------------
| Cleanup section
*--------------------------------------------------------------------------------------------------------------------------*/
CLEANUP
{
g_fRefreshDisplay |= (TB640_FSK_CLI_REFRESH_DISPLAY);
}
RETURN_VOID;
}
/*-------------------------------------------------------------------------------------------------------------------------------
|
| TB640FskEventMessageHandler: This function is called by the operation library when it hasn't recognize a specific message
| and couldn't associate it with an operation (i.e. a specific call context).
|
| in_pvAppContext : User-defined context
| in_hMsg : Handle of the unknown message
|
| Note : We cannot free or re-use the buffer after this function exits.
|
| Return : No return value
|
*------------------------------------------------------------------------------------------------------------------------------*/
TBX_VOID
TB640FskEventMessageHandler (
IN PTBX_VOID in_pvAppContext,
IN TBX_MSG_HANDLE in_hMsg)
{
TBX_RESULT result;
TBX_UINT32 un32MsgId;
TBX_UINT32 un32AdapterIdx;
TBX_UINT32 un32OpLibIdx;
PTB640_FSK_ADAPTER_INFO pAdapterInfo;
PTBX_ASYNC_OP_CONTEXT pOpContext;
PTB640_FSK_CALL_CONTEXT pCallContext;
/*---------------------------------------------------------------------------------------------------------------------------
| Code section
*--------------------------------------------------------------------------------------------------------------------------*/
CODE
{
/* Initialize local variables */
pOpContext = NULL;
pCallContext = NULL;
/* Retrieve the adapter index and operation lib index */
TB640_FSK_RETRIEVE_APP_CONTEXT (in_pvAppContext, un32AdapterIdx, un32OpLibIdx);
pAdapterInfo = &(g_AppContext->ahAdapterInfo [un32AdapterIdx]);
TB640FskLockFromOpLibIdx( pAdapterInfo, un32OpLibIdx );
/* Check which message did we received ? */
un32MsgId = TBX_MSG_ID_GET (in_hMsg);
switch (un32MsgId)
{
case TB640_MSG_ID_VP_FSK_TRANSMIT:
{
/* Received simulated TX data from a remote host */
PTB640_REQ_VP_FSK_TRANSMIT pEvt = (PTB640_REQ_VP_FSK_TRANSMIT)TBX_MSG_PAYLOAD_POINTER(in_hMsg);
TBX_UINT32 un32MsgCount;
TBX_UINT32 un32MsgIndex;
/* Retrieve our operation from the resource handle */
result = TBXAsyncRetrieveOp
(
pAdapterInfo->ahOperationLib [un32OpLibIdx],
pEvt->hVPResource,
&pOpContext,
(PTBX_VOID*)&pCallContext
);
if (TBX_RESULT_FAILURE(result))
{
/* Received a FSK message on a timeslot we are not using anymore. */
TBX_EXIT_SUCCESS (TBX_RESULT_OK);
}
un32MsgCount = 1/*pEvt->un8BurstSize*/;
for( un32MsgIndex = 0; un32MsgIndex < un32MsgCount; un32MsgIndex++ )
{
/* Reformat message into PTB640_EVT_VP_FSK_NOTIF_RECEIVE by moving data around in the structure */
PTB640_EVT_VP_FSK_NOTIF_RECEIVE pEventRxData = TBX_MSG_PAYLOAD_POINTER(in_hMsg);
pEventRxData->un32MsgVersion = pEvt->un32MsgVersion;
pEventRxData->hVPResource = pEvt->hVPResource;
pEventRxData->FskMsg = pEvt->FskMsg;
result = TB640FskProcessStateChange (
pAdapterInfo->ahOperationLib [un32OpLibIdx],
pOpContext,
pCallContext,
TB640_MSG_ID_VP_FSK_NOTIF_RECEIVE,
TBX_MSG_PAYLOAD_POINTER(in_hMsg) );
if (TBX_RESULT_FAILURE(result))
{
TBX_EXIT_ERROR(TBX_RESULT_FAIL, 0, "Unable to process state change");
}
}
/* Return response to remote host */
} break;
case TB640_MSG_ID_VP_FSK_NOTIF_RECEIVE:
{
/* Received Rx data */
PTB640_EVT_VP_FSK_NOTIF_RECEIVE pEvt = TBX_MSG_PAYLOAD_POINTER(in_hMsg);
/* Retrieve our operation from the resource handle */
result = TBXAsyncRetrieveOp
(
pAdapterInfo->ahOperationLib [un32OpLibIdx],
pEvt->hVPResource,
&pOpContext,
(PTBX_VOID*)&pCallContext
);
if (TBX_RESULT_FAILURE(result))
{
/* Received a FSK message on a timeslot we are not using anymore. */
TBX_EXIT_SUCCESS (TBX_RESULT_OK);
}
/* Reformat message into PTB640_EVT_VP_FSK_NOTIF_RECEIVE by moving data around in the structure */
result = TB640FskProcessStateChange (
pAdapterInfo->ahOperationLib [un32OpLibIdx],
pOpContext,
pCallContext,
TB640_MSG_ID_VP_FSK_NOTIF_RECEIVE,
TBX_MSG_PAYLOAD_POINTER(in_hMsg) );
if (TBX_RESULT_FAILURE(result))
{
TBX_EXIT_ERROR(TBX_RESULT_FAIL, 0, "Unable to process state change");
}
} break;
case TB640_MSG_ID_VP_FSK_SEND_DIGIT:
{
/* Received simulated TX ack from a remote host */
PTB640_REQ_VP_FSK_SEND_DIGIT pEvt = TBX_MSG_PAYLOAD_POINTER(in_hMsg);
PTB640_EVT_VP_TONE_NOTIF_DETECTION pEvtTone = TBX_MSG_PAYLOAD_POINTER(in_hMsg);
/* Retrieve our operation from the resource handle */
result = TBXAsyncRetrieveOp
(
pAdapterInfo->ahOperationLib [un32OpLibIdx],
pEvt->hVPResource,
&pOpContext,
(PTBX_VOID*)&pCallContext
);
if (TBX_RESULT_FAILURE(result))
{
/* Received a FSK ACK on a timeslot we are not using anymore. */
TBX_EXIT_SUCCESS (TBX_RESULT_OK);
}
/* Reformat message into PTB640_EVT_VP_FSK_NOTIF_RECEIVE by moving data around in the structure */
pEvtTone->un32MsgVersion = pEvt->un32MsgVersion;
pEvtTone->hVPResource = pEvt->hVPResource;
pEvtTone->Tone = pEvt->Tone;
result = TB640FskProcessStateChange (
pAdapterInfo->ahOperationLib [un32OpLibIdx],
pOpContext,
pCallContext,
TB640_MSG_ID_VP_TONE_NOTIF_DETECTION,
TBX_MSG_PAYLOAD_POINTER(in_hMsg) );
if (TBX_RESULT_FAILURE(result))
{
TBX_EXIT_ERROR(TBX_RESULT_FAIL, 0, "Unable to process state change");
}
/* Return response to remote host */
} break;
case TB640_MSG_ID_VP_TONE_NOTIF_DETECTION:
{
/* Received simulated TX ack from a remote host */
PTB640_EVT_VP_TONE_NOTIF_DETECTION pEvt = TBX_MSG_PAYLOAD_POINTER(in_hMsg);
/* Retrieve our operation from the resource handle */
result = TBXAsyncRetrieveOp
(
pAdapterInfo->ahOperationLib [un32OpLibIdx],
pEvt->hVPResource,
&pOpContext,
(PTBX_VOID*)&pCallContext
);
if (TBX_RESULT_FAILURE(result))
{
/* Received a FSK ACK on a timeslot we are not using anymore. */
TBX_EXIT_SUCCESS (TBX_RESULT_OK);
}
TB640_FSK_LOG (TRACE_LEVEL_1, "Received Tone %d from tr:ts %d:%d\n",
pEvt->Tone.Digit,
pCallContext->un32TrunkIndex, pCallContext->un32TimeslotIndex);
result = TB640FskProcessStateChange (
pAdapterInfo->ahOperationLib [un32OpLibIdx],
pOpContext,
pCallContext,
TB640_MSG_ID_VP_TONE_NOTIF_DETECTION,
TBX_MSG_PAYLOAD_POINTER(in_hMsg) );
if (TBX_RESULT_FAILURE(result))
{
TBX_EXIT_ERROR(TBX_RESULT_FAIL, 0, "Unable to process state change");
}
/* Return response to remote host */
} break;
case TB640_MSG_ID_VP_TONE_NOTIF_STOP:
{
PTB640_EVT_VP_TONE_NOTIF_STOP pEvt = TBX_MSG_PAYLOAD_POINTER(in_hMsg);
/* Retrieve our operation from the resource handle */
result = TBXAsyncRetrieveOp
(
pAdapterInfo->ahOperationLib [un32OpLibIdx],
pEvt->hVPResource,
&pOpContext,
(PTBX_VOID*)&pCallContext
);
if (TBX_RESULT_FAILURE(result))
{
/* Received a FSK ACK on a timeslot we are not using anymore. */
TBX_EXIT_SUCCESS (TBX_RESULT_OK);
}
TB640_FSK_LOG (TRACE_LEVEL_1, "Received ToneStop from tr:ts %d:%d\n",
pCallContext->un32TrunkIndex, pCallContext->un32TimeslotIndex);
result = TB640FskProcessStateChange (
pAdapterInfo->ahOperationLib [un32OpLibIdx],
pOpContext,
pCallContext,
TB640_MSG_ID_VP_TONE_NOTIF_STOP,
TBX_MSG_PAYLOAD_POINTER(in_hMsg) );
if (TBX_RESULT_FAILURE(result))
{
TBX_EXIT_ERROR(TBX_RESULT_FAIL, 0, "Unable to process state change");
}
/* Return response to remote host */
} break;
case TB640_MSG_ID_VP_FSK_NOTIF_END:
{
PTB640_EVT_VP_FSK_NOTIF_END pEvt = TBX_MSG_PAYLOAD_POINTER(in_hMsg);
/* Retrieve our operation from the resource handle */
result = TBXAsyncRetrieveOp
(
pAdapterInfo->ahOperationLib [un32OpLibIdx],
pEvt->hVPResource,
&pOpContext,
(PTBX_VOID*)&pCallContext
);
if (TBX_RESULT_FAILURE(result))
{
/* Received a FSK ACK on a timeslot we are not using anymore. */
TBX_EXIT_SUCCESS (TBX_RESULT_OK);
}
TB640_FSK_LOG (TRACE_LEVEL_1, "Received FskEnd from tr:ts %d:%d\n",
pCallContext->un32TrunkIndex, pCallContext->un32TimeslotIndex);
result = TB640FskProcessStateChange (
pAdapterInfo->ahOperationLib [un32OpLibIdx],
pOpContext,
pCallContext,
TB640_MSG_ID_VP_FSK_NOTIF_END,
TBX_MSG_PAYLOAD_POINTER(in_hMsg) );
if (TBX_RESULT_FAILURE(result))
{
TBX_EXIT_ERROR(TBX_RESULT_FAIL, 0, "Unable to process state change");
}
/* Return response to remote host */
} break;
/* CPU Monitor report */
case TB640_MSG_ID_ADAPTER_NOTIF_CPU_REPORT:
{
PTB640_EVT_ADAPTER_NOTIF_CPU_REPORT pEvtCpuReport = (PTB640_EVT_ADAPTER_NOTIF_CPU_REPORT)TBX_MSG_PAYLOAD_POINTER(in_hMsg);
if( pEvtCpuReport->un8CpuNumber == 1 )
pAdapterInfo->un32AdapterCpu1Usage = pEvtCpuReport->un32CpuUsage;
else
pAdapterInfo->un32AdapterCpu0Usage = pEvtCpuReport->un32CpuUsage;
g_fRefreshDisplay |= (TB640_FSK_CLI_REFRESH_DISPLAY);
TBX_EXIT_SUCCESS (TBX_RESULT_OK);
} break;
/* Unknown message, just discard */
default:
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -