/* Schedule Class C session if valid timing is found */
static int32_t multicast_schedule_class_c_session(uint8_t id, uint32_t session_time, uint32_t session_timeout)
/* Schedule Class C session if valid timing is found */
static int32_t multicast_schedule_class_c_session(uint8_t id, uint32_t session_time, uint32_t session_timeout)
{
	uint32_t current_time;
	int32_t time_to_start;
	int err;
	err = lorawan_clock_sync_get(&current_time);
	time_to_start = session_time - current_time;
	if (err != 0 || time_to_start > 0xFFFFFF) {
		LOG_ERR("Clocks not synchronized, cannot schedule class C session");
		time_to_start = 0xFFFFFF;
	} else if (time_to_start >= 0) {
		LOG_DBG("Starting class C session in %d s", time_to_start);
		lorawan_services_reschedule_work(&ctx[id].session_start_work,
						 K_SECONDS(time_to_start));
		lorawan_services_reschedule_work(&ctx[id].session_stop_work,
						 K_SECONDS(time_to_start + session_timeout));
	}
	return time_to_start;
}