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/OInitBoard( 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 initializationInitBoard( 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 resultpeerAddr = 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;}
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 );
Hi Timothy,
The structure of your code is a long way from working.
The CC2540 is a single threaded processor, and the TI stack and app run using a non pre-emptive OS (i.e. a prioritized task loop).
You should not be putting any code inside main.c - it should all run inside your app task. Your task should not block for more than a few ms when you are using the BLE interface.
Also, you cannot expect GAPCentralRole_StartDiscovery() to provide valid results on the very next line of code. The stack needs to process for several seconds and will trigger an event once it is complete.
You will need to read the software developers guide and read through the example code and understand how the examples work before modifying. The API is also an essential document here.