|
| 1 | +.. _nrf_cloud_coap_cell_location: |
| 2 | + |
| 3 | +Cellular: nRF Cloud CoAP cellular location |
| 4 | +########################################## |
| 5 | + |
| 6 | +.. contents:: |
| 7 | + :local: |
| 8 | + :depth: 2 |
| 9 | + |
| 10 | +This sample demonstrates how to use the `nRF Cloud CoAP API`_ for nRF Cloud's cellular location service on your device. |
| 11 | + |
| 12 | +Requirements |
| 13 | +************ |
| 14 | + |
| 15 | +The sample supports the following development kits: |
| 16 | + |
| 17 | +.. table-from-sample-yaml:: |
| 18 | + |
| 19 | +.. include:: /includes/tfm.txt |
| 20 | + |
| 21 | +The sample requires an `nRF Cloud`_ account. |
| 22 | +Your device must be onboarded to nRF Cloud. |
| 23 | +If it is not, follow the instructions in `Device on-boarding <nrf_cloud_coap_cell_location_onboarding>`_. |
| 24 | + |
| 25 | +.. note:: |
| 26 | + This sample requires modem firmware v1.3.x or later for an nRF9160 DK, or modem firmware v2.x.x for the nRF9161 and nRF9151 DKs. |
| 27 | + |
| 28 | +Overview |
| 29 | +******** |
| 30 | + |
| 31 | +The sample can work in two modes: single-cell mode and multi-cell mode. |
| 32 | + |
| 33 | +After the sample initializes and connects to the network, it enters the single-cell mode and sends a single-cell location request to nRF Cloud. |
| 34 | +For this purpose, the sample uses network data obtained from the :ref:`modem_info_readme` library. |
| 35 | +In the multi-cell mode, the sample requests for neighbor cell measurement using the :ref:`lte_lc_readme` library. |
| 36 | + |
| 37 | +If the modem provides neighbor cell data, the sample sends a multi-cell location request to nRF Cloud. |
| 38 | +Otherwise, the request is single-cell. |
| 39 | + |
| 40 | +In either mode, the sample sends a new location request if a change in cell ID is detected. |
| 41 | + |
| 42 | +See the `nRF Cloud Location Services documentation`_ for additional information. |
| 43 | + |
| 44 | +User interface |
| 45 | +************** |
| 46 | + |
| 47 | +Button 1: |
| 48 | + Toggle between the single-cell and multi-cell mode. |
| 49 | + |
| 50 | +.. _nrf_cloud_coap_cell_location_onboarding: |
| 51 | + |
| 52 | +Setup |
| 53 | +===== |
| 54 | + |
| 55 | +You must onboard your device to nRF Cloud for this sample to function. |
| 56 | +You only need to do this once for each device. |
| 57 | +To onboard your device, install `nRF Cloud Utils`_ and follow the instructions in the README. |
| 58 | + |
| 59 | +Configuration |
| 60 | +************* |
| 61 | + |
| 62 | +|config| |
| 63 | + |
| 64 | +Configuration options |
| 65 | +===================== |
| 66 | + |
| 67 | +Check and configure the following Kconfig options for the sample: |
| 68 | + |
| 69 | +.. _CONFIG_COAP_CELL_CHANGE_CONFIG: |
| 70 | + |
| 71 | +CONFIG_COAP_CELL_CHANGE_CONFIG - Enable changing request configuration |
| 72 | + Set this to use the next combination of ``hi_conf`` and ``fallback`` flags after performing both single- and multi-cell location requests. |
| 73 | + |
| 74 | +.. _CONFIG_COAP_CELL_DEFAULT_DOREPLY_VAL: |
| 75 | + |
| 76 | +CONFIG_COAP_CELL_DEFAULT_DOREPLY_VAL - Enable return of location from cloud |
| 77 | + If enabled, request the cloud to return the location information. |
| 78 | + |
| 79 | +.. _CONFIG_COAP_CELL_DEFAULT_FALLBACK_VAL: |
| 80 | + |
| 81 | +CONFIG_COAP_CELL_DEFAULT_FALLBACK_VAL - Enable fallback to coarse location |
| 82 | + If enabled and the location of the cell tower or Wi-Fi® access points cannot be found, return area-level location based on the cellular tracking area code. |
| 83 | + Otherwise an error will be returned indicating location is not known. |
| 84 | + |
| 85 | +.. _CONFIG_COAP_CELL_DEFAULT_HICONF_VAL: |
| 86 | + |
| 87 | +CONFIG_COAP_CELL_DEFAULT_HICONF_VAL - Enable high-confidence result |
| 88 | + Enable a 95% confidence interval for the location, instead of the default 68%. |
| 89 | + |
| 90 | +.. _CONFIG_COAP_CELL_SEND_DEVICE_STATUS: |
| 91 | + |
| 92 | +CONFIG_COAP_CELL_SEND_DEVICE_STATUS - Send device status |
| 93 | + Send device status to nRF Cloud on initial connection. |
| 94 | + |
| 95 | +.. include:: /libraries/modem/nrf_modem_lib/nrf_modem_lib_trace.rst |
| 96 | + :start-after: modem_lib_sending_traces_UART_start |
| 97 | + :end-before: modem_lib_sending_traces_UART_end |
| 98 | + |
| 99 | +Building and running |
| 100 | +******************** |
| 101 | + |
| 102 | +.. |sample path| replace:: :file:`samples/cellular/nrf_cloud_coap_cell_location` |
| 103 | + |
| 104 | +.. include:: /includes/build_and_run_ns.txt |
| 105 | + |
| 106 | +Testing |
| 107 | +======= |
| 108 | + |
| 109 | +|test_sample| |
| 110 | + |
| 111 | +#. |connect_kit| |
| 112 | +#. |connect_terminal| |
| 113 | +#. Reset the development kit. |
| 114 | +#. Observe in the terminal window that the application starts. |
| 115 | + This is indicated by output similar to the following (there is also a lot of additional information about the LTE connection): |
| 116 | + |
| 117 | + .. code-block:: console |
| 118 | +
|
| 119 | + *** Booting nRF Connect SDK v3.0.99-065f86a42eaa *** |
| 120 | + *** Using Zephyr OS v4.1.99-82973b4f6d2a *** |
| 121 | + Attempting to boot slot 0. |
| 122 | + Attempting to boot from address 0x8200. |
| 123 | + I: Trying to get Firmware version |
| 124 | + I: Verifying signature against key 0. |
| 125 | + I: Hash: 0x3e...f9 |
| 126 | + I: Firmware signature verified. |
| 127 | + Firmware version 2 |
| 128 | + �[00:00:00.254,821] <inf> spi_nor: GD25LE255E@0: 32 MiBy flash |
| 129 | + *** Booting My Application v1.0.0-065f86a42eaa *** |
| 130 | + *** Using nRF Connect SDK v3.0.99-065f86a42eaa *** |
| 131 | + *** Using Zephyr OS v4.1.99-82973b4f6d2a *** |
| 132 | + [00:00:00.292,907] <inf> nrf_cloud_coap_cell_location_sample: nRF Cloud CoAP Cellular Location Sample, version: 1.0.0 |
| 133 | + [00:00:00.715,637] <inf> nrf_cloud_coap_cell_location_sample: Device ID: 7e699894-79b6-11f0-a2b4-db93a314a2aa |
| 134 | + [00:00:00.721,313] <inf> nrf_cloud_coap_cell_location_sample: Using LTE LC neighbor search type GCI extended complete for 5 cells |
| 135 | + [00:00:01.023,040] <inf> nrf_cloud_credentials: Sec Tag: 16842753; CA: Yes, Client Cert: Yes, Private Key: Yes |
| 136 | + [00:00:01.023,101] <inf> nrf_cloud_credentials: CA Size: 1824, AWS: Likely, CoAP: Likely |
| 137 | + [00:00:01.023,101] <inf> nrf_cloud_coap_cell_location_sample: nRF Cloud credentials detected! |
| 138 | + [00:00:01.023,132] <inf> nrf_cloud_coap_cell_location_sample: Enabling connectivity... |
| 139 | + +CGEV: EXCE STATUS 0 |
| 140 | + +CEREG: 2,"0910","020A6B0C",7 |
| 141 | + %MDMEV: PRACH CE-LEVEL 0 |
| 142 | + +CSCON: 1 |
| 143 | + [00:00:02.995,330] <inf> nrf_cloud_coap_cell_location_sample: RRC mode: connected |
| 144 | + +CGEV: ME PDN ACT 0,0 |
| 145 | + +CNEC_ESM: 50,0 |
| 146 | + %MDMEV: SEARCH STATUS 2 |
| 147 | + +CEREG: 5,"0910","020A6B0C",7,,,"11100000","11100000" |
| 148 | + [00:00:07.840,423] <inf> nrf_cloud_coap_cell_location_sample: Connected to network |
| 149 | + [00:00:07.840,515] <inf> nrf_cloud_coap_cell_location_sample: Waiting for modem to acquire network time... |
| 150 | + [00:00:10.841,247] <inf> nrf_cloud_coap_cell_location_sample: Network time obtained |
| 151 | + [00:00:10.841,308] <inf> nrf_cloud_info: Device ID: 7e699894-79b6-11f0-a2b4-db93a314a2aa |
| 152 | + [00:00:10.841,857] <inf> nrf_cloud_info: IMEI: 359400123456789 |
| 153 | + [00:00:10.941,680] <inf> nrf_cloud_info: UUID: 7e699894-79b6-11f0-a2b4-db93a314a2aa |
| 154 | + [00:00:10.948,211] <inf> nrf_cloud_info: Modem FW: mfw_nrf91x1_2.0.2 |
| 155 | + [00:00:10.948,242] <inf> nrf_cloud_info: Protocol: CoAP |
| 156 | + [00:00:10.948,272] <inf> nrf_cloud_info: Download protocol: HTTPS |
| 157 | + [00:00:10.948,303] <inf> nrf_cloud_info: Sec tag: 16842753 |
| 158 | + [00:00:10.948,303] <inf> nrf_cloud_info: CoAP JWT Sec tag: 16842753 |
| 159 | + [00:00:10.948,333] <inf> nrf_cloud_info: Host name: coap.nrfcloud.com |
| 160 | + [00:00:12.721,099] <inf> nrf_cloud_coap_transport: Request authorization with JWT |
| 161 | + [00:00:12.986,877] <inf> nrf_cloud_coap_transport: Authorization result_code: 2.01 |
| 162 | + [00:00:12.986,999] <inf> nrf_cloud_coap_transport: Authorized |
| 163 | + [00:00:12.987,213] <inf> nrf_cloud_coap_transport: DTLS CID is active |
| 164 | + [00:00:13.716,003] <inf> nrf_cloud_coap_cell_location_sample: Device status sent to nRF Cloud |
| 165 | + [00:00:13.716,033] <inf> nrf_cloud_coap_cell_location_sample: Getting current cell info... |
| 166 | + [00:00:13.725,494] <inf> nrf_cloud_coap_cell_location_sample: Current cell info: Cell ID: 34237196, TAC: 2320, MCC: 242, MNC: 2 |
| 167 | + [00:00:13.725,524] <inf> nrf_cloud_coap_cell_location_sample: Performing single-cell request |
| 168 | + [00:00:13.725,524] <inf> nrf_cloud_coap_cell_location_sample: Request configuration: |
| 169 | + [00:00:13.725,555] <inf> nrf_cloud_coap_cell_location_sample: High confidence interval = false |
| 170 | + [00:00:13.725,616] <inf> nrf_cloud_coap_cell_location_sample: Fallback to rough location = true |
| 171 | + [00:00:13.725,646] <inf> nrf_cloud_coap_cell_location_sample: Reply with result = true |
| 172 | + [00:00:13.991,180] <inf> nrf_cloud_coap_cell_location_sample: Cellular location request fulfilled with single-cell |
| 173 | + [00:00:13.991,210] <inf> nrf_cloud_coap_cell_location_sample: Lat: 63.423740, Lon: 10.435896, Uncertainty: 1056 m |
| 174 | +
|
| 175 | +Troubleshooting |
| 176 | +=============== |
| 177 | + |
| 178 | +If you are not getting the output similar to the one in `Testing`_, check the following potential issues: |
| 179 | + |
| 180 | +The network carrier does not provide date and time |
| 181 | + The sample requires the network carrier to provide date and time to the modem. |
| 182 | + Without a valid date and time, the modem cannot generate JWTs with an expiration time. |
| 183 | + |
| 184 | +Dependencies |
| 185 | +************ |
| 186 | + |
| 187 | +This sample uses the following |NCS| libraries: |
| 188 | + |
| 189 | +* :ref:`lib_nrf_cloud` |
| 190 | +* :ref:`lib_nrf_cloud_coap` |
| 191 | +* :ref:`lib_modem_jwt` |
| 192 | +* :ref:`lte_lc_readme` |
| 193 | +* :ref:`modem_info_readme` |
| 194 | +* :ref:`dk_buttons_and_leds_readme` |
| 195 | + |
| 196 | +In addition, it uses the following secure firmware component: |
| 197 | + |
| 198 | +* :ref:`Trusted Firmware-M <ug_tfm>` |
0 commit comments