We are working on custom boards with a CC2540 SOC. We paired CC2540 Keyfob from CC2540 usb dongle board, and we programmed usb dongle with CC2540_USBdongle_HostTestRelease_All.hex and Keyfob with CC2540_SmartRF_SimpleBLEPeripheral.hex. Using this approach, we are able to scan, connect and pair both the device successfully by using BTool.exe.
We tried the same setup with our Custom Board and CC2540 usb dongle, and with this we are able to scan and find our Custom Device from the USB dongle. however, when we try to establish a link between USB Dongle and Custom Board, the BTool.exe application displays the device info for a fraction of second and it disappears, so we are not able to go to next step, 'pairing'.
int main(void)
{
/* Initialize hardware */
HAL_BOARD_INIT();
// Initialize board I/O
InitBoard( OB_COLD );
/* Initialze the HAL driver */
HalDriverInit();
/* Initialize NV system */
osal_snv_init();
/* Initialize LL */
/* Initialize the operating system */
osal_init_system();
/* Enable interrupts */
HAL_ENABLE_INTERRUPTS();
// Final board initialization
InitBoard( OB_READY );
#if defined ( POWER_SAVING )
//osal_pwrmgr_device( PWRMGR_BATTERY );
osal_pwrmgr_device( PWRMGR_ALWAYS_ON );
#endif
simpleBLEScanning = TRUE;
simpleBLEScanRes = 0;
uint8 addrType;
uint8 *peerAddr;
GAPCentralRole_StartDiscovery( DEFAULT_DISCOVERY_MODE,
DEFAULT_DISCOVERY_ACTIVE_SCAN,
DEFAULT_DISCOVERY_WHITE_LIST );
if ( simpleBLEScanRes > 0 )
{
// connect to current device in scan result
peerAddr = simpleBLEDevList[simpleBLEScanIdx].addr;
addrType = simpleBLEDevList[simpleBLEScanIdx].addrType;
simpleBLEState = 1;//BLE_STATE_CONNECTING;
GAPCentralRole_EstablishLink( DEFAULT_LINK_HIGH_DUTY_CYCLE,
DEFAULT_LINK_WHITE_LIST,
addrType, peerAddr );
}
#endif
/* Start OSAL */
osal_start_system(); // No Return from here
return 0;
}
case GAPROLE_ADVERT_DATA:
if ( len <= B_MAX_ADV_LEN )
{VOID osal_memset( gapRole_AdvertData, 0, B_MAX_ADV_LEN );
VOID osal_memcpy( gapRole_AdvertData, pValue, len ) ;
// Update the advertising data
GAP_UpdateAdvertisingData( gapRole_TaskID,TRUE, B_MAX_ADV_LEN, gapRole_AdvertData );