This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

NRF_ERROR_FORBIDDEN occurs in sd_ble_gatts_characteristic_add.

Hello.

It is developed using nrf52832 (S132 v7.0.1, SDK v17.0.0) as a peripheral device.

I'm trying to characteristically add BLE_UUID_GAP_CHARACTERISTIC_DEVICE_NAME and BLE_UUID_GAP_CHARACTERISTIC_APPEARANCE.

However, characteristic_add (sd_ble_gatts_characteristic_add) gives an NRF_ERROR_FORBIDDEN error. How can it be solved?

static uint16_t                 m_service_handle;                                   /**< Handle of local service (as provided by the BLE stack).*/
static ble_gatts_char_handles_t m_char_handles[2];                  /**< Handles of local characteristic (as provided by the BLE stack).*/


#define BLE_UUID_SERVICE_BASE {0xHH, 0xHH, 0xGG, 0xGG, 0xFF, 0xFF, 0xEE, 0xEE, 0xDD, 0xDD, 0xCC, 0xCC, 0xBB, 0xBB, 0xAA, 0xAA}
#define BLE_ADV_UUID_SERVICE 0xABCD
#define BLE_UUID_CHAR        0xEFGH

/**
 * @brief DEVICE NAME CHARACTERISTIC
 * 
 */
static ble_add_char_params_t char_device_name = 
{
    .uuid            = BLE_UUID_GAP_CHARACTERISTIC_DEVICE_NAME,
    .uuid_type       = 0x00,
    .max_len         = 248,
    .init_len        = 248,
    .p_init_value    = NULL,
    .is_var_len      = false,
    .char_props.read = 1,
    .read_access     = SEC_OPEN,
};

/**
 * @brief APPEARANCE CHARACTERISTIC
 * 
 */
static ble_add_char_params_t char_appearance = 
{
    .uuid             = BLE_UUID_GAP_CHARACTERISTIC_APPEARANCE,
    .uuid_type        = 0x00,
    .max_len          = 2,
    .init_len         = 2,
    .is_var_len       = false,
    .char_props.read  = 1,
    .read_access      = SEC_OPEN,
};

static void services_init(void)
{
    ble_uuid128_t base_uuid = {BLE_UUID_SERVICE_BASE};
    ble_uuid_t service_uuid;
    ret_code_t err_code;    

    service_uuid.uuid = BLE_ADV_UUID_SERVICE;

    err_code = sd_ble_uuid_vs_add(&base_uuid, &service_uuid.type);
    APP_ERROR_CHECK(err_code);

    err_code = sd_ble_gatts_service_add(BLE_GATTS_SRVC_TYPE_PRIMARY, &service_uuid, &m_service_handle);
    APP_ERROR_CHECK(err_code);

    characteristic_init();

    return;
}

static void characteristic_init(void)
{
    ble_uuid_t    char_uuid;
    ret_code_t    err_code;

    err_code = characteristic_add(m_service_handle, &char_device_name, &m_char_handles[0]);
    APP_ERROR_CHECK(err_code);

    err_code = characteristic_add(m_service_handle, &char_appearance, &m_char_handles[1]);
    APP_ERROR_CHECK(err_code);

    return;
}

Best regards.

