Error -13 when using nrfCloud location services from Thingy91x

I am using a Thingy91x, with some additional sensors attached via qwiic cable.


Initially to test the Thingy91x I inserted the SIM and scanned the QR code on the Thingy91x to get the device initialised in nrfCloud. The hello.nrfcloud page loaded in a browser and I could see data from the Thingy91x. I enabled GNSS via the page, and checked that GNSS worked when outdoors and the fallback to WIFI worked when indoors.

I then created my own custom firmware taking sample code from hello.nrfcloud. Sampling from the internal sensors and my added external ones is working fine, but I am having trouble with using the nrfCloud location services to get Assisted GNSS files when AGNSS is enabled and to get GPS coordinates from Cellular data.
I am using the location_init() to initialise and pass in my handler.

I am then using location_config_defaults_set(&config, location_methods_size, location_method_types); with

static enum location_method location_method_types[] = {
LOCATION_METHOD_GNSS,
LOCATION_METHOD_CELLULAR
};

I then call err = location_request(&config);

In my logs though I keep getting an error -13

[00:00:26.445,617] <inf> nrf_cloud_coap_cell_location_sample: Location request started
%NCELLMEAS: 0,"01991102","26201","05D8",128,1300,120,38,14,26119,1300,215,32,1,0,6400,479,63,24,24,1444,335,39,21,33,20370
[00:00:27.082,794] <err> location: Failed to acquire location using cloud location, error: -13
[00:00:27.092,285] <err> location: Location acquisition failed and fallbacks are also done
[00:00:27.101,257] <err> nrf_cloud_coap_cell_location_sample: Location request failed

I think this is an authentication issue to the nrfCloud services, but I can't find a way to resolve it. I know the device should be registered ok as hello.nrfcloud worked.

I have tried various config settings. Below are my base settings, but I have also tried:

- CONFIG_NRF_CLOUD_CLIENT_ID_SRC_IMEI=n and CONFIG_NRF_CLOUD_CLIENT_ID_SRC_INTERNAL_UUID=y
- CONFIG_NRF_CLOUD_CLIENT_ID_SRC_IMEI=y and CONFIG_NRF_CLOUD_CLIENT_ID_PREFIX="oob-" commented out
- CONFIG_NRF_CLOUD_CLIENT_ID_SRC_IMEI=y and CONFIG_NRF_CLOUD_CLIENT_ID_PREFIX="nrf-"


# --- Hardware & Library Enable ---
CONFIG_LOCATION=y
CONFIG_LOCATION_DATA_DETAILS=y
CONFIG_LOCATION_SERVICE_NRF_CLOUD=y
CONFIG_LOCATION_METHODS_LIST_SIZE=3
CONFIG_LOCATION_METHOD_GNSS=y
CONFIG_LOCATION_METHOD_WIFI=n
CONFIG_LOCATION_METHOD_CELLULAR=y

# --- Verified Credentials (OOB Factory Tag) ---
CONFIG_NRF_CLOUD_SEC_TAG=16842753
CONFIG_NRF_CLOUD_CLIENT_ID_SRC_IMEI=y
CONFIG_NRF_CLOUD_CLIENT_ID_PREFIX="oob-"

# --- Assistance & System ---
CONFIG_NRF_CLOUD_AGNSS=y

# Transport
#
CONFIG_COAP=y
CONFIG_NRF_CLOUD_COAP=y
CONFIG_NRF_CLOUD_COAP_SERVER_HOSTNAME="coap.nrfcloud.com"
CONFIG_NRF_CLOUD_COAP_SEC_TAG=16842753
CONFIG_NRF_CLOUD_COAP_JWT_SEC_TAG=4242
CONFIG_NRF_CLOUD_COAP_SERVER_PORT=5684
CONFIG_NRF_CLOUD_COAP_KEEPOPEN=y
CONFIG_NRF_CLOUD_COAP_MAX_RETRIES=10
CONFIG_NRF_CLOUD_COAP_DOWNLOADS=y
CONFIG_NRF_CLOUD_COAP_DISCONNECT_ON_FAILED_REQUEST=y
CONFIG_NRF_CLOUD_COAP_LOG_LEVEL_DEFAULT=y
CONFIG_NRF_CLOUD_COAP_LOG_LEVEL=3
# end of Transport

Can you point out what I am doing wrong. Thanks

