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

No BLE_GATTS_EVT_RW_AUTHORIZE_REQUEST event

Hi, 

      Add BLE_GATTS_EVT_RW_AUTHORIZE_REQUEST event handle at ble_lbs service in example of ble_app_blinky. but when client read the characteristics 1524 or 1525, no BLE_GATTS_EVT_RW_AUTHORIZE_REQUEST  report in ble_lbs_on_ble_evt? why? And How to implement charateristics read operation?

void ble_lbs_on_ble_evt(ble_evt_t const * p_ble_evt, void * p_context)
{
    ble_lbs_t * p_lbs = (ble_lbs_t *)p_context;

    switch (p_ble_evt->header.evt_id)
    {
        case BLE_GATTS_EVT_WRITE:
            on_write(p_lbs, p_ble_evt);
            break;
        case BLE_GATTS_EVT_RW_AUTHORIZE_REQUEST:
            NRF_LOG_INFO("ON W_AUTHORIZE_REQUEST");
            on_read(p_lbs, p_ble_evt);
            break;
        default:
            // No implementation needed.
            break;
    }
}
Post

Parents
  • Hi,

    You need to enable the ".is_defered_read" option on the characteristic to require authorization on read.

    E.g.

        // Add LED characteristic.
        memset(&add_char_params, 0, sizeof(add_char_params));
        add_char_params.uuid             = LBS_UUID_LED_CHAR;
        add_char_params.uuid_type        = p_lbs->uuid_type;
        add_char_params.init_len         = sizeof(uint8_t);
        add_char_params.max_len          = sizeof(uint8_t);
        add_char_params.char_props.read  = 1;
        add_char_params.char_props.write = 1;
        add_char_params.is_defered_read = true;
    
        add_char_params.read_access  = SEC_OPEN;
        add_char_params.write_access = SEC_OPEN;
    
        return characteristic_add(p_lbs->service_handle, &add_char_params, &p_lbs->led_char_handles);
    }

    And the message sequence chart here illustrates how to handle authorized read requests: GATTS Read Request with Authorization

    Best regards,

    Vidar

  • It success capture the BLE_GATTS_EVT_RW_AUTHORIZE_REQUEST message. One things that I concerned  is it comes a lot of times BLE_GATTS_EVT_RW_AUTHORIZE_REQUEST  event for each read opreate. about 5 events .Is this right?

Reply Children
Related