This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts

BLE_GATTS_EVT_RW_AUTHORIZE_REQUEST event not generated


I want to read characteristics (central needs read data from peripheral whenever he want ) but don’t want to use notification.

I am trying this with authorization but it can not generate BLE_GATTS_EVT_RW_AUTHORIZE_REQUEST event. I just didn’t get what are the exactly settings required for that. I made changes in led service characteristics as follows.

What are the exactly changes I have to done here?
OR
Is there any example available where such solution used?

Fullscreen
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
uint32_t ble_lbs_init(ble_lbs_t * p_lbs, const ble_lbs_init_t * p_lbs_init )
{
uint32_t err_code;
ble_uuid_t ble_uuid;
ble_add_char_params_t add_char_params;
ble_gatts_attr_md_t attr_md;
// Initialize service structure.
p_lbs->led_write_handler = p_lbs_init->led_write_handler;
// Add service.
ble_uuid128_t base_uuid = {LBS_UUID_BASE};
err_code = sd_ble_uuid_vs_add(&base_uuid, &p_lbs->uuid_type);
VERIFY_SUCCESS(err_code);
ble_uuid.type = p_lbs->uuid_type;
ble_uuid.uuid = LBS_UUID_SERVICE;
err_code = sd_ble_gatts_service_add(BLE_GATTS_SRVC_TYPE_PRIMARY, &ble_uuid, &p_lbs->service_handle);
VERIFY_SUCCESS(err_code);
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX

Thanks in advance.

Regards,

Pooja

Parents
  • i am sorry, I do not know how I missed to see this. 

    The attr_md.rd_auth is not used anywhere in your code. It should set the attribute metadata for the charachteristic and you have not  used the attr_md anywhere in your code.

    For example inside your characteristic_add you should change something like this

    Fullscreen
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    attr_md.vloc = BLE_GATTS_VLOC_STACK;
    attr_md.rd_auth = 1;
    attr_md.wr_auth = 0;
    attr_md.vlen = 0;
    memset(&attr_char_value, 0, sizeof(attr_char_value));
    attr_char_value.p_uuid = &char_uuid;
    attr_char_value.p_attr_md = &attr_md;
    attr_char_value.init_len = APP_CFG_CHAR_LEN;
    attr_char_value.init_offs = 0;
    attr_char_value.max_len = APP_CFG_CHAR_LEN;
    attr_char_value.p_value = m_char_value;
    err_code = sd_ble_gatts_characteristic_add(m_service_handle,
    &char_md,
    &attr_char_value,
    &m_char_handles);
    XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX

  • Yes, it worked. Thank you so much.

    Now BLE_GATTS_EVT_RW_AUTHORIZE_REQUEST event generates and I can read value.

Reply Children