/********************************************************************* * @fn SimpleBLEBroadcaster_processEvent * * @brief Application task entry point for the Simple BLE Broadcaster. * * @param none * * @return none */ static void SimpleBLEBroadcaster_taskFxn(UArg a0, UArg a1) { // Initialize application SimpleBLEBroadcaster_init(); // Application main loop for (;;) { // Get the ticks since startup uint32_t tickStart = Clock_getTicks(); // Waits for a signal to the semaphore associated with the calling thread. // Note that the semaphore associated with a thread is signaled when a // message is queued to the message receive queue of the thread or when // ICall_signal() function is called onto the semaphore. ICall_Errno errno = ICall_wait(ICALL_TIMEOUT_FOREVER); if (errno == ICALL_ERRNO_SUCCESS) { ICall_EntityID dest; ICall_ServiceEnum src; ICall_HciExtEvt *pMsg = NULL; if (ICall_fetchServiceMsg(&src, &dest, (void **)&pMsg) == ICALL_ERRNO_SUCCESS) { if ((src == ICALL_SERVICE_CLASS_BLE) && (dest == selfEntity)) { // Process inter-task message SimpleBLEBroadcaster_processStackMsg((ICall_Hdr *)pMsg); } if (pMsg) { ICall_freeMsg(pMsg); } } // If RTOS queue is not empty, process app message. while (!Queue_empty(appMsgQueue)) { sbbEvt_t *pMsg = (sbbEvt_t *)Util_dequeueMsg(appMsgQueue); if (pMsg) { // Process message. SimpleBLEBroadcaster_processAppMsg(pMsg); // Free the space from the message. ICall_free(pMsg); } } } } }
/********************************************************************* * @fn simpleTopology_taskFxn * * @brief Application task entry point for the Simple BLE Multi. * * @param a0, a1 - not used. * * @return None. */ static void simpleTopology_taskFxn(UArg a0, UArg a1) { // Initialize application simpleTopology_init(); // Application main loop for (;;) { // Waits for a signal to the semaphore associated with the calling thread. // Note that the semaphore associated with a thread is signaled when a // message is queued to the message receive queue of the thread or when // ICall_signal() function is called onto the semaphore. ICall_Errno errno = ICall_wait(ICALL_TIMEOUT_FOREVER); if (errno == ICALL_ERRNO_SUCCESS) { ICall_EntityID dest; ICall_ServiceEnum src; ICall_HciExtEvt *pMsg = NULL; if (ICall_fetchServiceMsg(&src, &dest, (void **)&pMsg) == ICALL_ERRNO_SUCCESS) { uint8 safeToDealloc = TRUE; if ((src == ICALL_SERVICE_CLASS_BLE) && (dest == selfEntity)) { ICall_Event *pEvt = (ICall_Event *)pMsg; // Check for BLE stack events first if (pEvt->signature == 0xffff) { if (pEvt->event_flag & SBT_CONN_EVT_END_EVT) { // Try to retransmit pending ATT Response (if any) simpleTopology_sendAttRsp(); } } else { // Process inter-task message safeToDealloc = simpleTopology_processStackMsg((ICall_Hdr *)pMsg); } } if (pMsg && safeToDealloc) { ICall_freeMsg(pMsg); } } // If RTOS queue is not empty, process app message. while (!Queue_empty(appMsgQueue)) { sbtEvt_t *pMsg = (sbtEvt_t *)Util_dequeueMsg(appMsgQueue); if (pMsg) { // Process message. simpleTopology_processAppMsg(pMsg); // Free the space from the message. ICall_free(pMsg); } } } if (events & SBT_START_DISCOVERY_EVT) { events &= ~SBT_START_DISCOVERY_EVT; simpleTopology_startDiscovery(); } } }
/********************************************************************* * @fn glucCollCentral_taskFxn * * @brief Application task entry point for the Glucose collector. * * @param a0, a1 - not used * * @return none */ static void glucCollCentral_taskFxn(UArg a0, UArg a1) { // Initialize application glucCollCentral_Init(); // Application main loop for (;;) { // Waits for a signal to the semaphore associated with the calling thread. // Note that the semaphore associated with a thread is signaled when a // message is queued to the message receive queue of the thread or when // ICall_signal() function is called onto the semaphore. ICall_Errno errno = ICall_wait(ICALL_TIMEOUT_FOREVER); if (errno == ICALL_ERRNO_SUCCESS) { ICall_EntityID dest; ICall_ServiceEnum src; ICall_HciExtEvt *pMsg = NULL; if (ICall_fetchServiceMsg(&src, &dest, (void **)&pMsg) == ICALL_ERRNO_SUCCESS) { if ((src == ICALL_SERVICE_CLASS_BLE) && (dest == selfEntity)) { // Process inter-task message glucCollCentral_processStackMsg((ICall_Hdr *)pMsg); } if (pMsg) { ICall_freeMsg(pMsg); } } // If RTOS queue is not empty, process app message. while (!Queue_empty(appMsgQueue)) { glucCollEvt_t *pMsg = (glucCollEvt_t *)Util_dequeueMsg(appMsgQueue); if (pMsg) { // Process message. glucCollCentral_processAppMsg(pMsg); // Free the space from the message. ICall_free(pMsg); } } if (events) { if (events & GLUCOLL_PROCEDURE_TIMEOUT_EVT) { events &= ~GLUCOLL_PROCEDURE_TIMEOUT_EVT; if (glucCollState == BLE_STATE_CONNECTED) { // disconnect glucCollState = BLE_STATE_DISCONNECTING; GAPCentralRole_TerminateLink(glucCollConnHandle); LCD_WRITE_STRING("Timeout", LCD_PAGE0); LCD_WRITE_STRING("", LCD_PAGE1); LCD_WRITE_STRING("", LCD_PAGE2); } } if (events & GLUCOLL_START_DISCOVERY_EVT) { events &= ~GLUCOLL_START_DISCOVERY_EVT; if (glucCollPairingStarted) { // Postpone discovery until pairing completes glucCollDiscPostponed = TRUE; } else { glucCollCentral_startDiscovery(); } } } } } }
/******************************************************************************* * @fn SensorTag_taskFxn * * @brief Application task entry point for the SensorTag * * @param a0, a1 (not used) * * @return none */ static void SensorTag_taskFxn(UArg a0, UArg a1) { // Initialize application SensorTag_init(); // Application main loop for (;;) { // Waits for a signal to the semaphore associated with the calling thread. // Note that the semaphore associated with a thread is signalled when a // message is queued to the message receive queue of the thread or when // ICall_signal() function is called onto the semaphore. ICall_Errno errno = ICall_wait(ICALL_TIMEOUT_FOREVER); if (errno == ICALL_ERRNO_SUCCESS) { ICall_EntityID dest; ICall_ServiceEnum src; ICall_HciExtEvt *pMsg = NULL; if (ICall_fetchServiceMsg(&src, &dest, (void **)&pMsg) == ICALL_ERRNO_SUCCESS) { if ((src == ICALL_SERVICE_CLASS_BLE) && (dest == selfEntity)) { // Process inter-task message SensorTag_processStackMsg((ICall_Hdr *)pMsg); } if (pMsg) { ICall_freeMsg(pMsg); } } // If RTOS queue is not empty, process app message. while (!Queue_empty(appMsgQueue)) { stEvt_t *pMsg = (stEvt_t *)Util_dequeueMsg(appMsgQueue); if (pMsg) { // Process message. SensorTag_processAppMsg(pMsg); // Free the space from the message. ICall_free(pMsg); } } // Process new data if available SensorTagKeys_processEvent(); SensorTagOpt_processSensorEvent(); SensorTagMov_processSensorEvent(); } if (!!(events & ST_PERIODIC_EVT)) { events &= ~ST_PERIODIC_EVT; if (gapProfileState == GAPROLE_CONNECTED || gapProfileState == GAPROLE_ADVERTISING) { Util_startClock(&periodicClock); } // Perform periodic application task if (gapProfileState == GAPROLE_CONNECTED) { SensorTag_performPeriodicTask(); } // Blink green LED when advertising if (gapProfileState == GAPROLE_ADVERTISING) { SensorTag_blinkLed(Board_LED2,1); #ifdef FEATURE_LCD SensorTag_displayBatteryVoltage(); #endif } } #ifdef FEATURE_OAD while (!Queue_empty(hOadQ)) { oadTargetWrite_t *oadWriteEvt = Queue_dequeue(hOadQ); // Identify new image. if (oadWriteEvt->event == OAD_WRITE_IDENTIFY_REQ) { OAD_imgIdentifyWrite(oadWriteEvt->connHandle, oadWriteEvt->pData); } // Write a next block request. else if (oadWriteEvt->event == OAD_WRITE_BLOCK_REQ) { OAD_imgBlockWrite(oadWriteEvt->connHandle, oadWriteEvt->pData); } // Free buffer. ICall_free(oadWriteEvt); } #endif //FEATURE_OAD } // task loop }
/********************************************************************* * @fn simpleTopology_taskFxn * * @brief Application task entry point for the Simple BLE Multi. * * @param a0, a1 - not used. * * @return None. */ static void simpleTopology_taskFxn(UArg a0, UArg a1) { // Initialize application simpleTopology_init(); // Application main loop for (;;) { // Waits for a signal to the semaphore associated with the calling thread. // Note that the semaphore associated with a thread is signaled when a // message is queued to the message receive queue of the thread or when // ICall_signal() function is called onto the semaphore. ICall_Errno errno = ICall_wait(ICALL_TIMEOUT_FOREVER); if (errno == ICALL_ERRNO_SUCCESS) { ICall_EntityID dest; ICall_ServiceEnum src; ICall_HciExtEvt *pMsg = NULL; if (ICall_fetchServiceMsg(&src, &dest, (void **)&pMsg) == ICALL_ERRNO_SUCCESS) { uint8 safeToDealloc = TRUE; if ((src == ICALL_SERVICE_CLASS_BLE) && (dest == selfEntity)) { // Process inter-task message safeToDealloc = simpleTopology_processStackMsg((ICall_Hdr *)pMsg); } if (pMsg && safeToDealloc) { ICall_freeMsg(pMsg); } } // If RTOS queue is not empty, process app message. while (!Queue_empty(appMsgQueue)) { sbtEvt_t *pMsg = (sbtEvt_t *)Util_dequeueMsg(appMsgQueue); if (pMsg) { // Process message. simpleTopology_processAppMsg(pMsg); // Free the space from the message. ICall_free(pMsg); } } } // the trigger was a periodic event // trigger was the SCAN_EVENT if (!!(events & SCAN_EVENT)) { // effectively mark off the event as "handled" events &= ~SCAN_EVENT; // now start discovery. // CJ: I think that the scan parameters are set in such a way // that it will start and stop itself scanningStarted = true; GAPRole_StartDiscovery(DEFAULT_DISCOVERY_MODE, DEFAULT_DISCOVERY_ACTIVE_SCAN, DEFAULT_DISCOVERY_WHITE_LIST); } } }
/********************************************************************* * @fn HeartRate_taskFxn * * @brief Application task entry point for the Heart Rate. * * @param none * * @return none */ static void HeartRate_taskFxn(UArg a0, UArg a1) { // Initialize the application. HeartRate_init(); // Application main loop. for(;;) { // Waits for a signal to the semaphore associated with the calling thread. // Note that the semaphore associated with a thread is signaled when a // message is queued to the message receive queue of the thread or when the // ICall_signal() function is called on the thread's respective semaphore. ICall_Errno errno = ICall_wait(ICALL_TIMEOUT_FOREVER); if (errno == ICALL_ERRNO_SUCCESS) { ICall_EntityID dest; ICall_ServiceEnum src; ICall_HciExtEvt *pMsg = NULL; if (ICall_fetchServiceMsg(&src, &dest, (void **)&pMsg) == ICALL_ERRNO_SUCCESS) { if ((src == ICALL_SERVICE_CLASS_BLE) && (dest == selfEntity)) { // Process inter-task message. HeartRate_processStackMsg((ICall_Hdr *)pMsg); } if (pMsg) { ICall_freeMsg(pMsg); } } } // If RTOS queue is not empty, process app message. while (!Queue_empty(appMsgQueue)) { heartRateEvt_t *pMsg = (heartRateEvt_t*)Util_dequeueMsg(appMsgQueue); if (pMsg) { // Process message. HeartRate_processAppMsg(pMsg); // Free the space from the message. ICall_free(pMsg); } } // Heart rate service periodic task. if (events & HEARTRATE_MEAS_PERIODIC_EVT) { events &= ~HEARTRATE_MEAS_PERIODIC_EVT; HeartRate_measPerTask(); } // Battery service periodic task. if (events & HEARTRATE_BATT_PERIODIC_EVT) { events &= ~HEARTRATE_BATT_PERIODIC_EVT; HeartRate_battPerTask(); } } }
/******************************************************************************* * @fn userAppPro * * @brief user Application event process * * @param evnet * * @return none */ void userAppPro(void) { if (userEvents & USER_10MS_EVT) { userEvents &= ~USER_10MS_EVT; Util_startClock(&periodicClock_10ms); KEY_Scan_10ms(); ChangeTime10mSec(); Pollint100mSec(); } #ifdef INCLUDE_CLKSTOP while (!Queue_empty(keyMsgQueue)) { KEY_stEvt_t *pMsg = (KEY_stEvt_t *)Util_dequeueMsg(keyMsgQueue); if (pMsg) { // Process message. switch(pMsg->GPIOName) { case KEY_NAME_3V3: if (KEY_HIGH == pMsg->GPIOStatus) { wifiPowerOn(); uartWriteDebug("poweron3v3", 10); OLED_ShowString(40,32, "WiCore"); userAppShowCharge(); // 启动广播 { uint8_t initialAdvertEnable = TRUE; GAPRole_SetParameter(GAPROLE_ADVERT_ENABLED, sizeof(uint8_t), &initialAdvertEnable); } Util_startClock(&periodicClock_10ms); } else { wifiPowerDown(); uartWriteDebug("powerdown3v3", 12); // 清低电闪烁 systemState.lowBatteryFlag = 0; OLED_Clear(); // 这个执行时间较长 打乱了定时周期,所以stopClock是没有用的 //Util_stopClock(&periodicClock_10ms); // 服务器的按键开关机 设置一个按键放开标志位,等待1s后没有放开 // 就清标志位,关闭时钟 systemState.keyUpFlag = 3; // 2 为电源按键 等待按键放开标志,3为 服务器按键 systemState.delayCnt = 10; // 有链接,关闭 GAPRole_TerminateConnection(); } break; case KEY_POWER: if (KEY_IQR == pMsg->GPIOStatus) { KEY_DisableIRQ(); uartWriteDebug("tttt", 4); systemState.powerOffFlag = 1; systemState.delayPowerOffTime = 5; // 延时5s 判断是否是按键长按 Util_startClock(&periodicClock_10ms); } else if (KEY_LONG == pMsg->GPIOStatus) { if (1 == systemState.powerOffFlag) { systemState.powerOffFlag = 0; systemState.delayPowerOffTime = 0; wifiPowerOn(); userAppShowCharge(); OLED_ShowString(40,32, "WiCore"); // 启动广播 { uint8_t initialAdvertEnable = TRUE; GAPRole_SetParameter(GAPROLE_ADVERT_ENABLED, sizeof(uint8_t), &initialAdvertEnable); } uartWriteDebug("poweron", 7); } else { //系统断电 wifiPowerDown(); uartWriteDebug("powerdown", 9); OLED_Clear(); systemState.lowBatteryFlag = 0; // 清低电闪烁 systemState.keyUpFlag = 2; // 2 为电源按键 等待按键放开标志,3为 服务器按键 // 有链接,关闭 GAPRole_TerminateConnection(); } systemState.keyShortFlag = 0; // 忽略短按事件 } else if (KEY_LOW == pMsg->GPIOStatus)// 松开 { if (2 == systemState.keyUpFlag) // 长按松开,关机 { systemState.keyUpFlag = 0; //开启外部中断 KEY_EnableIRQ(); { // 关闭广播 uint8_t initialAdvertEnable = FALSE; GAPRole_SetParameter(GAPROLE_ADVERT_ENABLED, sizeof(uint8_t), &initialAdvertEnable); } Util_stopClock(&periodicClock_10ms); } else if (1 == systemState.keyShortFlag)// 短按松开 产生一次短按完整事件 { //短按事件处理 uartWriteDebug("短按", 4); } } else if (KEY_HIGH == pMsg->GPIOStatus) // 短按 { if (1 == systemState.powerOffFlag) // 等待长按事件 忽略此时的短按事件 { systemState.delayPowerOffTime = 5; // 防止timout 剩2s时又产生长按事件 } else { systemState.keyShortFlag = 1; } } break; default: break; } // Free the space from the message. ICall_free(pMsg); } } #else while (!Queue_empty(keyMsgQueue)) { KEY_stEvt_t *pMsg = (KEY_stEvt_t *)Util_dequeueMsg(keyMsgQueue); if (pMsg) { // Process message. switch(pMsg->GPIOName) { case KEY_NAME_3V3: if (KEY_HIGH == pMsg->GPIOStatus) { wifiPowerOn(); uartWriteDebug("poweron3v3", 10); OLED_ShowString(40,32, "WiCore"); userAppShowCharge(); // 启动广播 { uint8_t initialAdvertEnable = TRUE; GAPRole_SetParameter(GAPROLE_ADVERT_ENABLED, sizeof(uint8_t), &initialAdvertEnable); } systemState.powerOffFlag = 0; } else { wifiPowerDown(); uartWriteDebug("powerdown3v3", 12); // 清低电闪烁 systemState.lowBatteryFlag = 0; OLED_Clear(); // 这个执行时间较长 打乱了定时周期,所以stopClock是没有用的 // 有链接,关闭 GAPRole_TerminateConnection(); systemState.powerOffFlag = 1; } break; case KEY_POWER: if (KEY_LONG == pMsg->GPIOStatus) { if (1 == systemState.powerOffFlag) { systemState.powerOffFlag = 0; systemState.delayPowerOffTime = 0; systemState.keyUpFlag=0; wifiPowerOn(); userAppShowCharge(); OLED_ShowString(40,32, "WiCore"); // 启动广播 { uint8_t initialAdvertEnable = TRUE; GAPRole_SetParameter(GAPROLE_ADVERT_ENABLED, sizeof(uint8_t), &initialAdvertEnable); } uartWriteDebug("poweron", 7); } else { //系统断电 systemState.keyUpFlag=0; systemState.powerOffFlag = 1; wifiPowerDown(); uartWriteDebug("powerdown", 9); OLED_Clear(); systemState.lowBatteryFlag = 0; // 清低电闪烁 // 有链接,关闭 GAPRole_TerminateConnection(); } systemState.keyShortFlag = 0; // 忽略短按事件 } else if (KEY_LOW == pMsg->GPIOStatus)// 松开 { if (1 == systemState.keyShortFlag)// 短按松开 产生一次短按完整事件 { //短按事件处理 uartWriteDebug("短按", 4); systemState.keyShortFlag = 0; } } else if (KEY_HIGH == pMsg->GPIOStatus) // 短按 { if (1 == systemState.powerOffFlag) // 等待长按事件 忽略此时的短按事件 { // 关机中 不处理 } else { systemState.keyShortFlag = 1; } } break; default: break; } // Free the space from the message. ICall_free(pMsg); } } #endif }
/********************************************************************* * @fn trainingTag_taskFxn * * @brief Application task entry point for the Simple BLE Peripheral. * * @param a0, a1 - not used. * * @return None. */ static void trainingTag_taskFxn(UArg a0, UArg a1) { // Initialize application trainingTag_init(); // Application main loop for (;;) { // Waits for a signal to the semaphore associated with the calling thread. // Note that the semaphore associated with a thread is signaled when a // message is queued to the message receive queue of the thread or when // ICall_signal() function is called onto the semaphore. ICall_Errno errno = ICall_wait(ICALL_TIMEOUT_FOREVER); if (errno == ICALL_ERRNO_SUCCESS) { ICall_EntityID dest; ICall_ServiceEnum src; ICall_HciExtEvt *pMsg = NULL; if (ICall_fetchServiceMsg(&src, &dest, (void **)&pMsg) == ICALL_ERRNO_SUCCESS) { if ((src == ICALL_SERVICE_CLASS_BLE) && (dest == selfEntity)) { // Process inter-task message trainingTag_processStackMsg((ICall_Hdr *)pMsg); } if (pMsg) { ICall_freeMsg(pMsg); } } // If RTOS queue is not empty, process app message. if (!Queue_empty(appMsgQueue)) { tTagEvt_t *pMsg = (tTagEvt_t *)Util_dequeueMsg(appMsgQueue); if (pMsg) { // Process message. trainingTag_processAppMsg(pMsg); // Free the space from the message. ICall_free(pMsg); } } } if (events & TTG_PERIODIC_EVT) { events &= ~TTG_PERIODIC_EVT; Util_startClock(&periodicClock); // Perform periodic application task trainingTag_performPeriodicTask(); } } }
/********************************************************************* * @fn Thermometer_taskFxn * * @brief Thermometer Application Task entry point. This function * is called to initialize and then process all events for the task. * Events include timers, messages and any other user defined events. * * @param a0, a1 - not used. * * @return None. */ void Thermometer_taskFxn(UArg a0, UArg a1) { // Initialize the application. Thermometer_init(); // Application main loop. for (;;) { // Waits for a signal to the semaphore associated with the calling thread. // Note that the semaphore associated with a thread is signaled when a // message is queued to the message receive queue of the thread or when // ICall_signal() function is called onto the semaphore. ICall_Errno errno = ICall_wait(ICALL_TIMEOUT_FOREVER); if (errno == ICALL_ERRNO_SUCCESS) { ICall_EntityID dest; ICall_ServiceEnum src; ICall_HciExtEvt *pMsg = NULL; if (ICall_fetchServiceMsg(&src, &dest, (void **)&pMsg) == ICALL_ERRNO_SUCCESS) { if ((src == ICALL_SERVICE_CLASS_BLE) && (dest == selfEntity)) { // Process inter-task message. Thermometer_processStackMsg((ICall_Hdr *)pMsg); } if (pMsg) { ICall_freeMsg(pMsg); } } } // If RTOS queue is not empty, process app message. while (!Queue_empty(appMsgQueue)) { thermometerEvt_t *pMsg = (thermometerEvt_t*)Util_dequeueMsg(appMsgQueue); if (pMsg) { // Process message. Thermometer_processAppMsg(pMsg); // Free the space from the message. ICall_free(pMsg); } } if (events) { // Start discovery event. if (events & THERMOMETER_START_DISC_EVT) { events &= ~THERMOMETER_START_DISC_EVT; Thermometer_startDiscEvt(); } // Thermometer periodic measurement event. if (events & THERMOMETER_PERIODIC_MEAS_EVT) { events &= ~THERMOMETER_PERIODIC_MEAS_EVT; Thermometer_performPeriodicTask(); } // Thermometer periodic I-measurement event. if (events & THERMOMETER_PERIODIC_IMEAS_EVT) { events &= ~THERMOMETER_PERIODIC_IMEAS_EVT; Thermometer_performPeriodicImeasTask(); } // Disconnect event. if (events & THERMOMETER_DISCONNECT_EVT) { events &= ~THERMOMETER_DISCONNECT_EVT; Thermometer_disconnectEvt(); } } } }
/********************************************************************* * @fn SimplePropBeacon_taskFxn * * @brief Application task entry point for the Simple Proprietary Beacon. * * @param a0, a1 - not used. * * @return None. */ static void SimplePropBeacon_taskFxn(UArg a0, UArg a1) { // Initialize application SimplePropBeacon_init(); // Application main loop for (;;) { // Waits for a signal to the semaphore associated with the calling thread. // Note that the semaphore associated with a thread is signaled when a // message is queued to the message receive queue of the thread or when // ICall_signal() function is called onto the semaphore. ICall_Errno errno = ICall_wait(ICALL_TIMEOUT_FOREVER); if (errno == ICALL_ERRNO_SUCCESS) { ICall_EntityID dest; ICall_ServiceEnum src; ICall_HciExtEvt *pMsg = NULL; if (ICall_fetchServiceMsg(&src, &dest, (void **)&pMsg) == ICALL_ERRNO_SUCCESS) { uint8 safeToDealloc = TRUE; if ((src == ICALL_SERVICE_CLASS_BLE) && (dest == selfEntity)) { ICall_Stack_Event *pEvt = (ICall_Stack_Event *)pMsg; // Check for BLE stack events first if (pEvt->signature == 0xffff) { if (pEvt->event_flag & SPB_CONN_EVT_END_EVT) { // Try to retransmit pending ATT Response (if any) SimplePropBeacon_sendAttRsp(); } } else { // Process inter-task message safeToDealloc = SimplePropBeacon_processStackMsg((ICall_Hdr *)pMsg); } } if (pMsg && safeToDealloc) { ICall_freeMsg(pMsg); } } // If RTOS queue is not empty, process app message. while (!Queue_empty(appMsgQueue)) { spbEvt_t *pMsg = (spbEvt_t *)Util_dequeueMsg(appMsgQueue); if (pMsg) { // Process message. SimplePropBeacon_processAppMsg(pMsg); // Free the space from the message. ICall_free(pMsg); } } } #ifdef FEATURE_OAD while (!Queue_empty(hOadQ)) { oadTargetWrite_t *oadWriteEvt = Queue_dequeue(hOadQ); // Identify new image. if (oadWriteEvt->event == OAD_WRITE_IDENTIFY_REQ) { OAD_imgIdentifyWrite(oadWriteEvt->connHandle, oadWriteEvt->pData); } // Write a next block request. else if (oadWriteEvt->event == OAD_WRITE_BLOCK_REQ) { OAD_imgBlockWrite(oadWriteEvt->connHandle, oadWriteEvt->pData); } // Free buffer. ICall_free(oadWriteEvt); } #endif //FEATURE_OAD } }
/********************************************************************* * @fn RunningSensor_taskFxn * * @brief Running Application Task event processor. This function * is called to process all events for the task. Events * include timers, messages and any other user defined events. * * @param a0, a1 - not used. * * @return none */ void RunningSensor_taskFxn(UArg a0, UArg a1) { // Initialize the application. RunningSensor_init(); // Application main loop. for (;;) { // Waits for a signal to the semaphore associated with the calling thread. // Note that the semaphore associated with a thread is signaled when a // message is queued to the message receive queue of the thread or when // ICall_signal() function is called onto the semaphore. ICall_Errno errno = ICall_wait(ICALL_TIMEOUT_FOREVER); if (errno == ICALL_ERRNO_SUCCESS) { ICall_EntityID dest; ICall_ServiceEnum src; ICall_HciExtEvt *pMsg = NULL; if (ICall_fetchServiceMsg(&src, &dest, (void **)&pMsg) == ICALL_ERRNO_SUCCESS) { if ((src == ICALL_SERVICE_CLASS_BLE) && (dest == selfEntity)) { // Process inter-task message. RunningSensor_processStackMsg((ICall_Hdr *)pMsg); } if (pMsg) { ICall_freeMsg(pMsg); } } // If RTOS queue is not empty, process app message. while (!Queue_empty(appMsgQueue)) { rscEvt_t *pMsg = (rscEvt_t *)Util_dequeueMsg(appMsgQueue); if (pMsg) { // Process message. RunningSensor_processAppMsg(pMsg); // Free the space from the message. ICall_free(pMsg); } } } if (events) { // Running sensor periodic event. if (events & RSC_PERIODIC_EVT) { events &= ~RSC_PERIODIC_EVT; // Perform periodic sensor's periodic task. RunningSensor_periodicTask(); } // Parameter update event. if (events & RSC_CONN_PARAM_UPDATE_EVT) { events &= ~RSC_CONN_PARAM_UPDATE_EVT; // Send param update. If it fails, retry until successful. GAPRole_SendUpdateParam(DEFAULT_DESIRED_MIN_CONN_INTERVAL, DEFAULT_DESIRED_MAX_CONN_INTERVAL, DEFAULT_DESIRED_SLAVE_LATENCY, DEFAULT_DESIRED_CONN_TIMEOUT, GAPROLE_RESEND_PARAM_UPDATE); #if USING_NEGLECT_TIMEOUT // Assuming service discovery complete, start neglect timer. Util_startClock(&neglectClock); #endif //USING_NEGLECT_TIMEOUT } #if USING_NEGLECT_TIMEOUT // Neglect timer expired. if (events & RSC_NEGLECT_TIMEOUT_EVT) { events &= ~RSC_NEGLECT_TIMEOUT_EVT; // No user input, terminate connection. GAPRole_TerminateConnection(); } #endif //USING_NEGLECT_TIMEOUT // Soft reset event. if (events & RSC_RESET_EVT) { events &= ~RSC_RESET_EVT; RunningSensor_handleResetEvt(); } } } }