Parents
  • Hello,

    sd_ble_gatts_characteristic_add will return NRF_ERROR_FORBIDDEN when you attempt to register an UUID that'd already reserved for the stack, as mentioned in the function API Reference. Please try to change the offending UUID's, and see if this resolves your issue.
    For the record, you could also use UUID generators to create custom UUID's for your services, if you'd like.

    Best regards,
    Karl

  • Hello.

    BLE_UUID_GAP_CHARACTERISTIC_DEVICE_NAME and BLE_UUID_GAP_CHARACTERISTIC_APPEARANCE are 16-bit UUIDs defined by the Bluetooth SIG. So, isn't the value registered in the characteristic also 16 bits? Therefore, I set it to ".uuid_type = 0x00".

    I don't know how to use BLE_UUID_GAP_CHARACTERISTIC_DEVICE_NAME and BLE_UUID_GAP_CHARACTERISTIC_APPEARANCE, so please let me know.

    Best regards.

  • Hello,

    sdi_kei said:

    Regarding the SDK that started development, I don't know about the SDK that I was using because I took over the program from my predecessor.

    I understand.
    Knowing which SDK version you are working with is vital, since the documentation is only valid for a particular SDK version. You can check the SDK version by going into SDK_ROOT/documentation/release_notes.txt it should say at the top of the file, which SDK version it is.

    sdi_kei said:

    I think you're mistaken for SoftDevice to do central work as well.

    Please let me know if you have any advice on how to turn off Central Address Resolution.

    Aha, I see. Thank you for clarifying!
    What is the value of the BLE_GAP_CHAR_INCL_CONFIG_INCLUDE define in your project? This is the define that is used for determine CAR inclusion in a peripheral.

    Best regards,
    Karl

  • Hello.

    You can check the SDK version by going into SDK_ROOT/documentation/release_notes.txt it should say at the top of the file, which SDK version it is.

    The SDK version is v17.0.0. I don't know the program that I referred to.

    What is the value of the BLE_GAP_CHAR_INCL_CONFIG_INCLUDE define in your project?

    The value of BLE_GAP_CHAR_INCL_CONFIG_INCLUDE was defined as 0 in ble_gap.h. There were no definitions in other files.

    Best regards.

  • Thank you for your patience with this.

    sdi_kei said:
    The SDK version is v17.0.0. I don't know the program that I referred to.

    Just to be sure, could you confirm the exact SoftDevice version you are working with again? Upon closer examination it seems that the option to disable CAR was only added in v7.0.1.

    sdi_kei said:
    The value of BLE_GAP_CHAR_INCL_CONFIG_INCLUDE was defined as 0 in ble_gap.h. There were no definitions in other files.

    Oh, my mistake, it is actually BLE_GAP_CAR_INCL_CONFIG_DEFAULT that you need to check the value of, since this is the define that is used for the configuration in the SDK examples, at least.
    Alternatively, you can configure this directly by calling sd_ble_cfg_set with BLE_GAP_CHAR_INCL_CONFIG_EXCLUDE_WITHOUT_SPACE before your call to nrf_sdh_ble_enable().

    Best regards,
    Karl

  • Hello.

    could you confirm the exact SoftDevice version you are working with again?

    It is v7.0.1 because there was "s132_nrf52_7.0.1_softdevice.hex" in "SDK_ROOT / components \ softdevice \ s132 \ hex".

    Alternatively, you can configure this directly by calling sd_ble_cfg_set with BLE_GAP_CHAR_INCL_CONFIG_EXCLUDE_WITHOUT_SPACE before your call to nrf_sdh_ble_enable().

    After constructing the following code based on what you taught and checking the operation, we succeeded in deleting Central Address Resolution from Generic Access.

    static void ble_stack_init(void)
    {
        ret_code_t err_code;
        ble_cfg_t  ble_cfg;
        
        // Exclude Central Address Resolution from Generic Access
        ble_cfg.gap_cfg.car_include_cfg.include_cfg = BLE_GAP_CHAR_INCL_CONFIG_EXCLUDE_WITHOUT_SPACE;
        err_code = sd_ble_cfg_set(BLE_GAP_CFG_CAR_INCL_CONFIG, &ble_cfg, ram_start);
        APP_ERROR_CHECK(err_code);
        
        return;
    }

    Thank you for telling me various things. It was very helpful. I think I will ask other questions as well, so please do not hesitate to contact me at that time.

    Best regards.

  • Hello again,

    sdi_kei said:
    It is v7.0.1 because there was "s132_nrf52_7.0.1_softdevice.hex" in "SDK_ROOT / components \ softdevice \ s132 \ hex".

    Thank you for confirming this.

    sdi_kei said:
    After constructing the following code based on what you taught and checking the operation, we succeeded in deleting Central Address Resolution from Generic Access.

    I am glad to hear that you were able to delete the Central Address Resolution characteristic.

    sdi_kei said:
    Thank you for telling me various things. It was very helpful. I think I will ask other questions as well, so please do not hesitate to contact me at that time.

    It is no problem at all, I am happy to help!
    Please do not hesitate to open another ticket if you should encounter any issues or questions in the future. It is best if you open a new ticket if the new issue diverges from the original topic of another ticket, instead of asking the question in an existing un-related ticket.

    Good luck with your development!

    Best regards,
    Karl

Reply
  • Hello again,

    sdi_kei said:
    It is v7.0.1 because there was "s132_nrf52_7.0.1_softdevice.hex" in "SDK_ROOT / components \ softdevice \ s132 \ hex".

    Thank you for confirming this.

    sdi_kei said:
    After constructing the following code based on what you taught and checking the operation, we succeeded in deleting Central Address Resolution from Generic Access.

    I am glad to hear that you were able to delete the Central Address Resolution characteristic.

    sdi_kei said:
    Thank you for telling me various things. It was very helpful. I think I will ask other questions as well, so please do not hesitate to contact me at that time.

    It is no problem at all, I am happy to help!
    Please do not hesitate to open another ticket if you should encounter any issues or questions in the future. It is best if you open a new ticket if the new issue diverges from the original topic of another ticket, instead of asking the question in an existing un-related ticket.

    Good luck with your development!

    Best regards,
    Karl

Children
No Data
Related