Program Listing for File coap_downloader.h
↰ Return to documentation for file (include_public/anj/coap_downloader.h)
/*
* Copyright 2023-2026 AVSystem <avsystem@avsystem.com>
* AVSystem Anjay Lite LwM2M SDK
* All rights reserved.
*
* Licensed under AVSystem Anjay Lite LwM2M Client SDK - Non-Commercial License.
* See the attached LICENSE file for details.
*/
#include <anj/init.h>
#ifndef ANJ_COAP_DOWNLOADER_H
# define ANJ_COAP_DOWNLOADER_H
# include <anj/compat/net/anj_net_api.h>
# include <anj/defs.h>
# define ANJ_INTERNAL_INCLUDE_EXCHANGE
# include <anj_internal/exchange.h>
# undef ANJ_INTERNAL_INCLUDE_EXCHANGE
# ifdef __cplusplus
extern "C" {
# endif
# ifdef ANJ_WITH_COAP_DOWNLOADER
# define ANJ_COAP_DOWNLOADER_ERR_INVALID_URI -1
# define ANJ_COAP_DOWNLOADER_ERR_IN_PROGRESS -2
# define ANJ_COAP_DOWNLOADER_ERR_INVALID_CONFIGURATION -3
# define ANJ_COAP_DOWNLOADER_ERR_TERMINATED -4
# define ANJ_COAP_DOWNLOADER_ERR_NETWORK -5
# define ANJ_COAP_DOWNLOADER_ERR_INVALID_RESPONSE -6
# define ANJ_COAP_DOWNLOADER_ERR_TIMEOUT -7
# define ANJ_COAP_DOWNLOADER_ERR_INTERNAL -8
# define ANJ_COAP_DOWNLOADER_ERR_ETAG_MISMATCH -9
typedef enum {
ANJ_COAP_DOWNLOADER_STATUS_INITIAL,
ANJ_COAP_DOWNLOADER_STATUS_STARTING,
ANJ_COAP_DOWNLOADER_STATUS_DOWNLOADING,
ANJ_COAP_DOWNLOADER_STATUS_FINISHING,
ANJ_COAP_DOWNLOADER_STATUS_FINISHED,
ANJ_COAP_DOWNLOADER_STATUS_FAILED,
} anj_coap_downloader_status_t;
typedef void
anj_coap_downloader_event_callback_t(void *arg,
anj_coap_downloader_t *coap_downloader,
anj_coap_downloader_status_t conn_status,
const uint8_t *data,
size_t data_len);
typedef struct anj_coap_downloader_configuration_struct {
anj_coap_downloader_event_callback_t *event_cb;
void *event_cb_arg;
const anj_exchange_udp_tx_params_t *udp_tx_params;
} anj_coap_downloader_configuration_t;
int anj_coap_downloader_init(anj_coap_downloader_t *coap_downloader,
const anj_coap_downloader_configuration_t *config);
void anj_coap_downloader_step(anj_coap_downloader_t *coap_downloader);
int anj_coap_downloader_start(anj_coap_downloader_t *coap_downloader,
const char *uri,
const anj_net_config_t *net_config);
void anj_coap_downloader_terminate(anj_coap_downloader_t *coap_downloader);
int anj_coap_downloader_get_error(anj_coap_downloader_t *coap_downloader);
# define ANJ_INTERNAL_INCLUDE_COAP_DOWNLOADER
# include <anj_internal/coap_downloader.h>
# undef ANJ_INTERNAL_INCLUDE_COAP_DOWNLOADER
# endif // ANJ_WITH_COAP_DOWNLOADER
# ifdef __cplusplus
}
# endif
#endif // ANJ_COAP_DOWNLOADER_H