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.

Compiler/CC2541: BLE Scan Issue

Part Number: CC2541
Other Parts Discussed in Thread: CC2540

Tool/software: TI C/C++ Compiler

Hello, 
I am using cc2541 as central. I am facing these issue:

1-I am scanning devices, I have 6 cc2541 BLE and 1 BLE 4.2 Chip(Don't know chip number)  in scanning result i found 6 (BLE cc2541) devices but unable to scan remaining BLE 4.2. How can i scan all devices?

2-I also want to connect another device. I am using this APIs. Is this correct way to save MAC address of other device and connect?

uint8 addrType;

uint8 *peerAddr;

peerAddr = "0x78DB2FD19591"; 

addrType = simpleBLEDevList[simpleBLEScanIdx].addrType;
simpleBLEState = BLE_STATE_CONNECTING;

GAPCentralRole_EstablishLink( DEFAULT_LINK_HIGH_DUTY_CYCLE,
DEFAULT_LINK_WHITE_LIST,
addrType, peerAddr );

Thank you 

  • Hi,

    If I remember correctly, there is a filtering of specific devices based on the advertisement data, i.e. simplified UUID. There should be a define you can set to FALSE in the top of the simple central application file.

  • Thanks  For 1st problem.
    Kindly suggest solution for 2nd issue.

  • If you hardcode the address, you should hardcode the addrType as well. However, you should only hardcode for test purposes. The Central should really scan for devices and then check if you find the address you are looking for.

  • Hi ,

    I have set this FALSE but still unable to scan device :(

    // TRUE to filter discovery results on desired service UUID
    #define DEFAULT_DEV_DISC_BY_SVC_UUID FALSE

  • What response do you get when scanning? Are you sure the device is advertising?

  • My device is advertising and i can see my device in nRF app also but unable to see in IAR(Showing 0 device found)


  • What is the scan duration?

  • Scan Duration is 3000msec

    // Scan duration in ms
    #define DEFAULT_SCAN_DURATION 3000

  • You might want to try a longer duration, What is the advertising intervals of the peripheral devices?

  • I have set these settings.

    // Maximum number of scan responses
    #define DEFAULT_MAX_SCAN_RES 8

    // Scan duration in ms
    #define DEFAULT_SCAN_DURATION 5000

    // Discovey mode (limited, general, all)
    #define DEFAULT_DISCOVERY_MODE DEVDISC_MODE_ALL

    // TRUE to use active scan
    #define DEFAULT_DISCOVERY_ACTIVE_SCAN TRUE

    // TRUE to use white list during discovery
    #define DEFAULT_DISCOVERY_WHITE_LIST FALSE

    // TRUE to use high scan duty cycle when creating link
    #define DEFAULT_LINK_HIGH_DUTY_CYCLE FALSE

    // TRUE to use white list when creating link
    #define DEFAULT_LINK_WHITE_LIST FALSE

    // Default RSSI polling period in ms
    #define DEFAULT_RSSI_PERIOD 1000

    // Whether to enable automatic parameter update request when a connection is formed
    #define DEFAULT_ENABLE_UPDATE_REQUEST FALSE

    // Minimum connection interval (units of 1.25ms) if automatic parameter update request is enabled
    #define DEFAULT_UPDATE_MIN_CONN_INTERVAL 400

    // Maximum connection interval (units of 1.25ms) if automatic parameter update request is enabled
    #define DEFAULT_UPDATE_MAX_CONN_INTERVAL 800

    // Slave latency to use if automatic parameter update request is enabled
    #define DEFAULT_UPDATE_SLAVE_LATENCY 0

    // Supervision timeout value (units of 10ms) if automatic parameter update request is enabled
    #define DEFAULT_UPDATE_CONN_TIMEOUT 600

    // Default passcode
    #define DEFAULT_PASSCODE 0 //19655

    // Default GAP pairing mode
    #define DEFAULT_PAIRING_MODE GAPBOND_PAIRING_MODE_NO_PAIRING //GAPBOND_PAIRING_MODE_WAIT_FOR_REQ

    // Default MITM mode (TRUE to require passcode or OOB when pairing)
    #define DEFAULT_MITM_MODE FALSE

    // Default bonding mode, TRUE to bond
    #define DEFAULT_BONDING_MODE TRUE

    // Default GAP bonding I/O capabilities
    #define DEFAULT_IO_CAPABILITIES GAPBOND_IO_CAP_DISPLAY_ONLY

    // Default service discovery timer delay in ms
    #define DEFAULT_SVC_DISCOVERY_DELAY 1000

    // TRUE to filter discovery results on desired service UUID
    #define DEFAULT_DEV_DISC_BY_SVC_UUID FALSE



  • Hi,

    Thats configuration mostly for a GAP Central. I was asking for the GAP Peripheral, such as advertising interval.

  • I can't see advertising interval of Peripheral device as in nRF app. It showing N/A.

  • I have also another ibeacon device with advertising interval of 546.25 milliseconds. My central device also not scanning that device. 

  • When i set this DEFAULT_DEV_DISC_BY_SVC_UUID as FLASE. BLE stop scanning all devices and show 0 results.

    // TRUE to filter discovery results on desired service UUID
    #define DEFAULT_DEV_DISC_BY_SVC_UUID FLASE

  • Hi,

    I suppose you mean "FALSE". When I define DEFAULT_DEV_DISC_BY_SVC_UUID FALSE, I can scan for other devices.

  • Hi,

    When i define FAULT_DEV_DISC_BY_SVC_UUID TRUE   I can scan other cc2541 devices.
    But 
    When i FAULT_DEV_DISC_BY_SVC_UUID FALSE i can't scan any device(even cc2541 devices)

  • Hi,

    I cannot reproduce your claim so I am not sure what is going on. Are you sure that;

    1. Central is scanning

    2. Peripheral is advertising

  • Hi ,

    1. Central is scanning?

    Yes, I am sure Central is scanning. I have turn ON 3 peripheral (2 cc2541+1 another BLE device). I am attaching screen shot of that scanning.Below image is when 

    // TRUE to filter discovery results on desired service UUID
    #define DEFAULT_DEV_DISC_BY_SVC_UUID TRUE

    In this case Central scan only 2 BLE devices(cc2541 only).Shown in screen shot.  


    // TRUE to filter discovery results on desired service UUID
    #define DEFAULT_DEV_DISC_BY_SVC_UUID FALSE

    In this case Central scan 0 BLE devices.Shown in screen shot.

    2. Peripheral is advertising?

    Yes, All 3 peripheral devices are advertising. I have check in nRF app show in image


    Kindly suggest me solution so i can scan all 3 devices.

  • Hi
    Kindly any suggestion ?

  • Hi ,

    I have set these values but still unable to scan device :(

    1-

    // TRUE to filter discovery results on desired service UUID

    #define DEFAULT_DEV_DISC_BY_SVC_UUID FALSE

    2-

    // Setup GAP
    GAP_SetParamValue( TGAP_GEN_DISC_SCAN_INT, 16);
    GAP_SetParamValue( TGAP_GEN_DISC_SCAN_WIND, 16);

    3-

    HCI_EXT_HaltDuringRfCmd(HCI_EXT_HALT_DURING_RF_DISABLE);

  • TGAP_GEN_DISC_SCAN_INT is in unit of (n * 0.625 mSec).

    Try larger values, for example 160 (100 ms).

  • i have set TGAP_GEN_DISC_SCAN_INT 1000 but still unable to scan device (i can scan in nRF).

    I am setting these setting kindly check these setting either i am making mistake in these settings.


    // Length of bd addr as a string
    #define B_ADDR_STR_LEN 15

    /*********************************************************************
    * CONSTANTS
    */

    // Maximum number of scan responses
    #define DEFAULT_MAX_SCAN_RES 8

    // Scan duration in ms
    #define DEFAULT_SCAN_DURATION 10000

    // Discovey mode (limited, general, all)
    #define DEFAULT_DISCOVERY_MODE DEVDISC_MODE_ALL

    // TRUE to use active scan
    #define DEFAULT_DISCOVERY_ACTIVE_SCAN TRUE

    // TRUE to use white list during discovery
    #define DEFAULT_DISCOVERY_WHITE_LIST FALSE

    // TRUE to use high scan duty cycle when creating link
    #define DEFAULT_LINK_HIGH_DUTY_CYCLE FALSE

    // TRUE to use white list when creating link
    #define DEFAULT_LINK_WHITE_LIST FALSE

    // Default RSSI polling period in ms
    #define DEFAULT_RSSI_PERIOD 1000

    // Whether to enable automatic parameter update request when a connection is formed
    #define DEFAULT_ENABLE_UPDATE_REQUEST FALSE

    // Minimum connection interval (units of 1.25ms) if automatic parameter update request is enabled
    #define DEFAULT_UPDATE_MIN_CONN_INTERVAL 400

    // Maximum connection interval (units of 1.25ms) if automatic parameter update request is enabled
    #define DEFAULT_UPDATE_MAX_CONN_INTERVAL 800

    // Slave latency to use if automatic parameter update request is enabled
    #define DEFAULT_UPDATE_SLAVE_LATENCY 0

    // Supervision timeout value (units of 10ms) if automatic parameter update request is enabled
    #define DEFAULT_UPDATE_CONN_TIMEOUT 600

    // Default passcode
    #define DEFAULT_PASSCODE 0 //19655

    // Default GAP pairing mode
    #define DEFAULT_PAIRING_MODE GAPBOND_PAIRING_MODE_NO_PAIRING //GAPBOND_PAIRING_MODE_WAIT_FOR_REQ

    // Default MITM mode (TRUE to require passcode or OOB when pairing)
    #define DEFAULT_MITM_MODE FALSE

    // Default bonding mode, TRUE to bond
    #define DEFAULT_BONDING_MODE TRUE

    // Default GAP bonding I/O capabilities
    #define DEFAULT_IO_CAPABILITIES GAPBOND_IO_CAP_DISPLAY_ONLY

    // Default service discovery timer delay in ms
    #define DEFAULT_SVC_DISCOVERY_DELAY 1000

    // TRUE to filter discovery results on desired service UUID
    #define DEFAULT_DEV_DISC_BY_SVC_UUID FALSE

  • It looks ok.

    What HW are you using?

    Do you use the latest sdk? (v1.5.0)

  • I am using 1.4.2.

  • please try the latest.

  • I have update the stack (1.5.0.16).

    I have 2 BLE powered On(1 BLE,1 iBeacon).But still unable to scan these devices. Am I forgetting any core settings?

    // TRUE to filter discovery results on desired service UUID
    #define DEFAULT_DEV_DISC_BY_SVC_UUID FALSE

    // Setup GAP
    GAP_SetParamValue( TGAP_GEN_DISC_SCAN_INT, 16);
    GAP_SetParamValue( TGAP_GEN_DISC_SCAN_WIND, 16);
    GAP_SetParamValue( TGAP_GEN_DISC_SCAN, DEFAULT_SCAN_DURATION );
    // GAP_SetParamValue( TGAP_LIM_DISC_SCAN, DEFAULT_SCAN_DURATION );
    GGS_SetParameter( GGS_DEVICE_NAME_ATT, GAP_DEVICE_NAME_LEN, (uint8 *) simpleBLEDeviceName );

  • Hi  ,
    Any suggestion Please.

  • Hello Muqarrab,

    I tested the simpleBLECentral example from BLE-CC254x-1.5.0.16 on a SmartRF05EB+CC2541EM with IAR 10.30.1.

    It seems to work well to scan what is in the area, although I don't have a iBeacon device to scan here, but it should be the same as only the payload is different from a regular advertiser.

    I only changed the following:

    #define DEFAULT_DEV_DISC_BY_SVC_UUID          FALSE

  • Hi ,
    Are you able to scan other cc2541 devices after setting "#define DEFAULT_DEV_DISC_BY_SVC_UUID       FALSE" if yes,then kindly upload your project and send me link. I will b very grateful to you. Because whenever i set "#define DEFAULT_DEV_DISC_BY_SVC_UUID       FALSE" my found devices results is "0".
    It is very urgent for me to scan all devices. Thank you

  • I used the example directly from the SDK. Yes i set DEFAULT_DEV_DISC_BY_SVC_UUID to false.

    I ran it on EM+EB:

    http://www.ti.com/tool/CC2541EMK

    http://www.ti.com/lit/ug/swru210a/swru210a.pdf

    You can try to reinstall the SDK.

  • I am trying but still unable to scan device. :(
    Can i use SimpleBLEObserver to scan all devices?

  • Hi ,
    I have cc2540. Using cc2540 I have successfully scan the device. :)
    But for same project in cc2541 using cc2541 i can't able to scan device?
    is there any setting for cc2541?

  • That is odd. There are some minor differences, but that's why there are different example projects for CC2540 and CC2541. On application level there should not be any difference. Have you tried different CC2541 devices?

  • Yes i have tried on 3 other cc2541.But when i comment this part  in SimpleBLECentral_Init cc2541 also start scanning devices.

    P0SEL = 0; // Configure Port 0 as GPIO
    P1SEL = 0; // Configure Port 1 as GPIO
    P2SEL = 0; // Configure Port 2 as GPIO

    P0DIR = 0xFF; 
    P1DIR = 0x13; 
    P2DIR = 0x1F;

    P0 = 0; 
    P1 = 0xE6; 
    P2 = 0;

    In cc2541 and cc2540 if i decalair these settings in SimpleBLECentral_Init cc2540 also give 0 scan result.

    P0SEL = 0; // Configure Port 0 as GPIO
    P1SEL = 0; // Configure Port 1 as GPIO
    P2SEL = 0; // Configure Port 2 as GPIO

    P0DIR = 0xFF;
    P1DIR = 0x13;
    P2DIR = 0x1F;

    P0 = 0;
    P1 = 0xE6;
    P2 = 0;

    What is this issue?

  • How can i enable broadcasting in central?

  • Which HW are you running on?

    You should set a breakpoint in simpleBLECentralEventCB -> case GAP_DEVICE_INFO_EVENT while running in debug mode to verify if you are receiving advertisements.

    So it works if you do not configure the IO manually?