CN / EN
CN / EN

提问

设计支持

您的项目私密技术问题如需获得一对一支持,请点击下方联系我们。

如何GR5515开发BLE5.0/BLE5.1的串口透传应用? GR551x

137****com

2024-09-11 10:37

芯片型号:GR5515IGND

SDK版本:GR551x_SDK_V2.0.1

基础工程:\GR551x_SDK_V2.0.1\projects\ble\ble_peripheral\ble_app_uart

需求:为了更稳定、更远距离的传输,希望在该基础工程上增加BLE5.0/BLE5.1的协议,增强设备的通信距离和传输稳定特性。

现象:在基础工程中增加如下的gap初始化参数,程序运行后,串口能够看到正常的log,但是安卓手机的调试工具GRToolbox完全搜索不到这个设备了,更无法连接。

代码改动情况:在demo工程上 只增加了以下的初始化函数:

#define APP_ADV_INTERVAL    800     // 0.5s
static ble_gap_ext_adv_param_t  s_gap_ext_adv_param;
static void gap_ext_adv_param_init(void)
{
    sdk_err_t   error_code;
    // TODO:新增 BLE5.0 参数设置
    s_gap_ext_adv_param.type = BLE_GAP_ADV_TYPE_EXTENDED;
    s_gap_ext_adv_param.disc_mode = BLE_GAP_DISC_MODE_GEN_DISCOVERABLE;
    s_gap_ext_adv_param.prop = BLE_GAP_ADV_PROP_CONNECTABLE_BIT;
    s_gap_ext_adv_param.max_tx_pwr = 7;
    s_gap_ext_adv_param.filter_pol = BLE_GAP_ADV_ALLOW_SCAN_ANY_CON_ANY;
    s_gap_ext_adv_param.prim_cfg.adv_intv_max = APP_ADV_INTERVAL;
    s_gap_ext_adv_param.prim_cfg.adv_intv_min = APP_ADV_INTERVAL;
    s_gap_ext_adv_param.prim_cfg.chnl_map = BLE_GAP_ADV_CHANNEL_37_38_39;
    s_gap_ext_adv_param.prim_cfg.phy = BLE_GAP_PHY_1MBPS_VALUE;
    s_gap_ext_adv_param.second_cfg.max_skip = 0;
    s_gap_ext_adv_param.second_cfg.phy = BLE_GAP_PHY_1MBPS_VALUE;
    s_gap_ext_adv_param.second_cfg.adv_sid = 0x00;
    s_gap_ext_adv_param.period_cfg.adv_intv_min = 0;
    s_gap_ext_adv_param.period_cfg.adv_intv_max = 0;
    memset(&s_gap_ext_adv_param.peer_addr, 0, sizeof(ble_gap_bdaddr_t));
    error_code = ble_gap_ext_adv_param_set(0, BLE_GAP_OWN_ADDR_GEN_RSLV, &s_gap_ext_adv_param);
    APP_ERROR_CHECK(error_code);
}

问题:

1、如何在这个具有串口服务的外设上添加2M/Coded 的PHY能力?以上的初始化代码是否合理,还需要如何修改?

2、如果增加了,苹果手机是否能与外设连接通信?

3、如果增加了,微信小程是否能与外设连接通信?

0收藏

0赞成

134***007

汇顶员工
2024-09-12 09:59

主机配置

scan_init.scan_param.type = BLE_GAP_EXT_SCAN_TYPE_OBSERVER;

scan_init.scan_param.prop = BLE_GAP_EXT_SCAN_PROP_PHY_1M_BIT |

BLE_GAP_EXT_SCAN_PROP_PHY_CODED_BIT |

BLE_GAP_EXT_SCAN_PROP_ACTIVE_1M_BIT |

BLE_GAP_EXT_SCAN_PROP_ACTIVE_CODED_BIT|

BLE_GAP_EXT_SCAN_PROP_ACCEPT_RPA_BIT|

