Hello, when using sd_ble_gatts_hvx(), I keep getting 0x3401 error. I googled it and it appears that it's because I might not have the notification enabled.
But I very much did. The MCP showed me this:
And the code on my android device also did enable notification:
if ((charaProp | BluetoothGattCharacteristic.PROPERTY_NOTIFY) > 0) {
mNotifyCharacteristic = characteristic;
mBluetoothLeService.setCharacteristicNotification(
characteristic, true);
Also, here's my config for that characteristic, when trying to add the characteristic:
static uint32_t mesh_value_char_add(void)
{
/* BLE GATT metadata */
ble_gatts_char_md_t ble_char_md;
memset(&ble_char_md, 0, sizeof(ble_char_md));
ble_char_md.char_props.write_wo_resp = 1;
ble_char_md.char_props.notify = 1;
ble_char_md.char_props.read = 1;//*
ble_char_md.char_props.write =1;//*
ble_char_md.p_cccd_md = NULL;//
ble_char_md.p_sccd_md = NULL;
ble_char_md.p_char_user_desc = NULL;
ble_char_md.p_user_desc_md = NULL;
/* ATT metadata */
ble_gatts_attr_md_t ble_attr_md;
memset(&ble_attr_md, 0, sizeof(ble_attr_md));
/* No security is required */
ble_attr_md.write_perm.lv = 1;
ble_attr_md.write_perm.sm = 1;
BLE_GAP_CONN_SEC_MODE_SET_OPEN(&ble_attr_md.read_perm); //*
BLE_GAP_CONN_SEC_MODE_SET_OPEN(&ble_attr_md.write_perm);//*
ble_char_md.p_cccd_md = &ble_attr_md;//*
ble_char_md.char_props.notify = 1;//*
ble_attr_md.vloc = BLE_GATTS_VLOC_STACK;
ble_attr_md.rd_auth = 1;
ble_attr_md.wr_auth = 1;
ble_attr_md.vlen = 1;
/* ble characteristic UUID */
ble_uuid_t ble_uuid;
ble_uuid.type = m_mesh_base_uuid_type;
ble_uuid.uuid = MESH_VALUE_CHAR_UUID;
/* ble attribute */
ble_gatts_attr_t ble_attr;
uint8_t default_value = 0;
memset(&ble_attr, 0, sizeof(ble_attr));
ble_attr.init_len = 1;
ble_attr.init_offs = 0;
ble_attr.max_len = sizeof(mesh_gatt_evt_t);
ble_attr.p_attr_md = &ble_attr_md;
ble_attr.p_uuid = &ble_uuid;
ble_attr.p_value = &default_value;
/* add to service */
uint32_t error_code = sd_ble_gatts_characteristic_add(
m_mesh_service.service_handle,
&ble_char_md,
&ble_attr,
&m_mesh_service.ble_val_char_handles);
if (error_code != NRF_SUCCESS)
{
return NRF_ERROR_INTERNAL;
}
return NRF_SUCCESS;
}
So... what did I do wrong?