{"id":13343759,"url":"https://github.com/inductivekickback/timeslot","last_synced_at":"2026-01-24T09:36:12.159Z","repository":{"id":77248177,"uuid":"388686078","full_name":"inductivekickback/timeslot","owner":"inductivekickback","description":"A wrapper around the MPSL Timeslot interface in NCS","archived":false,"fork":false,"pushed_at":"2021-07-31T04:00:49.000Z","size":29,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"main","last_synced_at":"2024-10-24T16:49:15.426Z","etag":null,"topics":["ncs","nordicsemi","zephyr-rtos"],"latest_commit_sha":null,"homepage":"","language":"C","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/inductivekickback.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"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}},"created_at":"2021-07-23T05:19:43.000Z","updated_at":"2021-07-31T04:00:51.000Z","dependencies_parsed_at":null,"dependency_job_id":"6a79836f-2ea2-46c8-be75-c831af227cf4","html_url":"https://github.com/inductivekickback/timeslot","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/inductivekickback%2Ftimeslot","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/inductivekickback%2Ftimeslot/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/inductivekickback%2Ftimeslot/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/inductivekickback%2Ftimeslot/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/inductivekickback","download_url":"https://codeload.github.com/inductivekickback/timeslot/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":243171361,"owners_count":20247876,"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":["ncs","nordicsemi","zephyr-rtos"],"created_at":"2024-07-29T19:32:00.654Z","updated_at":"2026-01-24T09:36:12.153Z","avatar_url":"https://github.com/inductivekickback.png","language":"C","funding_links":[],"categories":[],"sub_categories":[],"readme":"This wrapper is intended to be a reasonable example of how to use the [Timeslot interface](https://developer.nordicsemi.com/nRF_Connect_SDK/doc/latest/nrfxlib/mpsl/doc/timeslot.html) that is built into the [MPSL](https://developer.nordicsemi.com/nRF_Connect_SDK/doc/latest/nrfxlib/mpsl/README.html) in Nordic's [nRF Connect SDK](https://github.com/nrfconnect/sdk-nrf). The objective is to open a recurring timeslot of a fixed length after a BLE connection has been established. Each timeslot has a fixed length and is opened once per Connection Interval. If a library like [ESB](http://developer.nordicsemi.com/nRF_Connect_SDK/doc/1.6.0/nrf/ug_esb.html) is going to be used then a preprocessor symbol called TIMESLOT_CALLS_RADIO_IRQHANDLER can be set to call RADIO_IRQHandler directly from the MPSL_TIMESLOT_SIGNAL_RADIO signal. A \"skipped\" callback is also provided so proprietary networks can stay in sync when timeslots are blocked or cancelled.\n\n---\n### Implementation\n\nTimeslots are synchronized to the active edge of [radio notifications](https://developer.nordicsemi.com/nRF_Connect_SDK/doc/1.6.0/nrfxlib/mpsl/doc/radio_notification.html) so they can follow along with the timing of the BLE connection's Connection Events. The radio notifications feature requires a hardware interrupt vector so a TIMESLOT_IRQN must be defined in timeslot.h (the default is QDEC_IRQn). The MPSL timeslot callback runs as a [Zero Latency IRQ](https://docs.zephyrproject.org/latest/reference/kconfig/CONFIG_ZERO_LATENCY_IRQS.html) and benefits from a hardware interrupt vector so the TIMESLOT_IRQN is also used for lowering the priority of several MPSL interrupts. \n\n---\n### Usage\n\nThe timeslot_config struct and timeslot_cb structs are required.\n```\n#include \u003ctimeslot.h\u003e\n...\nstatic void timeslot_err_cb(int err)\n{\n    LOG_ERR(\"Timeslot session error: %d\", err);\n}\n\nstatic void timeslot_start_cb(void)\n{\n    LOG_DBG(\"Timeslot start\");\n}\n\nstatic void timeslot_end_cb(void)\n{\n    LOG_DBG(\"Timeslot end\");\n}\n\nstatic void timeslot_skipped_cb(uint8_t count)\n{\n    LOG_INF(\"Timeslot skipped: %d\", count);\n}\n\nstatic void timeslot_stopped_cb(void)\n{\n    LOG_INF(\"Timeslot stopped\");\n}\n\n#if !TIMESLOT_CALLS_RADIO_IRQHANDLER\nstatic void radio_irq_cb(void)\n{\n    LOG_DBG(\"Radio_IRQHandler\");\n}\n#endif\n\nstatic struct timeslot_cb timeslot_callbacks = {\n    .error     = timeslot_err_cb,\n    .start     = timeslot_start_cb,\n    .end       = timeslot_end_cb,\n    .skipped   = timeslot_skipped_cb,\n    .stopped   = timeslot_stopped_cb,\n#if !TIMESLOT_CALLS_RADIO_IRQHANDLER\n    .radio_irq = radio_irq_cb\n#endif\n};\n\nstatic struct timeslot_config timeslot_config = TS_DEFAULT_CONFIG;\n...\nvoid main(void)\n{\n    int err = timeslot_open(\u0026timeslot_config, \u0026timeslot_callbacks);\n    if (err) {\n        LOG_ERR(\"timeslot_open failed (err: %d)\", err);\n    }\n...\n```\nA good place to start requesting timeslots is after the BLE connection parameters have settled.\n```\nstatic void conn_param_update(struct bt_conn *conn, uint16_t interval, uint16_t latency, uint16_t timeout)\n{\n...\n    int err = timeslot_start(500);\n    if (err) {\n        LOG_ERR(\"timeslot_start failed (err=%d)\", err);\n    }\n```\nIf the connection parameters change during the connection then the current timeslots can be stopped so they can be restarted in the \"stopped\" callback.\n```\nnext_interval = interval;\nint err = timeslot_stop();\nif (err) {\n    LOG_ERR(\"timeslot_stop failed (err=%d)\", err);\n}\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Finductivekickback%2Ftimeslot","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Finductivekickback%2Ftimeslot","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Finductivekickback%2Ftimeslot/lists"}