CH32V208 notify失效

用的是ble 的peripherial例程,attributr table部分配置如下

// Characteristic 3 Declaration

    {

        {ATT_BT_UUID_SIZE, characterUUID},

        GATT_PERMIT_READ,

        0,

        &simpleProfileChar3Props},


    // Characteristic Value 3

    {

        {ATT_BT_UUID_SIZE, simpleProfilechar3UUID},

        GATT_PERMIT_WRITE,

        0,

        simpleProfileChar3},


    // Characteristic 3 User Description

    {

        {ATT_BT_UUID_SIZE, charUserDescUUID},

        GATT_PERMIT_READ,

        0,

        simpleProfileChar3UserDesp},


    // Characteristic 4 Declaration

    {

        {ATT_BT_UUID_SIZE, characterUUID},

        GATT_PERMIT_READ,

        0,

        &simpleProfileChar4Props},


    // Characteristic Value 4

    {

        {ATT_BT_UUID_SIZE, simpleProfilechar4UUID},

        0,

        0,

        simpleProfileChar4},


    // Characteristic 4 configuration

    {

        {ATT_BT_UUID_SIZE, clientCharCfgUUID},

        GATT_PERMIT_READ | GATT_PERMIT_WRITE,

        0,

        (uint8_t *)simpleProfileChar4Config},


    // Characteristic 4 User Description

    {

        {ATT_BT_UUID_SIZE, charUserDescUUID},

        GATT_PERMIT_READ,

        0,

        simpleProfileChar4UserDesp},

这样没有问题,Characteristic 4 的notify功能正常,但如果我把Characteristic 3的 User Description注释掉,Characteristic 4 的notify就不正常了,即

// Characteristic 3 Declaration

    {

        {ATT_BT_UUID_SIZE, characterUUID},

        GATT_PERMIT_READ,

        0,

        &simpleProfileChar3Props},


    // Characteristic Value 3

    {

        {ATT_BT_UUID_SIZE, simpleProfilechar3UUID},

        GATT_PERMIT_WRITE,

        0,

        simpleProfileChar3},


    // Characteristic 3 User Description

//    {

//        {ATT_BT_UUID_SIZE, charUserDescUUID},

//        GATT_PERMIT_READ,

//        0,

//        simpleProfileChar3UserDesp},


    // Characteristic 4 Declaration

    {

        {ATT_BT_UUID_SIZE, characterUUID},

        GATT_PERMIT_READ,

        0,

        &simpleProfileChar4Props},


    // Characteristic Value 4

    {

        {ATT_BT_UUID_SIZE, simpleProfilechar4UUID},

        0,

        0,

        simpleProfileChar4},


    // Characteristic 4 configuration

    {

        {ATT_BT_UUID_SIZE, clientCharCfgUUID},

        GATT_PERMIT_READ | GATT_PERMIT_WRITE,

        0,

        (uint8_t *)simpleProfileChar4Config},


    // Characteristic 4 User Description

    {

        {ATT_BT_UUID_SIZE, charUserDescUUID},

        GATT_PERMIT_READ,

        0,

        simpleProfileChar4UserDesp},

这是为什么

Characteristic 3是write,Characteristic 4是notify


@TECH_Lpc


这里配置11,寻找Characteristic Value 4。

如果修改了数组内容,需要将这里查询数组也进行修改。

image.png


谢谢大佬,解决了


还有一个问题,从机设备如何一连接,notify就配置为enable?

因为现在需要手机上点一下才可以enable,我尝试修改CCCD貌似没起作用.


可以从机主动使能CCCD,这样主机可以不进行使能。、

CH573 CH582 CH579蓝牙从机(peripheral)例程讲解五(蓝牙从机使能通知) - WCH蓝牙应用分享 - 博客园

但是要注意主机是否有硬件点击,例如BLE调试助手的noti务必手动点击按键才能进行接收数据,即使从机使能CCCD也无法成功接收到数据。可以用nrfconnect这个APP测试。


谢谢大佬,已经解决,andriod手机的nrf connect用起来没问题


只有登录才能回复,可以选择微信账号登录