This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

scanning and pairing of CC2540 Custom Boards

Other Parts Discussed in Thread: CC2540
We are having trouble Discovering our custom boards. We are able to make our custom board as well as Keyfob in discovered mode as default.  Also we are able to scan, pair and connect the keyfob with USB dongle by using BTool. We can also scan our custom board from USB Dongle with BTool, but unfortunately we are not able to pair the custom board from USB dongle. 

Below are the tests that we've done and the problems that we are facing:

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 approachwe 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'.

We also tried to scan and pair the custom devices to each other. We programmed one board with SerialApp project and other with SerialAppCentral and tried to scan the one from the other, the modification that we made in the code is
In serialAppCentral_Main.c from SerialAppCentral project is as follows

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;
}

We added the lines that shows in bold Italics. Once we starts to debug the code we found that it is not able to scan the other BLE module, simpleBLEScanRes shows Zero.

To make the Custom Board in Discovered mode, we modified SerialApp Project as follows.
In SerialApp Project, serialAppPeripheral.c file, within the function SimpleBLEPeripheral_Init()

We changed uint16 gapRole_AdvertOffTime = 1 from 0

Also,
added  GAP_UpdateAdvertisingData() in the function GAPRole_SetParameter() in peripheral.c :

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 );
we would like to know that whether we are going in right way? or is there any alternate approach to do the pairing of our custom board with Each other?

Thanks and Regards
  • 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.