Complete session example

This section describes a complete Radio Timeslot session.

Complete Radio Timeslot session example shows a complete Timeslot session. In this case, only timeslot requests from the application are being scheduled, and there is no SoftDevice activity.

At start, the application calls the Application Programming Interface (API) to open a session and to request a first timeslot (which must be of type earliest possible). The SoftDevice schedules the timeslot. At the start of the timeslot, the SoftDevice calls the application signal handler with the START signal. After this, the application is in control and has access to the peripherals. The application will then typically set up TIMER0 to expire before the end of the timeslot to get a signal indicating that the timeslot is about to end. In the last signal in the timeslot, the application uses the signal handler return action to request a new timeslot 100 ms after the first.

All subsequent timeslots are similar. The signal handler is called with the START signal at the start of the timeslot. The application then has control, but must arrange for a signal to come towards the end of the timeslot. As the return value for the last signal in the timeslot, the signal handler requests a new timeslot using the REQUEST_AND_END action.

Eventually, the application does not require the radio any more. Therefore, at the last signal in the last timeslot, the application returns END from the signal handler. The SoftDevice then sends an IDLE event to the application event handler. The application calls session_close, and the SoftDevice sends the CLOSED event. The session has now ended.

Figure 1. Complete Radio Timeslot session example
Complete Radio Timeslot session example

LowerStack denotes the interrupt level for SoftDevice API calls and non-time-critical processing, and App(L) denotes the selected low-priority application interrupt level. See Interrupt priority levels for the available interrupt levels.