6621E怎么添加128位的私有服务

徽信管理团队 · 132次点击 · 4个月前

6621E 有些客户会使用私有128位的服务,这里以tspp服务为例,初始化代码修改如下:

void service_tspp_init(void)
{
    ble_uuid_t service_uuid;
    ble_uuid128_t ble_uuid =
    {
        {0x79, 0x41, 0xDC, 0x24, 0x0E, 0xE5, 0xA9, 0xE0, 0x93, 0xF3, 0xA3, 0xB5, 0x01, 0x00, 0x40, 0x6E}
    };
    ble_gatts_char_handles_t handles;
    service_uuid.uuid = 0x0001;
    om_ble_uuid_vs_add(&ble_uuid, &(service_uuid.type));
    om_ble_gatts_service_add(BLE_GATTS_SRVC_TYPE_PRIMARY, &service_uuid, &m_start_handle);

    ble_gatts_char_md_t char_md;
    ble_gatts_attr_t attr_char_value;
    ble_gatts_attr_md_t attr_md;
    ble_gatts_attr_md_t cccd_md;

    //!  这里用作举例设置其他128bit的值
    ble_uuid128_t char_ble_uuid =
    {
        {0x66, 0x41, 0xDC, 0x24, 0x0E, 0xE5, 0xA9, 0xE0, 0x93, 0xF3, 0xA3, 0xB5, 0x01, 0x00, 0x40, 0x66}
    };
    memset(&attr_char_value, 0, sizeof(attr_char_value));
    memset(&attr_md, 0, sizeof(attr_md));
    memset(&char_md, 0, sizeof(char_md));
    attr_md.vloc = BLE_GATTS_VLOC_USER;
    char_md.char_props.write_wo_resp = 1;
    service_uuid.uuid = 0x0002;
    om_ble_uuid_vs_add(&char_ble_uuid, &(service_uuid.type));
    attr_char_value.p_uuid = &service_uuid;
    attr_char_value.p_attr_md = &attr_md;
    om_ble_gatts_characteristic_add(m_start_handle, &char_md, &attr_char_value, &handles);

    memset(&char_md, 0, sizeof(char_md));
    memset(&attr_char_value, 0, sizeof(attr_char_value));
    memset(&cccd_md, 0, sizeof(cccd_md));
    char_md.char_props.notify = 1;
    char_md.p_cccd_md = &cccd_md;
    service_uuid.uuid = 0x0003;
    om_ble_uuid_vs_add(&ble_uuid, &(service_uuid.type));
    attr_char_value.p_uuid = &service_uuid;
    attr_char_value.p_attr_md = &attr_md;
    om_ble_gatts_characteristic_add(m_start_handle, &char_md, &attr_char_value, &handles);

    memset(&attr_char_value, 0, sizeof(attr_char_value));
    memset(&char_md, 0, sizeof(char_md));
    char_md.char_props.write = 1;
    service_uuid.uuid = 0x0004;
    om_ble_uuid_vs_add(&ble_uuid, &(service_uuid.type));
    attr_char_value.p_uuid = &service_uuid;
    attr_char_value.p_attr_md = &attr_md;
    om_ble_gatts_characteristic_add(m_start_handle, &char_md, &attr_char_value, &handles);
    co_fifo_init(&tspp_fifo, tspp_buffer, TSPP_BUFFER_SIZE);
}


被收藏 0  ∙  0 赞  
加入收藏
点赞
0 回复  
善言善语 (您需要 登录 后才能回复 没有账号 ?)

请先登录网站