平台:
协议栈版本:DA1458x_SDK 5.0.4
编译软件:keil 5.20
1,user_custs1_def.c下user_custs1_def.h 定义了
/// Custom1 Service Data Base Characteristic enum
enum
{
CUST1_IDX_SVC = 0,
CUST1_IDX_CONTROL_POINT_CHAR,
CUST1_IDX_CONTROL_POINT_VAL,
CUST1_IDX_CONTROL_POINT_USER_DESC,
CUST1_IDX_LED_STATE_CHAR,
CUST1_IDX_LED_STATE_VAL,
CUST1_IDX_LED_STATE_USER_DESC,
CUST1_IDX_ADC_VAL_1_CHAR,
CUST1_IDX_ADC_VAL_1_VAL,
CUST1_IDX_ADC_VAL_1_NTF_CFG,
CUST1_IDX_ADC_VAL_1_USER_DESC,
CUST1_IDX_ADC_VAL_2_CHAR,
CUST1_IDX_ADC_VAL_2_VAL,
CUST1_IDX_ADC_VAL_2_USER_DESC,
CUST1_IDX_BUTTON_STATE_CHAR,
CUST1_IDX_BUTTON_STATE_VAL,
CUST1_IDX_BUTTON_STATE_NTF_CFG,
CUST1_IDX_BUTTON_STATE_USER_DESC,
CUST1_IDX_INDICATEABLE_CHAR,
CUST1_IDX_INDICATEABLE_VAL,
CUST1_IDX_INDICATEABLE_IND_CFG,
CUST1_IDX_INDICATEABLE_USER_DESC,
CUST1_IDX_LONG_VALUE_CHAR,
CUST1_IDX_LONG_VALUE_VAL,
CUST1_IDX_LONG_VALUE_NTF_CFG,
CUST1_IDX_LONG_VALUE_USER_DESC,
CUST1_IDX_NB
};
等同于:
M10的 app文件下 streamdatad.c下的 streamdatad.h。
/* StreamData Device service */
enum
{
STREAMDATAD_IDX_PRIM_SVC,
STREAMDATAD_IDX_ENABLE_CHAR,
STREAMDATAD_IDX_ENABLE_VAL,
STREAMDATAD_IDX_ENABLE_EN,
STREAMDATAD_IDX_ENABLE_DESC,
STREAMDATAD_IDX_STREAMDATAD_D0_CHAR,
STREAMDATAD_IDX_STREAMDATAD_D0_VAL,
STREAMDATAD_IDX_STREAMDATAD_D0_EN,
STREAMDATAD_IDX_STREAMDATAD_D0_DESC,
STREAMDATAD_IDX_NB
};
2,sdk_profiles文件下 diss.c 下diss.h 定义了
///Attributes State Machine
enum
{
DIS_IDX_SVC,
DIS_IDX_MANUFACTURER_NAME_CHAR,
DIS_IDX_MANUFACTURER_NAME_VAL,
DIS_IDX_MODEL_NB_STR_CHAR,
DIS_IDX_MODEL_NB_STR_VAL,
DIS_IDX_SERIAL_NB_STR_CHAR,
DIS_IDX_SERIAL_NB_STR_VAL,
DIS_IDX_HARD_REV_STR_CHAR,
DIS_IDX_HARD_REV_STR_VAL,
DIS_IDX_FIRM_REV_STR_CHAR,
DIS_IDX_FIRM_REV_STR_VAL,
DIS_IDX_SW_REV_STR_CHAR,
DIS_IDX_SW_REV_STR_VAL,
DIS_IDX_SYSTEM_ID_CHAR,
DIS_IDX_SYSTEM_ID_VAL,
DIS_IDX_IEEE_CHAR,
DIS_IDX_IEEE_VAL,
DIS_IDX_PNP_ID_CHAR,
DIS_IDX_PNP_ID_VAL,
DIS_IDX_NB,
};
3,
文件:ble_580_sw_version.中定义了上图中Firmware Revision String
文件:ble_580_sw_version.中定义了上图中Software Revision String
同于:
M10的 app文件下 streamdatad.c下的 streamdatad.h。
官方蓝牙例程
平台:SDK5.0.4
工程:..\5.0.4\projects\target_apps\ble_examples\ble_app_peripheral
1,文件 user_custs1_def.c
更改原:
//static struct att_char128_desc custs1_ctrl_point_char = {ATT_CHAR_PROP_WR,
// {0, 0},
// DEF_CUST1_CTRL_POINT_UUID_128};
//static struct att_char128_desc custs1_led_state_char = {ATT_CHAR_PROP_WR_NO_RESP,
// {0, 0},
// DEF_CUST1_LED_STATE_UUID_128};
//static struct att_char128_desc custs1_adc_val_1_char = {ATT_CHAR_PROP_RD | ATT_CHAR_PROP_NTF,
// {0, 0},
// DEF_CUST1_ADC_VAL_1_UUID_128};
//static struct att_char128_desc custs1_adc_val_2_char = {ATT_CHAR_PROP_RD,
// {0, 0},
// DEF_CUST1_ADC_VAL_2_UUID_128};
//static struct att_char128_desc custs1_button_state_char = {ATT_CHAR_PROP_RD | ATT_CHAR_PROP_NTF,
// {0, 0},
// DEF_CUST1_BUTTON_STATE_UUID_128};
//static struct att_char128_desc custs1_indicateable_char = {ATT_CHAR_PROP_RD | ATT_CHAR_PROP_IND,
// {0, 0},
// DEF_CUST1_INDICATEABLE_UUID_128};
//static struct att_char128_desc custs1_long_value_char = {ATT_CHAR_PROP_RD | ATT_CHAR_PROP_WR | ATT_CHAR_PROP_NTF,
// {0, 0},
// DEF_CUST1_LONG_VALUE_UUID_128};
改为:
static struct att_char_desc custs1_ctrl_point_char = {ATT_CHAR_PROP_WR,
{0, 0},
DEF_CUST1_CTRL_POINT_UUID_128};
static struct att_char_desc custs1_led_state_char = {ATT_CHAR_PROP_WR_NO_RESP,
{0, 0},
DEF_CUST1_LED_STATE_UUID_128};
static struct att_char_desc custs1_adc_val_1_char = {ATT_CHAR_PROP_RD | ATT_CHAR_PROP_NTF,
{0, 0},
DEF_CUST1_ADC_VAL_1_UUID_128};
static struct att_char_desc custs1_adc_val_2_char = {ATT_CHAR_PROP_RD,
{0, 0},
DEF_CUST1_ADC_VAL_2_UUID_128};
static struct att_char_desc custs1_button_state_char = {ATT_CHAR_PROP_RD | ATT_CHAR_PROP_NTF,
{0, 0},
DEF_CUST1_BUTTON_STATE_UUID_128};
static struct att_char_desc custs1_indicateable_char = {ATT_CHAR_PROP_RD | ATT_CHAR_PROP_IND,
{0, 0},
DEF_CUST1_INDICATEABLE_UUID_128};
static struct att_char_desc custs1_long_value_char = {ATT_CHAR_PROP_RD | ATT_CHAR_PROP_WR | ATT_CHAR_PROP_NTF,
{0, 0},
DEF_CUST1_LONG_VALUE_UUID_128};
可以将UUID的长度改为2字节16位的。
将43行,改如下
static att_svc_desc128_t custs1_svc = DEF_CUST1_SVC_UUID_128;
//static uint8_t custs1_svc[ATT_UUID_16_LEN] = DEF_CUST1_SVC_UUID_128;
可以将服务UUID改为2字节16位的。
2,文件user_ota.c 或是 user_peripheral.c 中, 蓝牙只需读取发送在此处。
void user_catch_rest_hndl(ke_msg_id_t const msgid,
void const *param,
ke_task_id_t const dest_id,
ke_task_id_t const src_id)
{
switch(msgid)
{
case GAPC_PARAM_UPDATED_IND:
{
// Cast the "param" pointer to the appropriate message structure
struct gapc_param_updated_ind const *msg_param = (struct gapc_param_updated_ind const *)(param);
// Check if updated Conn Params filled to preffered ones
if ((msg_param->con_interval >= user_connection_param_conf.intv_min) &&
(msg_param->con_interval <= user_connection_param_conf.intv_max) &&
(msg_param->con_latency == user_connection_param_conf.latency) &&
(msg_param->sup_to == user_connection_param_conf.time_out))
{
}
} break;
//2018.6.14 JC
case CUSTS1_VAL_WRITE_IND:
{
struct custs1_val_write_ind const *msg_param = (struct custs1_val_write_ind const *)(param);
switch (msg_param->handle)
{
case CUST1_IDX_CONTROL_POINT_VAL:
user_custs1_ctrl_wr_ind_handler(msgid, msg_param, dest_id, src_id);
break;
case CUST1_IDX_LED_STATE_VAL:
user_custs1_led_wr_ind_handler(msgid, msg_param, dest_id, src_id);
break;
case CUST1_IDX_ADC_VAL_1_NTF_CFG:
user_custs1_adc_val_1_cfg_ind_handler(msgid, msg_param, dest_id, src_id);
break;
case CUST1_IDX_BUTTON_STATE_NTF_CFG:
user_custs1_button_cfg_ind_handler(msgid, msg_param, dest_id, src_id);
break;
case CUST1_IDX_INDICATEABLE_IND_CFG:
user_custs1_long_val_cfg_ind_handler(msgid, msg_param, dest_id, src_id);
break;
case CUST1_IDX_LONG_VALUE_NTF_CFG:
user_custs1_long_val_cfg_ind_handler(msgid, msg_param, dest_id, src_id);
break;
case CUST1_IDX_LONG_VALUE_VAL:
user_custs1_long_val_wr_ind_handler(msgid, msg_param, dest_id, src_id);
break;
default:
break;
}
} break;
case CUSTS1_VAL_NTF_CFM:
{
struct custs1_val_ntf_cfm const *msg_param = (struct custs1_val_ntf_cfm const *)(param);
switch (msg_param->handle)
{
case CUST1_IDX_ADC_VAL_1_VAL:
break;
case CUST1_IDX_BUTTON_STATE_VAL:
break;
case CUST1_IDX_LONG_VALUE_VAL:
break;
default:
break;
}
} break;
case CUSTS1_VAL_IND_CFM:
{
struct custs1_val_ind_cfm const *msg_param = (struct custs1_val_ind_cfm const *)(param);
switch (msg_param->handle)
{
case CUST1_IDX_INDICATEABLE_VAL:
break;
default:
break;
}
} break;
//以上
default:
break;
}
}
参考:https://blog.csdn.net/a369000753/article/details/53510146