{"id":23479466,"url":"https://github.com/thethingsnetwork/lorawan-stack-example-clock","last_synced_at":"2025-06-24T06:08:23.265Z","repository":{"id":98710053,"uuid":"184827063","full_name":"TheThingsNetwork/lorawan-stack-example-clock","owner":"TheThingsNetwork","description":"Example application to synchronize a device clock using class C","archived":false,"fork":false,"pushed_at":"2020-03-13T14:24:43.000Z","size":46,"stargazers_count":5,"open_issues_count":0,"forks_count":3,"subscribers_count":14,"default_branch":"master","last_synced_at":"2025-04-14T21:49:59.898Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"C","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/TheThingsNetwork.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2019-05-03T22:22:56.000Z","updated_at":"2024-12-09T22:53:28.000Z","dependencies_parsed_at":"2023-05-20T13:46:40.933Z","dependency_job_id":null,"html_url":"https://github.com/TheThingsNetwork/lorawan-stack-example-clock","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/TheThingsNetwork/lorawan-stack-example-clock","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/TheThingsNetwork%2Florawan-stack-example-clock","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/TheThingsNetwork%2Florawan-stack-example-clock/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/TheThingsNetwork%2Florawan-stack-example-clock/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/TheThingsNetwork%2Florawan-stack-example-clock/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/TheThingsNetwork","download_url":"https://codeload.github.com/TheThingsNetwork/lorawan-stack-example-clock/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/TheThingsNetwork%2Florawan-stack-example-clock/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":261618130,"owners_count":23185095,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-12-24T19:29:40.689Z","updated_at":"2025-06-24T06:08:23.249Z","avatar_url":"https://github.com/TheThingsNetwork.png","language":"C","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Example: Clock Synchronization\n\nThis is an example project for synchronizing clocks of end devices using class C.\n\nIn LoRaWAN, there are at least three ways for synchronizing end device clocks:\n\n1. Using [application layer clock synchronization](https://lora-alliance.org/resource-hub/lorawan-application-layer-clock-synchronization-specification-v100). This requires request/response messages per end device and do not guarantee exact time synchronization between end devices;\n2. Using class B beacons. This requires gateways with GPS sync and the end device to be aware of time zone and leap seconds;\n3. Using class C messages. This requires the end device only to be aware of time zone.\n\nThis is an example application for method 3: scheduling a class C message at a fixed time, with the absolute time as message payload. Since this is downlink only, this method can be used for unicast and multicast sessions.\n\n## Requirements\n\n1. A LoRaWAN network powered by The Things Network Stack V3 for LoRaWAN. If you do not have a network available, please see the [Getting Started](https://github.com/TheThingsNetwork/lorawan-stack/blob/master/doc/gettingstarted.md).\n2. A LoRa® end device capable of running the Arm Mbed OS, for example the [ST B-L072Z-LRWAN1 LoRa®Discovery kit](https://www.st.com/en/evaluation-tools/b-l072z-lrwan1.html) or [L-TEK FF1705](https://l-tek.si/web-shop/ltek-ff1705/).\n3. A gateway that has either GPS lock or provides round-trip times (RTTs). When relying on RTTs, gateways running LoRa Basics™ Station or Semtech UDP Packet Forwarder 4.0 or higher (sending `TX_ACK`) can be used.\n\n## Getting Started\n\n1. Provision an end device in the LoRaWAN stack supporting class C, for example:\n   ```sh\n   $ ttn-lw-cli end-devices create app1 dev1 \\\n     --dev-eui 0004A30B001C0530 \\\n     --app-eui 800000000000000C \\\n     --frequency-plan-id EU_863_870 \\\n     --root-keys.app-key.key 752BAEC23EAE7964AF27C325F4C23C9A \\\n     --lorawan-version 1.0.3 \\\n     --lorawan-phy-version 1.0.3-a\n     --supports-class-c true\n   ```\n2. [Configure, compile and run the device application](./mbed-os)\n3. [Configure, compile and run the controller](./controller)\n\n## Example\n\nController output:\n\n```\nsync clock dev1: now = 2019-05-10T12:13:33.275Z; target = 2019-05-10T12:13:43.000Z; unix time = 1557490423\n```\n\nDevice output:\n\n```\nReceived message on port 2 (4 bytes): f7 6a d5 5c \nSynchronized clock to Fri May 10 12:13:43 2019\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fthethingsnetwork%2Florawan-stack-example-clock","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fthethingsnetwork%2Florawan-stack-example-clock","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fthethingsnetwork%2Florawan-stack-example-clock/lists"}