Android BLE API onCharacteristicChanged() never triggered

2 posts / 0 new
Last post
thomas
Offline
Last seen:5 years 7 months ago
加入:2015-03-11 02:46
Android BLE API onCharacteristicChanged() never triggered

I'm a newcomer to da14560
Here are the things I would like to do:
The Android App sends a value to da14580 , da14580 then modify the characteristic's value and send a indication back to Android App. The Android App uses indication to read corresponding characteristic.

I have a problem here, according to Android SDK, onCharacteristicChanged() should called when Android App received a notification or indication, but it never triggered in my scenario.
I have previously enabled Characteristic Notification using setCharacteristicNotification(characteristic, true).
Here is my onCharacteristicChanged() method
@Override
public void onCharacteristicChanged(BluetoothGatt gatt, BluetoothGattCharacteristic characteristic) {
broadcastUpdate(ACTION_DATA_CHANGED, characteristic);
日志。d(标签,“没有tification Received!");
}

these are my da14580 characteristic setup code:
In profile_task.c
static int lowspp_create_db_req_handler(ke_msg_id_t const msgid,
struct lowspp_create_db_req const *param,
ke_task_id_t const dest_id,
ke_task_id_t const src_id)
{
...
//add val attribute
status = attmdb_add_attribute(lowspp_env.lowspp_shdl, sizeof(uint8_t)*30, //Data size = 20 //hcasen add 14-10-10
ATT_UUID_128_LEN, (uint8_t*)&lowspp_2_val.uuid, PERM(RD, ENABLE) | PERM(IND, ENABLE) | PERM(WR, ENABLE),
&(val_hdl));

memcpy(lowspp_2_char.attr_hdl, &val_hdl, sizeof(uint16_t));

status = attmdb_att_set_value(char_hdl, sizeof(lowspp_2_char), (uint8_t *)&lowspp_2_char);
....
}

In profile.c
struct att_char128_desc lowspp_2_char = {ATT_CHAR_PROP_RD | ATT_CHAR_PROP_IND|ATT_CHAR_PROP_WR,
{0,0},
//{0xfb, 0x34, 0x9b, 0x5f, 0x80, 0x00, 0x00, 0x80, 0x00, 0x10, 0x00, 0x00, 0xe2, 0x34, 0x00, 0x00}}; /*UUID*/
{0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0x00, 0x10, 0x00, 0x60, 0x02, 0xD0, 0x18, 0xD6}};

lowspp_upd_char2_req_handler() modifies attribute database and send indication to Android App

static int lowspp_upd_char2_req_handler(ke_msg_id_t const msgid,
struct lowspp_upd_char2_req const *param,
ke_task_id_t const dest_id,
ke_task_id_t const src_id)
{
uint8_t status = PRF_ERR_OK;

// Check provided values
if(param->conhdl == gapc_get_conhdl(lowspp_env.con_info.conidx))
{
// Update value in DB
attmdb_att_set_value(lowspp_env.lowspp_shdl + LOWSPP_2_IDX_VAL,
param->len, (uint8_t *)¶m->val);
// Send indication to the peer device
if((lowspp_env.feature & PRF_CLI_START_IND))
{
prf_server_send_event((prf_env_struct *)&lowspp_env, true,
lowspp_env.lowspp_shdl + LOWSPP_2_IDX_VAL);
}
}
else
{
status = PRF_ERR_INVALID_PARAM;
}

if (status != PRF_ERR_OK)
{
lowspp_upd_char2_cfm_send(status);
}

return (KE_MSG_CONSUMED);
}

If you can help me out ,thanks a lot

Keywords:
Device:
JE_Dialog
Offline
Last seen:1小时29分钟前
Staff
加入:2013-12-05 14:02
Hello Thomas, one of the team

Hello Thomas, one of the team is taking a look and will be in touch shorrly.

BR JE_Dialog