Other Parts Discussed in Thread: CC2640
Tool/software: Code Composer Studio
Running the simple_peripheral project in CC2640 LAUNCHPAD . When my android phone connecting with CC2640 , it will fail sometimes ,and CC2640 enters in "GAPROLE_WAITING" .Then CC2640 stops advertising . The probability of the above situation is about thirty percent . The probability is lower when using HUAWEI phone ,and is higher when using Xiaomi .
How to configure CC2640 to ensure the connecting success ?
1、my configuration of CC2640
(1)configure pair mode in SimpleBLEPeripheral_init(void)
// Setup the GAP Bond Manager. For more information see the section in the // User's Guide: // <a href="software-dl.ti.com/.../a> { // Don't send a pairing request after connecting; the peer device must // initiate pairing //uint8_t pairMode = GAPBOND_PAIRING_MODE_WAIT_FOR_REQ; uint8_t pairMode = GAPBOND_PAIRING_MODE_INITIATE; // Use authenticated pairing: require passcode. uint8_t mitm = TRUE; // This device only has display capabilities. Therefore, it will display the // passcode during pairing. However, since the default passcode is being // used, there is no need to display anything. uint8_t ioCap = GAPBOND_IO_CAP_DISPLAY_ONLY; //手机不显示密码,只有这个可用 // Request bonding (storing long-term keys for re-encryption upon subsequent // connections without repairing) uint8_t bonding = TRUE; GAPBondMgr_SetParameter(GAPBOND_PAIRING_MODE, sizeof(uint8_t), &pairMode); GAPBondMgr_SetParameter(GAPBOND_MITM_PROTECTION, sizeof(uint8_t), &mitm); GAPBondMgr_SetParameter(GAPBOND_IO_CAPABILITIES, sizeof(uint8_t), &ioCap); GAPBondMgr_SetParameter(GAPBOND_BONDING_ENABLED, sizeof(uint8_t), &bonding); }
(2)log print of “GAP_LINK_ESTABLISHED_EVENT” through UART
static void gapRole_processGAPMsg(gapEventHdr_t *pMsg) { ...... case GAP_LINK_ESTABLISHED_EVENT: { //fuheng UART_write(uart, "GAP_LINK_ESTABLISHED_EVENT\r\n", sizeof("GAP_LINK_ESTABLISHED_EVENT\r\n")); ...... } ...... }
(3)log print of “GAPROLE_WAITING” through UART
static void SimpleBLEPeripheral_processStateChangeEvt(gaprole_States_t newState) { ....... case GAPROLE_WAITING: Util_stopClock(&periodicClock); SimpleBLEPeripheral_freeAttRsp(bleNotConnected); Display_print0(dispHandle, 2, 0, "Disconnected"); UART_write(uart, "GAPROLE_WAITING\r\n", sizeof("GAPROLE_WAITING\r\n")); ...... }
2、my steps of connecting
(1)Running the simple_peripheral project in CC2640 LAUNCHPAD .Serial port assistant shows CC2640 is advertising , as shown in picture 1 .
picture 1
(2)Scaning CC2640 in BLE SCANNER on android phone , as shown in picture 2.
picture 2
(3)press the "CONNECT " button . However , serial port assistant shows connecting fail , as shown in picture 1.
(4)CC2640 enters in "GAPROLE_WAITING" .Then CC2640 stops advertising , as shown in picture 1.
3、analysis of packet sniffer
(1)using packet sniffer , several packets about “Scan request / response” has been captured , as shown in picture 3 .
picture 3
(2)several packets about "FCS = ERROR" has been captured , as shown in picture 4 . No packets about “Connection establishment” has been captured .
picture 4
(3)according to the "BLE sniffer guide ", packets about “Connection establishment” can be captured , as shown in picture 5.
picture 5
(4)the packet sniffer when conneting failed can be downloade from attachments, which is named in " 02_fail_pairing.psd ".
(5)the packet sniffer when conneting successed can be downloade from attachments, which is named in "14hornorV8-sucess.psd ".
4、attachments
(1)path of simple_peripheral project on my computer:
C:\ti\simplelink_cc2640r2_sdk_1_40_00_45\examples\rtos\CC2640R2_LAUNCHXL\blestack\simple_peripheral
(2)The packet sniffer named in " 02_fail_pairing.psd " can be downloaded here:
(3)The packet sniffer named in "14hornorV8-sucess.psd " can be downloaded here:
(4)《core_V5.0.pdf》can be downloaded here:
www.bluetooth.com/.../bluetooth-core-specification
(5)simplelink_cc2640r2_sdk_1_40_00_45 can be downloaded here::
dev.ti.com/.../
(6)CC2640R2 launchpad can be bought here:
www.ti.com/.../launchxl-cc2640r2
(7)"BLE sniffer guide " can be downloaded here::
processors.wiki.ti.com/.../BLE_sniffer_guide
(8)soure code of my workspace can be downloaded here:
5、my developing environment
CCS:Code Composer Studio 7.2.0
SDK:simplelink_cc2640r2_sdk_1_40_00_45
hardware:CC26640R2 launchpad develop kit
VS: Microsoft Visual C++ 2010 Express
OS:win7 64 bit
Serial assistant: sscom5.13.1.exe
android phone:hornor V8 (android 7.0)