Hello,
I am new to QN908x BLE environment.
I am using HID device example code from SDK_2.x_QN908XCDK.
By default, the device will be in IDLE mode and as Switch is pressed, its starts Advertising.
I am not able to get how exactly Switch pressed event is triggering Advertising.
Can someone help me with the event.
I did not want Switch pressed event to trigger advertising.
I want as soon as the development kit is supplied power, it must start Advertising.
I have debugged the code was not able to get the exactly where it gets triggered.
解決済! 解決策の投稿を見る。
Hello,
I used the heart rate sensor so I can try to explain the idea. Just perform the following change and it will start advertising
void BleApp_GenericCallback (gapGenericEvent_t* pGenericEvent)
{
/* Call BLE Conn Manager */
BleConnManager_GenericEvent(pGenericEvent);
switch (pGenericEvent->eventType)
{
case gInitializationComplete_c:
{
BleApp_Config();
BleApp_Start();
}
break;
case gAdvertisingParametersSetupComplete_c:
{
App_StartAdvertising(BleApp_AdvertisingCallback, BleApp_ConnectionCallback);
}
break;
default:
break;
}
}
Consider that you will need to modify the keyboard callback to perform your desired functionality with the buttons. If you check there, the start of the advertisement will start automatically
Regards,
Estephania
Hello,
If you check the hid_host.c file, you will see the BleApp_HandleKeys
void BleApp_HandleKeys(key_event_t events)
{
switch (events)
{
case gKBD_EventPressPB1_c:
{
BleApp_Start();
break;
}
case gKBD_EventLongPB1_c:
{
for (uint8_t i = 0; i < gAppMaxConnections_c; i++)
{
if (mPeerInformation[i].deviceId != gInvalidDeviceId_c)
Gap_Disconnect(mPeerInformation[i].deviceId);
}
break;
}
case gKBD_EventPressPB2_c:
case gKBD_EventLongPB2_c:
default:
break;
}
}
The function you are looking for its BleApp_Start()
Regards,
Estephania
Thanks Estephania for the response,
But, I am using HID Device example code.
I have already modified "hid_device.c" source file and tried those modifications.
But, then also I am not able to start advertising .
Modification code:
I have removed the parameter passed also to make it independent of Event:
void BleApp_HandleKeys(){
BleApp_Start();
}
But, it doesn't start Advertising without switch pressed event.
Do let me know if this is correct?
Did I missed something?
Hello,
You are placing it in the incorrect function, in your current code the event it's being set when a key (button) it's being pressed, so when a button gets pushed it will start the advertisement.
You will need to place the start the advertisements before it starts the idle task.
Regards,
Estephania
Thanks Estephania for the clarification.
But, in KeyScan callback also, I am just calling "mpfKeyFunction();" and commented all the other cod ein that function which is Switch case statement.
Does this makes sense?
Hello,
Again you are depending on the switch pressing to make this work. You are relying on the keyboard callback.
Regards,
Estephania
Hi Estephania,
Yes you are correct, it gets called in keyboard callback.
But, I have gone through many example code and they are doing it the same way.
How, to make that independent of callback.
Because of callback only, I think after I disconnect the device, its starts advertising again.
Hello,
But you are not trying to what they do in the example, in the different examples they use a key pressed to start the advertisement, which it's not what you are trying to achieve, you want to start the process without any key pressed, is it ?
Regards,
Estephania
Correct, I want Advertising to be independent of Key press.
To attain that I have modified code which is independent of key press.
But as previously pointed out by you, it is getting called in keyboard callback.
That's not the correct way of doing it, correct?
Thanks Estephania,
I tried this before also, but was not able to make it work.
But, today I tried with new example source code and its working as per my requirement.
Thanks
Hello,
I used the heart rate sensor so I can try to explain the idea. Just perform the following change and it will start advertising
void BleApp_GenericCallback (gapGenericEvent_t* pGenericEvent)
{
/* Call BLE Conn Manager */
BleConnManager_GenericEvent(pGenericEvent);
switch (pGenericEvent->eventType)
{
case gInitializationComplete_c:
{
BleApp_Config();
BleApp_Start();
}
break;
case gAdvertisingParametersSetupComplete_c:
{
App_StartAdvertising(BleApp_AdvertisingCallback, BleApp_ConnectionCallback);
}
break;
default:
break;
}
}
Consider that you will need to modify the keyboard callback to perform your desired functionality with the buttons. If you check there, the start of the advertisement will start automatically
Regards,
Estephania
I am using Bare Metal - HID Device example code.
Anyone from NXP Technical team, can you help me to figure out how to disable the switch event for BLE advertising.
This makes it advertising irrespective of Switch event.
In Keyboard.c file:
Comment the following lines:
for( i=0; i<gKBD_KeysCount_c; i++ )
// {
// if(kbdSwButtons[i].swType == gKBDTypeGpio_c)
// {
// GpioInstallIsr( Switch_Press_ISR, gGpioIsrPrioLow_c, gKeyboard_IsrPrio_c, kbdSwButtons[i].config_struct.pSwGpio);
// }
// }
and start timer:
TMR_StartIntervalTimer(mKeyScanTimerID, gKeyScanInterval_c, (pfTmrCallBack_t)KeyScan, (void*)((uint32_t)mKeyScanTimerID));
This makes it advertising irrespective of Switch event.