Hello,
I'm working on on a KW45 based board, I'm working on BLE ADV, I want to test if a scan request is reveived, then I will send the ADV data with the scan response, but i could not find a way to check if a scan request is received or not, here is my code :
typedef struct advState_tag{
bool_t advOn;
}advState_t;
/* Adv State */
static advState_t mAdvState;
/*! *********************************************************************************
* \brief Handles BLE Advertising callback from host stack.
*
* \param[in] pAdvertisingEvent Pointer to gapAdvertisingEvent_t.
********************************************************************************** */
static void BleApp_AdvertisingCallback (gapAdvertisingEvent_t* pAdvertisingEvent)
{
switch (pAdvertisingEvent->eventType)
{
case gAdvertisingStateChanged_c:
{
mAdvState.advOn = !mAdvState.advOn;
if(mAdvState.advOn)
{
}
else
{
}
}
break;
case gAdvertisingCommandFailed_c:
{
}
break;
default:
{
; /* For MISRA Compliance */
}
break;
}
}
static void vBleSensitivityMeasurement( uint32_t channelId )
{
/* Set New Lowpower Constraint on Advertising start request */
( void )PWR_SetLowPowerModeConstraint(PWR_WFI);
/** (!) */
OSA_vidTaskSleep(10);
Controller_SetTxPowerLevel(ADV_POWER_DBM, channelId);
/*LED ON*/
GPIO_PinWrite(DIAG_LED_GPIO, DIAG_LED_PIN, DIAG_LED_ON);
BluetoothLEHost_StartAdvertising(&RADIATION_strAdvertisingData, BleApp_AdvertisingCallback, NULL);
OSA_vidTaskSleep(ADV_DURATION_MS); // TODO change 3000 with ADV_DURATION_MS
Gap_StopAdvertising();
GPIO_PinWrite(DIAG_LED_GPIO, DIAG_LED_PIN, DIAG_LED_OFF);
// Wait for the tester's response
bool scanRequestReceived = true;// WaitForScanRequest(); // TODO Implement this function
if (scanRequestReceived) {
// Scan request received
// Turn off the LED and send a SCAN Response
GPIO_PinWrite(DIAG_LED_GPIO, DIAG_LED_PIN, DIAG_LED_OFF);
// BluetoothLEHost_SendScanResponse(/* scan response data */);
} else {
// Scan request not received
// Light the LED for 500ms
GPIO_PinWrite(DIAG_LED_GPIO, DIAG_LED_PIN, DIAG_LED_ON);
OSA_vidTaskSleep(500);
}