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

sd_ble_uuid_vs_add () returns err_code = 16 (#define NRF_ERROR_INVALID_ADDR (NRF_ERROR_BASE_NUM + 16) ///< Bad Memory Address)

Hi, I am using nRF52832 with S132 softdevice and SDK version 11. I am getting bad memory address error code.

err_code = sd_ble_uuid_vs_add (&base_uuid, &ble_service->uuid_type);
if (err_code != NRF_SUCCESS){
SEGGER_RTT_printf(0, "err_code: %d \n", err_code);
return err_code;
}

Can anybody help me to figure out what could be the reason for such errors? Thank!

  • OK, address of the service looks ok. How do you set it up? Mine looks like:

        // Add service
    serviceUuid.type = BLE_UUID_TYPE_VENDOR_BEGIN + BLE_NRF_LOCAL_VENDOR_UUID_INDEX;  // Position of the Vender specific ID base in baseUuid128.
    serviceUuid.uuid = ONSET_SERVICE_UUID;
    
    errCode = sd_ble_uuid_vs_add(&baseUuid128, &serviceUuid.type);
    
  • I am not understanding why you are doing serviceUuid.type = BLE_UUID_TYPE_VENDOR_BEGIN + BLE_NRF_LOCAL_VENDOR_UUID_INDEX; // Position of the Vender specific ID base in baseUuid128 in your code. What BLE_NRF_LOCAL_VENDOR_UUID_INDEX is?

    This is my code for service init.

    uint32_t vitameter_service_init (ble_vitameter_service_t* ble_vitameter_service)
    {
      uint32_t err_code;
      ble_uuid128_t base_uuid = {BLE_UUID_VITAMETER_BASE_UUID};
      ble_vitameter_service->conn_handle 	   = BLE_CONN_HANDLE_INVALID;
      err_code = sd_ble_uuid_vs_add (&base_uuid, &ble_vitameter_service->uuid_type);
      if (err_code != NRF_SUCCESS){
        SEGGER_RTT_printf(0, "err_code: %d \n", err_code);
        return err_code;
      }
    
      ble_uuid_t service_uuid;
      service_uuid.type = ble_vitameter_service->uuid_type;
      service_uuid.uuid = BLE_UUID_VITAMETER_SERVICE;
    
      err_code = sd_ble_gatts_service_add(BLE_GATTS_SRVC_TYPE_PRIMARY,
                                          &service_uuid,
                                          &ble_vitameter_service->service_handle);
      if (err_code != NRF_SUCCESS){
        return err_code;
      }
      err_code = vitameter_is_test_inserted_char_add(ble_vitameter_service);
      if (err_code != NRF_SUCCESS){
        return err_code;
      }
      
      err_code = vitameter_test_error_char_add(ble_vitameter_service);
      if (err_code != NRF_SUCCESS){
        return err_code;
      }
    
      err_code = vitameter_test_result_char_add(ble_vitameter_service);
      if (err_code != NRF_SUCCESS){
          return err_code;
      }
      return NRF_SUCCESS;
    }
    

    and structure for service

    typedef struct{
    	uint16_t                              	conn_handle;
    	uint16_t                              	service_handle;
    	ble_gatts_char_handles_t              	is_test_inserted_handles;             	/**< Server Characteristic Configuration Descriptor (SCCD) */
    	ble_gatts_char_handles_t              	error_handles;
    	ble_gatts_char_handles_t              	result_handles;
    	uint8_t                               	uuid_type;
    } ble_vitameter_service_t;
    

    According to my understanding, this err_code = sd_ble_uuid_vs_add (&base_uuid, &ble_vitameter_service->uuid_type); will save what type of uuid (whether its vendor specific or SIG) in ble_vitameter_service->uuid_type and later for for all service and characteristics this ble_vitameter_service->uuid_type will be used.

  • Well, the BLE_UUID_TYPE_VENDOR_BEGIN is defined as a 2 in ble_types.h, BLE_NRF_LOCAL_VENDOR_UUID_INDEX is defined as a 0 in my code. I believe BLE_NRF_LOCAL_VENDOR_UUID_INDEX is in case you want to add more than 1 vendor specific UUID to your services. It's not necessary, but it was in the Nordic example I took this code from years ago now, and I've had no need to change it.

    What is ble_vitameter_service->uuid_type set to?

  • I have only one vendor-specific UUID, so I don't think I should worry about that. ble_vitameter_service->uuid_type pointing to 0, that means I think invalid UUID.

    #define BLE_UUID_TYPE_UNKNOWN       0x00 /**< Invalid UUID type. */
    
Related