你好:
我做了测试:
1. 同样的测试环境、测试硬件
2. 官方蓝牙4.2 主、从主机例程。
3. 根据贵司的建议,从: 下载进行远距离通信测试
4. 发现蓝蓝牙4.2 例程和远距离通信例程,主从机的通信距离几乎没有区别。
5. 通信距离都是在30米左右,没有实现远距离通信的功能啊?
Alvin Chen:
1.首先我认为你的硬件设计不太好,就算不用S=8的long range mode 30多米也很近在环境的优良的环境下。
2.
RED: Solid RED indicates the device is not connected to a central.
GREEN: Blinking GREEN indicates the device is connected to a central in using the Long Range Coded PHY (S8).
你连接上之后绿色的的灯有闪烁?
user5983202:
回复 Alvin Chen:
1. 硬件:2*LaunchPad CC2640R2 应该不存在硬件设计不太
2. 环境不算好
3. 仔细阅读了资料,我是这样理解的,主从没有连接时,主从的距离一定要在1M PHY 范围内(环境好的情况下也就100米),当连接上后,通信距离可以达到1.5Km(理想情况下),当断连后,主从的距离又在1M PHY 范围内才能连接上?我的理解对不对? 这样的话,没什么实际意义啊?
Alvin Chen:
回复 user5983202:
github上面的demo太久了没有更新了。请下载最新的SDK。
在新的SDK支持CODE PHY advertise 和scan:
static void SimplePeripheral_processGapMessage(gapEventHdr_t *pMsg) {switch(pMsg->opcode){case GAP_DEVICE_INIT_DONE_EVENT:{bStatus_t status = FAILURE;gapDeviceInitDoneEvent_t *pPkt = (gapDeviceInitDoneEvent_t *)pMsg;if(pPkt->hdr.status == SUCCESS){// Store the system IDuint8_t systemId[DEVINFO_SYSTEM_ID_LEN];// use 6 bytes of device address for 8 bytes of system ID valuesystemId[0] = pPkt->devAddr[0];systemId[1] = pPkt->devAddr[1];systemId[2] = pPkt->devAddr[2];// set middle bytes to zerosystemId[4] = 0x00;systemId[3] = 0x00;// shift three bytes upsystemId[7] = pPkt->devAddr[5];systemId[6] = pPkt->devAddr[4];systemId[5] = pPkt->devAddr[3];// Set Device Info Service ParameterDevInfo_SetParameter(DEVINFO_SYSTEM_ID, DEVINFO_SYSTEM_ID_LEN, systemId);Display_printf(dispHandle, SP_ROW_STATUS_1, 0, "Initialized");// Setup and start Advertising// For more information, see the GAP section in the User's Guide:// software-dl.ti.com/.../// Temporary memory for advertising parameters for set #1. These will be copied// by the GapAdv moduleGapAdv_params_t advParamLegacy = GAPADV_PARAMS_LEGACY_SCANN_CONN;// Create Advertisement set #1 and assign handlestatus = GapAdv_create(&SimplePeripheral_advCallback, &advParamLegacy,&advHandleLegacy);SIMPLEPERIPHERAL_ASSERT(status == SUCCESS);// Load advertising data for set #1 that is statically allocated by the appstatus = GapAdv_loadByHandle(advHandleLegacy, GAP_ADV_DATA_TYPE_ADV,sizeof(advertData), advertData);SIMPLEPERIPHERAL_ASSERT(status == SUCCESS);// Load scan response data for set #1 that is statically allocated by the appstatus = GapAdv_loadByHandle(advHandleLegacy, GAP_ADV_DATA_TYPE_SCAN_RSP,sizeof(scanRspData), scanRspData);SIMPLEPERIPHERAL_ASSERT(status == SUCCESS);// Set event mask for set #1status = GapAdv_setEventMask(advHandleLegacy,GAP_ADV_EVT_MASK_START_AFTER_ENABLE |GAP_ADV_EVT_MASK_END_AFTER_DISABLE |GAP_ADV_EVT_MASK_SET_TERMINATED);// Enable legacy advertising for set #1status = GapAdv_enable(advHandleLegacy, GAP_ADV_ENABLE_OPTIONS_USE_MAX , 0);SIMPLEPERIPHERAL_ASSERT(status == SUCCESS);// Use long range params to create long range set #2GapAdv_params_t advParamLongRange = GAPADV_PARAMS_AE_LONG_RANGE_CONN;// Create Advertisement set #2 and assign handlestatus = GapAdv_create(&SimplePeripheral_advCallback, &advParamLongRange,&advHandleLongRange);SIMPLEPERIPHERAL_ASSERT(status == SUCCESS);// Load advertising data for set #2 that is statically allocated by the appstatus = GapAdv_loadByHandle(advHandleLongRange, GAP_ADV_DATA_TYPE_ADV,sizeof(advertData), advertData);SIMPLEPERIPHERAL_ASSERT(status == SUCCESS);// Load scan response data for set #2 that is statically allocated by the appstatus = GapAdv_loadByHandle(advHandleLongRange, GAP_ADV_DATA_TYPE_SCAN_RSP,sizeof(scanRspData), scanRspData);SIMPLEPERIPHERAL_ASSERT(status == SUCCESS);// Set event mask for set #2status = GapAdv_setEventMask(advHandleLongRange,GAP_ADV_EVT_MASK_START_AFTER_ENABLE |GAP_ADV_EVT_MASK_END_AFTER_DISABLE |GAP_ADV_EVT_MASK_SET_TERMINATED);// Enable long range advertising for set #2status = GapAdv_enable(advHandleLongRange, GAP_ADV_ENABLE_OPTIONS_USE_MAX , 0);SIMPLEPERIPHERAL_ASSERT(status == SUCCESS);// Display device addressDisplay_printf(dispHandle, SP_ROW_IDA, 0, "%s Addr: %s",(addrMode <= ADDRMODE_RANDOM) ? "Dev" : "ID",Util_convertBdAddr2Str(pPkt->devAddr));
user5983202:
回复 Alvin Chen:
1. 你这个在主机还是从机?
2. 仔细阅读了资料,我是这样理解的,主从没有连接时,主从的距离一定要在1M PHY 范围内(环境好的情况下也就100米),当连接上后,通信距离可以达到1.5Km(理想情况下),当断连后,主从的距离又在1M PHY 范围内才能连接上?我的理解对不对? 这样的话,没什么实际意义啊?
Alvin Chen:
回复 user5983202:
这是广播肯定是是peripheral,可以支持长连接去下载最新的SDK里面的程序里面有代码自己去学习一下。
Alvin Chen:
回复 user5983202:
这是广播肯定是是peripheral,可以支持长连接去下载最新的SDK里面的程序里面有代码自己去学习一下。
user5983202:
回复 Alvin Chen:
1.那主机呢,主机部分如何修改?
2.最新的SDK,长连接功能可以实现1.5KM(理想情况下)长距离下扫描到、连接、通信吗?
Alvin Chen:
回复 user5983202:
请下载最新SDK并阅读里面的程序。
user5983202:
回复 Alvin Chen:
你不知道就说不知道,关于远距离通信的,我问了好几次,有人回复说,默认打开,有人回复说默认不打开,让我去下例程,好了,我去下了例程,倒腾了好久,可以测试了,结果不理想。最后你让我去下载最新SDK并阅读里面的程序。如果我看了程序就知道的话,我干嘛还要在这里问来问去的?无语!
Alvin Chen:
回复 user5983202:
测试距离客户应该达不到1.5km 我们测试在400m左右。此外在新的SDK里面的central和peripheral里面支持选择ADV PHY和SCAN PHY。
此外什么是远距离就是PHY在CODE PHY.我需要把整个工程给您贴上来吗?