7 posts / 0 new
Last post
sbourahla
Offline
Last seen:5 years 6 months ago
Expert
Joined:2015-02-25 09:51
Read/Write

Hello,

I try to develop an application for control a LED, I change the characteristic "Appearance" of the Generic Access Service to allow the write operation. It's work, when I connect to the Bluetooth, I can change the value and when I read it's correct.

Now I want to implement some minor update in the code for ON/OFF the LED depending to the Appearance Value but I don't understand where in the code I can get this value and how i can test it. My application is based on the SmartTag example.

Regards,

sbourahla
Offline
Last seen:5 years 6 months ago
Expert
Joined:2015-02-25 09:51
Up

Up

RvA
Offline
Last seen:2 weeks 2 days ago
Staff
Joined:2014-02-07 14:10
Hi Sbourahla,

Hi Sbourahla,

I will check and get back to you as soon as possible.

Best regards, RvA

sbourahla
Offline
Last seen:5 years 6 months ago
Expert
Joined:2015-02-25 09:51
Hi RvA,

Hi RvA,

Ok, thank you, I continue to look for this and I found this in the file "prf_utils.h" :

void prf_read_char_send(struct prf_con_info* con_info,
uint16_t shdl, uint16_t ehdl, uint16_t valhdl)
{
struct gattc_read_cmd * req = KE_MSG_ALLOC(GATTC_READ_CMD, KE_BUILD_ID(TASK_GATTC, con_info->conidx),
con_info->prf_id, gattc_read_cmd);
//request type
req->req_type = GATTC_READ;
req->nb = 1;
req->req.simple.offset = 0;
req->req.simple.length = 0;
req->req.simple.handle = valhdl;

//send request to GATT
ke_msg_send(req);
}

Do you think I can read an attribute/characteristic with this and how ?

Best Regards,

RvA
Offline
Last seen:2 weeks 2 days ago
Staff
Joined:2014-02-07 14:10
Hi Sbourahla,

Hi Sbourahla,

There is aGAPM_APPEARANCE_INDmessage in our ble stack which is triggered when appearance is writable and modified by a peer device.

Event triggered when device appearance is modified by a peer device. This can occur only if device
appearance is writable into attribute database.

What you need do is:
1. Turn to app_task_handlers.h, fill line "{GAPM_APPEARANCE_IND, (ke_msg_func_t)gapm_appearance_ind_handler}," in array app_default_state
2. Define your own message handler in following format:

int gapm_appearance_ind_handler(ke_msg_id_t const msgid,
struct gapm_appearance_ind const *param,
ke_task_id_t const dest_id,
ke_task_id_t const src_id)
{
if (ke_state_get(dest_id) == APP_CONNECTED)
{
// check the param to see what's the modified appearance value and do the corresponding LED control
}
}

Best regards, RvA

sbourahla
Offline
Last seen:5 years 6 months ago
Expert
Joined:2015-02-25 09:51
Hi RvA,

Hi RvA,

Thank you, I implement this with the SmartTag application, it's work. Now I understand more how the BLE stacks and the SDk work. For some reasons with the condition "ke_state_get(dest_id) == APP_CONNECTED) it doesn't work. I think it's because I don't use the good Android application for this (SmartTag App only on iOS, so the i use a standart BLE scan on Android) so the status APP_CONNECTED it's never define. What do you think ?

Best Regards,

RvA
Offline
Last seen:2 weeks 2 days ago
Staff
Joined:2014-02-07 14:10
Hi Sbourahla,

Hi Sbourahla,

我们相信。你可以检查该设备是否is still in connection state on the application side when the appearance write cmd is sent.

Best regards, RvA