以tspps服务为例子增加0x2901特性: 1.enum { IDX_TSPP_SVC, IDX_TSPP_COMMAND_CHAR, IDX_TSPP_COMMAND_VAL, IDX_TSPP_COMMAND_DESC,//这个特性下增加0X2901属性 IDX_TSPP_NOTIFY_CHAR, IDX_TSPP_NOTIFY_VAL, IDX_TSPP_NOTIFY_DESC, }; 2.在service_tspp_init函数接口里面增加ob_att_cudd_def static const ob_gatt_item_t atts_tspp[] = { { ob_att_char_def, OB_UUID_16BIT, OB_ATT_PROP_READ }, { tspp_command, OB_UUID_16BIT, OB_ATT_PROP_WRITE_CMD }, { ob_att_cudd_def, OB_UUID_16BIT, OB_ATT_PROP_READ },//0X2901 { ob_att_char_def, OB_UUID_16BIT, OB_ATT_PROP_READ }, { tspp_notify, OB_UUID_16BIT, OB_ATT_PROP_NTF }, { ob_att_cccd_def, OB_UUID_16BIT, OB_ATT_PROP_READ | OB_ATT_PROP_WRITE },
}; 3.在tspp_event_cb函数接口增加0X2091的特性值 #define GAP_APPEARANCE "V123"//"\xc2\x03" //测试使用 if (req->att_hdl == m_tspp_start_handle + IDX_TSPP_COMMAND_DESC)//0X2901 { OM_LOG_DEBUG("\n tspp IDX_TSPP_COMMAND_DESC"); // ob_gatts_read_response(evt->gatt.conn_idx, OB_GATT_ERR_NO_ERROR, (uint8_t *)&m_trans_enabled, sizeof(uint16_t)); ob_gatts_read_response(evt->gatt.conn_idx, OB_GATT_ERR_NO_ERROR, (uint8_t *)GAP_APPEARANCE, sizeof(GAP_APPEARANCE) - 1);//测试使用 } 4.附件是对应的源文件 |
![](/images/page/ziptu.png)