blob: 7e1190e971c41caa75f54f982f06d01f762af75b [file] [log] [blame]
/*
* Copyright (c) 2022 Martin Jäger <martin@libre.solar>
* Copyright (c) 2022 tado GmbH
*
* SPDX-License-Identifier: Apache-2.0
*/
#ifndef ZEPHYR_SUBSYS_LORAWAN_SERVICES_LORAWAN_SERVICES_H_
#define ZEPHYR_SUBSYS_LORAWAN_SERVICES_LORAWAN_SERVICES_H_
#include <zephyr/kernel.h>
#include <zephyr/lorawan/lorawan.h>
/**
* Unique package identifiers used for LoRaWAN services.
*/
enum lorawan_package_id {
LORAWAN_PACKAGE_ID_COMPLIANCE = 0,
LORAWAN_PACKAGE_ID_CLOCK_SYNC = 1,
LORAWAN_PACKAGE_ID_REMOTE_MULTICAST_SETUP = 2,
LORAWAN_PACKAGE_ID_FRAG_TRANSPORT_BLOCK = 3,
};
/**
* Default ports used for LoRaWAN services.
*/
enum lorawan_services_port {
LORAWAN_PORT_MULTICAST = 200,
LORAWAN_PORT_FRAG_TRANSPORT = 201,
LORAWAN_PORT_CLOCK_SYNC = 202,
};
/**
* @brief Send unconfirmed LoRaWAN uplink message after the specified timeout
*
* @param port Port to be used for sending data.
* @param data Data buffer to be sent.
* @param len Length of the data to be sent. Maximum length of the
* buffer is 18 bytes.
* @param timeout Relative timeout in milliseconds when the uplink message
* should be scheduled.
*
* @return 0 if message was successfully queued, negative errno otherwise.
*/
int lorawan_services_schedule_uplink(uint8_t port, uint8_t *data, uint8_t len, uint32_t timeout);
/**
* @brief Reschedule a delayable work item to the LoRaWAN services work queue
*
* This work queue is used to schedule the uplink messages, but can be used by
* any of the services for internal tasks.
*
* @param dwork pointer to the delayable work item.
* @param delay the time to wait before submitting the work item.
* @returns Result of call to k_work_reschedule_for_queue()
*/
int lorawan_services_reschedule_work(struct k_work_delayable *dwork, k_timeout_t delay);
#endif /* ZEPHYR_SUBSYS_LORAWAN_SERVICES_LORAWAN_SERVICES_H_ */