I am modifying SimpeBLECentral and I want to transmit values every 10 seconds after it is connected.
How do I code it to run without the joystick input and delay transmission to 10 seconds?
This thread has been locked.
If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.
I am modifying SimpeBLECentral and I want to transmit values every 10 seconds after it is connected.
How do I code it to run without the joystick input and delay transmission to 10 seconds?
Hello Glendon,
please add one task event and set one osal_timer
case GAP_LINK_ESTABLISHED_EVENT:
{
if ( pEvent->gap.hdr.status == SUCCESS )
{
simpleBLEState = BLE_STATE_CONNECTED;
simpleBLEConnHandle = pEvent->linkCmpl.connectionHandle;
simpleBLEProcedureInProgress = TRUE;
// If service discovery not performed initiate service discovery
if ( simpleBLECharHdl == 0 )
{
osal_start_timerEx( simpleBLETaskId, START_DISCOVERY_EVT, DEFAULT_SVC_DISCOVERY_DELAY );
}
LCD_WRITE_STRING( "Connected", HAL_LCD_LINE_1 );
LCD_WRITE_STRING( bdAddr2Str( pEvent->linkCmpl.devAddr ), HAL_LCD_LINE_2 );
osal_start_timerEx( simpleBLETaskId, event_name, event_period(10000) ); //set one osal_timer
}
and handle your event
uint16 SimpleBLECentral_ProcessEvent( uint8 task_id, uint16 events )
{
VOID task_id; // OSAL required parameter that isn't used in this function
if ( events & event_name )
{
transmit your data here
// return unprocessed events
return (events ^ event_name);
}
if ( events & SYS_EVENT_MSG )
{
uint8 *pMsg;
if ( (pMsg = osal_msg_receive( simpleBLETaskId )) != NULL )
{
simpleBLECentral_ProcessOSALMsg( (osal_event_hdr_t *)pMsg );
// Release the OSAL message
VOID osal_msg_deallocate( pMsg );
}
// return unprocessed events
return (events ^ SYS_EVENT_MSG);
}