如题:BlueNRG蓝牙开发,连接自动断开.....现在怀疑是自己的spi有问题,但是又能进行其他设置?玩过BlueNRG的给点意见!?
具体连接过程如下:
<p>SdkEvalSpiInit end
BlueNRG_RST
interrupt
spi Read come back:
02 7F 00 00 00
spi Read come back:
02 7F 00 06 00
04 FF 03 01 00 01 </p><p>......................................................................
Write DATA:
data1:<01 0C FC 08 >
data2:<00 06 FF 00 00 E1 80 02 >
Read DATA:
spi Read come back:
02 7F 00 07 00
04 0E 04 01 0C FC 00
Setting BD_ADDR Success.</p><p>......................................................................
Write DATA:
data1:<01 01 FD 00 >
data2:<>
spi Read come back:
02 7F 00 07 00
04 0E 04 01 01 FD 00
GATT_Init success</p><p>......................................................................
Write DATA:
data1:<01 8A FC 01 >
data2:<01 >
Read DATA:
spi Read come back:
02 7F 00 0D 00
04 0E 0A 01 8A FC 00 05 00 06 00 08 00
GAP_Init success.</p><p>......................................................................
Write DATA:
data1:<01 86 FC 1A >
data2:<01 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 07 10 00 40 E2 01 00 01 >
spi Read come back:
02 7F 00 07 00
04 0E 04 01 86 FC 00
BLE Stack Initialized.
SERVER: BLE Stack Initialized (platform:linux)</p><p>........................................................................
Write DATA:
data1:<01 02 FD 13 >
data2:<02 66 9A 0C 20 00 08 96 9E E2 11 9E B1 E0 F2 73 D9 01 07 >
Read DATA:
spi Read come back:
02 7F 00 09 00
04 0E 06 01 02 FD 00 10 00
........................................................................
Write DATA:
data1:<01 04 FD 19 >
data2:<10 00 02 66 9A 0C 20 00 08 96 9E E2 11 9E B1 E1 F2 73 D9 14 10 00 00 10 01 >
Read DATA:
spi Read come back:
02 7F 00 09 00
04 0E 06 01 04 FD 00 11 00 </p><p>........................................................................
Write DATA:
data1:<01 04 FD 19 >
data2:<10 00 02 66 9A 0C 20 00 08 96 9E E2 11 9E B1 E2 F2 73 D9 14 0C 00 01 10 01 >
Read DATA:
spi Read come back:
02 7F 00 09 00
04 0E 06 01 04 FD 00 14 00
Chat Service added.
TX Char Handle 0011, RX Char Handle 0014
Service added successfully.</p><p>........................................................................
Write DATA:
data1:<01 0F FC 02 >
data2:<01 04 >
Read DATA:
spi Read come back:
02 7F 00 07 00
04 0E 04 01 0F FC 00
........................................................................
Write DATA:
data1:<01 09 20 20 >
data2:<00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 >
Read DATA:
spi Read come back:
02 7F 00 07 00
04 0E 04 01 09 20 00
General Discoverable Mode </p><p>........................................................................
Write DATA:
data1:<01 83 FC 1A >
data2:<00 00 00 00 00 00 00 0D 09 42 6C 75 65 4E 52 47 5F 62 6F 62 6F 00 00 00 00 00 >
Read DATA:
spi Read come back:
02 7F 00 07 00
04 0E 04 01 83 FC 00
0</p><p>........................................................................</p><p>interrupt
Read DATA:
spi Read come back:
02 7F 00 16 00
04 3E 13 01 00 01 08 01 00 B9 7E D3 30 CB EC 27 00 00 00 BC 02 05
Connected to device:EC-CB-30-D3-7E-B9</p><p>........................................................................
interrupt
Read DATA:
spi Read come back:
02 7F 00 00 00
Read DATA:
spi Read come back:
02 7F 00 08 00
04 FF 05 02 0C 01 08 00 </p><p>........................................................................</p>
觉使用spi都能设置成功了,当外面的蓝牙连接的时候,Connected to device:EC-CB-30-D3-7E-B9, 连接上10s左右就断开了》?
主要代码如下:
<p>
uint8_t bdaddr[] = {0xff, 0x00, 0x00, 0xE1, 0x80, 0x02};
ret = aci_hal_write_config_data(CONFIG_DATA_PUBADDR_OFFSET, CONFIG_DATA_PUBADDR_LEN,
bdaddr);
if(ret){
PRINTF("Setting BD_ADDR failed.\n");
}else {
PRINTF("Setting BD_ADDR Success.\n");
}
ret = aci_gatt_init();
if(ret){
PRINTF("GATT_Init failed.\n");
}else {
PRINTF("GATT_Init success\n");
}
{
uint16_t service_handle, dev_name_char_handle, appearance_char_handle;
ret = aci_gap_init(GAP_PERIPHERAL_ROLE, &service_handle, &dev_name_char_handle, &appearance_char_handle);</p><p>
if(ret){
PRINTF("GAP_Init failed.\n");
}else{
PRINTF("GAP_Init success.\n");
}
}
ret = aci_gap_set_auth_requirement(MITM_PROTECTION_REQUIRED,
OOB_AUTH_DATA_ABSENT,
NULL_DATA,
7,
16,
USE_FIXED_PIN_FOR_PAIRING,
123456,
BONDING);
PRINTF("BLE Stack Initialized.\n");
PRINTF("SERVER: BLE Stack Initialized (platform:linux)\n");
ret = Add_Chat_Service();
if(ret == BLE_STATUS_SUCCESS)
PRINTF("Service added successfully.\n");
else
PRINTF("Error while adding service.\n");
/* -2 dBm output power */
ret = aci_hal_set_tx_power_level(1,4);
while(1)
{
HCI_Process(); //list
User_Process();//make connect
}
</p>
|