CN / EN
CN / EN

提问

获得支持

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

属性表定义时,gatts_db.attr_tab.attr_tab_128变量赋值的规则是否有参考文档? GR551x

Wantfly

2024-02-22 17:30

GR551x_SDK_V1.6.10,下述代码中,OTAS_IDX_TX_CHAR、OTAS_IDX_TX_VAL、OTAS_IDX_TX_CFG这3个数据应该是属于同一个OTA_SERVICE_TX_UUID的属性,给otas_att_db赋值时,这3个数据必须按顺序赋值吗?还是可以与其他几个数据OTAS_IDX_SVC、OTAS_IDX_RX_CHAR、OTAS_IDX_RX_VAL交叉乱序赋值?请问有参考文档吗?

static const attm_desc_128_t otas_att_db[OTAS_IDX_NB] = {

// OTA service

[OTAS_IDX_SVC] = {ATT_128_PRIMARY_SERVICE, READ_PERM_UNSEC, 0, 0},


// OTA TX Characteristic Declaration

[OTAS_IDX_TX_CHAR] = {ATT_128_CHARACTERISTIC,READ_PERM_UNSEC, 0, 0},

// OTA TX Characteristic Value

[OTAS_IDX_TX_VAL] = {OTA_SERVICE_TX_UUID,

NOTIFY_PERM_UNSEC,

(ATT_VAL_LOC_USER | ATT_UUID_TYPE_SET(UUID_TYPE_128)),

OTAS_MAX_DATA_LEN},


// OTA TX Characteristic - Client Characteristic Configuration Descriptor

[OTAS_IDX_TX_CFG] = {ATT_128_CLIENT_CHAR_CFG,

READ_PERM_UNSEC| WRITE_REQ_PERM_UNSEC,

0,

0},


// OTA RX Characteristic Declaration

[OTAS_IDX_RX_CHAR] = {ATT_128_CHARACTERISTIC, READ_PERM_UNSEC, 0, 0 },

// OTA RX Characteristic Value

[OTAS_IDX_RX_VAL] = {OTA_SERVICE_RX_UUID,

WRITE_CMD_PERM_UNSEC,

(ATT_VAL_LOC_USER | ATT_UUID_TYPE_SET(UUID_TYPE_128)),

OTAS_MAX_DATA_LEN},

// OTA CTRL Characteristic Declaration

[OTAS_IDX_CTRL_CHAR] = {ATT_128_CHARACTERISTIC, READ_PERM_UNSEC, 0, 0},

// OTA CTRL Characteristic Value

[OTAS_IDX_CTRL_VAL] = {OTA_SERVICE_CTRL_UUID,

WRITE_CMD_PERM_UNSEC,

(ATT_VAL_LOC_USER | ATT_UUID_TYPE_SET(UUID_TYPE_128)),

sizeof(uint32_t)},

};

0收藏

0赞成

zhongchengzhi

汇顶员工
2024-02-22 21:11

您好:

1、赋值顺序不影响,因为otas_att_db是数组,赋值的时候指定了索引(如OTAS_IDX_TX_CHAR)后,您无论在哪个位置赋值,其索引不变。不过建议按照索引的位置来赋值,方便代码阅读和维护;

2、关于索引,您可以按照,Service, Char1_char/Char1_VAL/Char1_Cfg, Char2_char/Char2_VAL/Char2_Cfg, IDX_NB的顺序,参考如下:

enum otas_attr_idx_tag
{
   // Service
    OTAS_IDX_SVC,

    // TX Characteristic 
    OTAS_IDX_TX_CHAR,
    OTAS_IDX_TX_VAL,
    OTAS_IDX_TX_CFG,

    // RX Characteristic 
    OTAS_IDX_RX_CHAR,
    OTAS_IDX_RX_VAL,
    
    // Ctrl Characteristic 
    OTAS_IDX_CTRL_CHAR,
    OTAS_IDX_CTRL_VAL,

    OTAS_IDX_NB,
};

3、关于自定义服务,您这边可参考: https://docs.goodix.com/zh/online/detail/custom_sample_service_bl/V3.1/fb48e0f3e1872f3c158ed681e170577c

0条评论

0赞成

0收藏

您的评论

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

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

扫描关注公众号

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