Parents
  • Hi Chris,

    The error you get is -EACCES, meaning the device does not have a valid nRF Cloud CoAP connection.

    In your custom firmware, are you able to see any communication to nRF Cloud at all? Please try to follow this guide. Note that you need to run the device_credentials_installer.py script with the --coap argument.

    Regards,
    Benjamin

  • Hi Benjamin,

    Thanks for replying.

    Isn't the device already onboarded though as part of the scan of the QR code on the Thingy91x, and confirmation that the device is showing on the hello.nrfcloud page in the browser.  It must be onboarded with coap enabled as the oob firmware was succesfully uploading data to nrfcloud via coap, which was displayed in the hello.nrfcloud page.  I'm trying to connect to nrfCloud as the same onboarded device.  My understanding is that certs and keys are held in the modem secure storage, which i am not touching when flashing the custom firmware to the nrf9151.

    Chris

  • Hi Chris,

    Sorry for the delay. You are correct that the device stores credentials in the modem. Other applications, such as nrf_cloud_coap_cell_location, use a different security tag than the hello.nrfcloud firmware. However, if your firmware is based on hello.nrfcloud, the security tag should remain the same. What changes did you make to your firmware?

    With the new firmware, do you see any communication with nRF Cloud at all, or is only the A-GNSS failing? If possible, please provide the full log and modem traces.

    Best regards,
    Benjamin

  • Hi Benjamin,

    We have actually based our code on the nrf_cloud_coap_cell_location application, but heavily customised.  I included the security tag information from the prj.conf file in my original post.  Are we able to use the hello.nrfcloud security tag?  Below is a log from where we have tried to use GNSS (not A-GNSS) with a fallback to cellular.  If we try A-GNSS we get the same error -13 when it attempts to download the A-GNSS files.

      [00:00:27.171,661] <inf> location: Method specific timeout expired
    [00:00:27.178,955] <inf> location: Location retrieval failed using 'GNSS', trying with 'Cellular' next
    [00:00:27.189,025] <inf> nrf_cloud_coap_cell_location_sample: Entering Func: location_event_handler
    [00:00:27.198,516] <inf> nrf_cloud_coap_cell_location_sample: Location fallback: Timeout -> Cellular
    %NCELLMEAS: 0,"01991102","26201","05D8",130,1300,120,38,10,28660,6400,212,57,21,24,6400,477,55,16,24,6400,149,51,9,24,1444,335,43,20,33,20119
    [00:00:29.600,280] <inf> nrf_cloud_coap_cell_location_sample: Entering Func: lte_event_handler
    %NCELLMEAS: 0,"01991102","26201","05D8",130,20119,1300,120,37,9,28984,1,0,"019A9301","26201","05D8",65535,0,1300,213,40,13,28984,0,0,"019A9300","26201","05D8",65535,0,1300,215,31,-4,28984,0,0,"01991105","26201","05D8",65535,0,6400,212,57,21,29041,0,0,"019A9310","26201","05D8",65535,0,6400,477,54,14,29041,0,0
    [00:00:29.964,752] <inf> nrf_cloud_coap_cell_location_sample: Entering Func: lte_event_handler
    [00:00:29.981,048] <err> location: Failed to acquire location using cloud location, error: -13
    [00:00:29.990,631] <err> location: Location acquisition failed and fallbacks are also done
    [00:00:29.999,572] <inf> nrf_cloud_coap_cell_location_sample: Entering Func: location_event_handler
    [00:00:30.009,307] <err> nrf_cloud_coap_cell_location_sample: Location request failed

    Hope this is usefull.

    Thanks

    Chris

Reply
  • Hi Benjamin,

    We have actually based our code on the nrf_cloud_coap_cell_location application, but heavily customised.  I included the security tag information from the prj.conf file in my original post.  Are we able to use the hello.nrfcloud security tag?  Below is a log from where we have tried to use GNSS (not A-GNSS) with a fallback to cellular.  If we try A-GNSS we get the same error -13 when it attempts to download the A-GNSS files.

      [00:00:27.171,661] <inf> location: Method specific timeout expired
    [00:00:27.178,955] <inf> location: Location retrieval failed using 'GNSS', trying with 'Cellular' next
    [00:00:27.189,025] <inf> nrf_cloud_coap_cell_location_sample: Entering Func: location_event_handler
    [00:00:27.198,516] <inf> nrf_cloud_coap_cell_location_sample: Location fallback: Timeout -> Cellular
    %NCELLMEAS: 0,"01991102","26201","05D8",130,1300,120,38,10,28660,6400,212,57,21,24,6400,477,55,16,24,6400,149,51,9,24,1444,335,43,20,33,20119
    [00:00:29.600,280] <inf> nrf_cloud_coap_cell_location_sample: Entering Func: lte_event_handler
    %NCELLMEAS: 0,"01991102","26201","05D8",130,20119,1300,120,37,9,28984,1,0,"019A9301","26201","05D8",65535,0,1300,213,40,13,28984,0,0,"019A9300","26201","05D8",65535,0,1300,215,31,-4,28984,0,0,"01991105","26201","05D8",65535,0,6400,212,57,21,29041,0,0,"019A9310","26201","05D8",65535,0,6400,477,54,14,29041,0,0
    [00:00:29.964,752] <inf> nrf_cloud_coap_cell_location_sample: Entering Func: lte_event_handler
    [00:00:29.981,048] <err> location: Failed to acquire location using cloud location, error: -13
    [00:00:29.990,631] <err> location: Location acquisition failed and fallbacks are also done
    [00:00:29.999,572] <inf> nrf_cloud_coap_cell_location_sample: Entering Func: location_event_handler
    [00:00:30.009,307] <err> nrf_cloud_coap_cell_location_sample: Location request failed

    Hope this is usefull.

    Thanks

    Chris

Children
  • Thanks,

    In that case, the issue becomes clearer. This sample uses security tag 16842753, and you must use the device_credentials_installer script. The credentials used in the hello.nrfcloud firmware will not work.

    Regards,
    Benjamin

  • Hi Benjamin,

    I managed to get it working in the end without having to run the script and install my own certs.

    I knew that the Thingy91x device must registered ok in nrfcloud, as the default hello.nrfcloud firmware initially installed on the device worked.  I also knew that I had not overwritten the modem firmware when I had flashed my own application firmware to the device, so I knew the certs should still be there.  It was a matter of working out the correct config settings to get the correct cert used for authentication.  Eventually after a lot of trial and error I got there, and now it's working perfectly.

    Thanks for your help though

    Chris

Related