There is possible to set your CC254X be scanable when it is in connection. But, based on my test,
the connecting would be sluggish if you modify the code as below steps:
0. Check your BLE stack being 1.3.2 , if that is not, I apologize. if it is, Backup the file : TiBLEStackInstallationFolder\BLE-CC254x-1.3.2\Projects\ble\Profiles\Roles\peripheralBroadcaster.c.
1. Substitute the file peripheral.c as peripheralBroadcaster.c in your IAR project. That is, enable PLUS_BROADCASTER macro in preprocessor define, exclude peripheral.c, and include peripheralBroadcaster.c in your project.
Open the peripheralBroadcaster.c, it should be modified.
2. for line 45 : add the line :
#include "hci_tl.h"
:
#include "hci.h"
#include "hci_tl.h"
#include "l2cap.h"
:
it is for passing compilation.
3. For line 641, change the line :
// Initialize the Profile Advertising and Connection Parameters
gapRole_profileRole = GAP_PROFILE_PERIPHERAL;
As :
#if(1) //GAIGER
gapRole_profileRole = GAP_PROFILE_PERIPHERAL;
#else
gapRole_profileRole = (GAP_PROFILE_PERIPHERAL | GAP_PROFILE_BROADCASTER);
#endif
The peripheral could advertise now.
3. At the line 927 :
// Since gapRole_AdvertOffTime is set to 0, the device should not
// automatically become discoverable again after a period of time.
// Set enabler to FALSE; device will become discoverable again when
// this value gets set to TRUE
gapRole_AdvEnabled = FALSE;
Modify it as :
// Since gapRole_AdvertOffTime is set to 0, the device should not
// automatically become discoverable again after a period of time.
// Set enabler to FALSE; device will become discoverable again when
// this value gets set to TRUE
#if(0) //GAIGER
gapRole_AdvEnabled = FALSE;
#else
osal_start_timerEx( gapRole_TaskID, START_ADVERTISING_EVT, 1000);
#endif
The device would keep advertising which it is connected.
4. For the line 937 :
// Check whether update parameter request is enabled, and check the connection parameters
if ( ( gapRole_ParamUpdateEnable == TRUE ) &&
( (pPkt->connInterval < gapRole_MinConnInterval) ||
(pPkt->connInterval > gapRole_MaxConnInterval) ||
(pPkt->connLatency != gapRole_SlaveLatency) ||
(pPkt->connTimeout != gapRole_TimeoutMultiplier) ))
{
gapRole_SendUpdateParam( pPkt->connInterval, pPkt->connLatency );
}
// Notify the Bond Manager to the connection
VOID GAPBondMgr_LinkEst( pPkt->devAddrType, pPkt->devAddr, pPkt->connectionHandle, GAP_PROFILE_PERIPHERAL );
There should be insert a line for resuming advertise after disconnection event occuring:
// Check whether update parameter request is enabled, and check the connection parameters
if ( ( gapRole_ParamUpdateEnable == TRUE ) &&
( (pPkt->connInterval < gapRole_MinConnInterval) ||
(pPkt->connInterval > gapRole_MaxConnInterval) ||
(pPkt->connLatency != gapRole_SlaveLatency) ||
(pPkt->connTimeout != gapRole_TimeoutMultiplier) ))
{
gapRole_SendUpdateParam( pPkt->connInterval, pPkt->connLatency );
}
#if(1) //GAIGER
VOID osal_set_event( gapRole_TaskID, START_ADVERTISING_EVT );
#endif
// Notify the Bond Manager to the connection
VOID GAPBondMgr_LinkEst( pPkt->devAddrType, pPkt->devAddr, pPkt->connectionHandle, GAP_PROFILE_PERIPHERAL );
It is all, now the goal has been reached. Your cc 254x could keep advertising while it is on connection.
I noet agagin, that would lead your peripheral be slow on connecting: it costs 5~8 seconds to discover services by using BLE scaner on my Sony Xperia Z3 compact, but for pure peripheral, it costs 1 second only at worst case.
This method is refered from Texas forum threads:
https://e2e.ti.com/support/wireless_connectivity/f/538/t/197769
http://www.deyisupport.com/question_answer/wireless_connectivity/bluetooth/f/103/t/88540.aspx?keyMatch=gaiger&tisearch=Search-CN-Everything