久芯网

在STM30WB55中怎样让P2P_Client同时连接P2P_Sever1和P2PSever2等多个设备

avatar j&S 提问时间: 2023-08-16 20:27:30 / 未解决

现在是这样的,首先我手上拥有USB_Dongle+Nucleo Board以及自己设计的开发板(和USB_Dongle兼容),现在想使用USB_Dongle作为P2P_Client,其他两块板子分别为Sever1和Sever2。目前只能实现Client与其中任意一块链接,但不能实现多机的链接。

app_conf.h中配置如下,

define CFG_MAX_CONNECTION 2

define CFG_DEV_ID_P2P_SERVER1 (0x83)

define CFG_DEV_ID_P2P_SERVER2 (0x84)

app_ble.c如下:

if (adlength >= 7 && adv_report_data[k + 2] == 0x01) { / ST VERSION ID 01 / APP_DBG_MSG("--- ST MANUFACTURER ID --- \n"); switch (adv_report_data[k + 3]) { / Demo ID / case CFG_DEV_ID_P2P_SERVER1: / End Device 1 / APP_DBG_MSG("-- SERVER DETECTED -- VIA MAN ID\n"); BleApplicationContext.DeviceServerFound = 0x01; SERVER_REMOTE_BDADDR[0] = le_advertising_event->Advertising_Report[0].Address[0]; SERVER_REMOTE_BDADDR[1] = le_advertising_event->Advertising_Report[0].Address[1]; SERVER_REMOTE_BDADDR[2] = le_advertising_event->Advertising_Report[0].Address[2]; SERVER_REMOTE_BDADDR[3] = le_advertising_event->Advertising_Report[0].Address[3]; SERVER_REMOTE_BDADDR[4] = le_advertising_event->Advertising_Report[0].Address[4]; SERVER_REMOTE_BDADDR[5] = le_advertising_event->Advertising_Report[0].Address[5]; break; case CFG_DEV_ID_P2P_SERVER2: / End Device 2 / APP_DBG_MSG("-- SERVER DETECTED -- VIA MAN ID\n"); BleApplicationContext.DeviceServerFound = 0x02; SERVER_REMOTE_BDADDR[0] = le_advertising_event->Advertising_Report[0].Address[0]; SERVER_REMOTE_BDADDR[1] = le_advertising_event->Advertising_Report[0].Address[1]; SERVER_REMOTE_BDADDR[2] = le_advertising_event->Advertising_Report[0].Address[2]; SERVER_REMOTE_BDADDR[3] = le_advertising_event->Advertising_Report[0].Address[3]; SERVER_REMOTE_BDADDR[4] = le_advertising_event->Advertising_Report[0].Address[4]; SERVER_REMOTE_BDADDR[5] = le_advertising_event->Advertising_Report[0].Address[5]; break;

default: break; }

2个回答
  • avatar j&S
    回答时间: 2023-08-16 20:57:21

  • avatar butterflyspring
    回答时间: 2023-08-16 21:24:16

    看到了官方有相关的例程资料,参考一下哈

会员中心 微信客服
客服
回到顶部