BLE_GAP_EXT_SCAN_PROP_FILT_TRUNC_BIT;

scan_init.scan_param.dup_filt_pol = BLE_GAP_EXT_DUP_FILT_DIS;

scan_init.scan_param.scan_param_coded.scan_intv = 160;

scan_init.scan_param.scan_param_coded.scan_wd = 80;

scan_init.scan_param.scan_param_1m.scan_intv = 320;

scan_init.scan_param.scan_param_1m.scan_wd = 40;

scan_init.scan_param.duration = 0;

scan_init.scan_param.period = 0;

scan_init.conn_param.type = BLE_GAP_INIT_TYPE_DIRECT_CONN_EST;

scan_init.conn_param.prop = BLE_GAP_INIT_PROP_CODED_BIT;

scan_init.conn_param.conn_to = 0;

scan_init.conn_param.conn_param_coded.conn_intv_max = 100;

scan_init.conn_param.conn_param_coded.conn_intv_min = 100;

scan_init.conn_param.conn_param_coded.conn_latency = 0;

scan_init.conn_param.conn_param_coded.supervision_to = 400;

scan_init.conn_param.scan_param_coded.scan_intv = 160;

scan_init.conn_param.scan_param_coded.scan_wd = 80;


scan_init.connect_auto = true;


4条评论

0赞成

0收藏

您的评论

134***007

汇顶员工
2024-09-12 09:56

从机配置

s_gap_ext_adv_param.type = BLE_GAP_ADV_TYPE_EXTENDED;

s_gap_ext_adv_param.disc_mode = BLE_GAP_DISC_MODE_GEN_DISCOVERABLE;

s_gap_ext_adv_param.prop = BLE_GAP_ADV_PROP_CONNECTABLE_BIT;

s_gap_ext_adv_param.max_tx_pwr = 0;

s_gap_ext_adv_param.filter_pol = BLE_GAP_ADV_ALLOW_SCAN_ANY_CON_ANY;

memset(&s_gap_ext_adv_param.peer_addr, 0, sizeof(ble_gap_addr_t));

s_gap_ext_adv_param.peer_addr.addr_type = BLE_GAP_ADDR_TYPE_PUBLIC;

s_gap_ext_adv_param.prim_cfg.adv_intv_min = 160;

s_gap_ext_adv_param.prim_cfg.adv_intv_max = 160;

s_gap_ext_adv_param.prim_cfg.chnl_map = BLE_GAP_ADV_CHANNEL_37_38_39;

s_gap_ext_adv_param.prim_cfg.phy = BLE_GAP_PHY_CODED_VALUE ;

s_gap_ext_adv_param.second_cfg.max_skip= 0;

s_gap_ext_adv_param.second_cfg.phy= BLE_GAP_PHY_CODED_VALUE;

s_gap_ext_adv_param.second_cfg.adv_sid= 0;

s_gap_ext_adv_param.period_cfg.adv_intv_max = 0;

s_gap_ext_adv_param.period_cfg.adv_intv_min = 0;


//default value

s_gap_ext_adv_param.period_cfg.adv_intv_min = 0;

s_gap_ext_adv_param.period_cfg.adv_intv_max = 0;

error_code = ble_gap_ext_adv_param_set(0, BLE_GAP_OWN_ADDR_STATIC, &s_gap_ext_adv_param);

error_code = ble_gap_adv_data_set(0, BLE_GAP_ADV_DATA_TYPE_DATA, s_adv_data_set, sizeof(s_adv_data_set));

APP_ERROR_CHECK(error_code);


s_gap_adv_time_param.duration = 0;

s_gap_adv_time_param.max_adv_evt = 0;


ble_gap_pref_phy_set(BLE_GAP_PHY_LE_CODED, BLE_GAP_PHY_LE_CODED);

0条评论

0赞成

0收藏

您的评论

登录后可回答问题,请 注册

我们时刻倾听您的声音
联系销售

扫描关注公众号

打开微信,使用“扫一扫”即可关注