From 945610305a77388f3ab24da824b175fc11807f24 Mon Sep 17 00:00:00 2001 From: Nihad Ferhatovic Date: Thu, 9 May 2024 13:07:39 +0200 Subject: [PATCH] Adds description for all methods within server and client c files within examples. --- examples/client/lwm2mclient.c | 189 ++++++++++++++++++++++++++++--- examples/server/lwm2mserver.c | 206 ++++++++++++++++++++++++++++++++++ 2 files changed, 381 insertions(+), 14 deletions(-) diff --git a/examples/client/lwm2mclient.c b/examples/client/lwm2mclient.c index 73e2d703..3f270756 100644 --- a/examples/client/lwm2mclient.c +++ b/examples/client/lwm2mclient.c @@ -95,6 +95,7 @@ lwm2m_object_t * objArray[OBJ_COUNT]; # define BACKUP_OBJECT_COUNT 2 lwm2m_object_t * backupObjectArray[BACKUP_OBJECT_COUNT]; +// Structure to hold client data typedef struct { lwm2m_object_t * securityObjP; @@ -109,6 +110,13 @@ typedef struct int addressFamily; } client_data_t; +/** + * @brief Callback function to quit the LwM2M client. + * + * @param lwm2mH Pointer to the LWM2M context. + * @param buffer Pointer to a character buffer. + * @param user_data User data. + */ static void prv_quit(lwm2m_context_t * lwm2mH, char * buffer, void * user_data) @@ -118,14 +126,30 @@ static void prv_quit(lwm2m_context_t * lwm2mH, (void)buffer; (void)user_data; + // Set the quit flag to terminate the program g_quit = 1; } +/** + * @brief Signal handler for SIGINT (Ctrl+C) for graceful shutdown. + * + * @param lwm2mH LwM2M context. + * @param uri URI of the resource. + */ void handle_sigint(int signum) { + // Set the quit flag to initiate a graceful shutdown g_quit = 2; } +/** + * @brief Callback function for handling value changes in resources. + * + * @param lwm2mH LwM2M context. + * @param uri URI of the resource. + * @param value New value of the resource. + * @param valueLength Length of the new value. + */ void handle_value_changed(lwm2m_context_t * lwm2mH, lwm2m_uri_t * uri, const char * value, @@ -206,6 +230,13 @@ void handle_value_changed(lwm2m_context_t * lwm2mH, } #ifdef WITH_TINYDTLS +/** + * @brief Connects to the LwM2M server using DTLS. + * + * @param secObjInstID Security Object Instance ID. + * @param userData User data. + * @return void* Pointer to the connection object. + */ void * lwm2m_connect_server(uint16_t secObjInstID, void * userData) { @@ -230,6 +261,13 @@ void * lwm2m_connect_server(uint16_t secObjInstID, return (void *)newConnP; } #else +/** + * @brief Connects to the LwM2M server using CoAP. + * + * @param secObjInstID Security Object Instance ID. + * @param userData User data. + * @return void* Pointer to the connection object. + */ void * lwm2m_connect_server(uint16_t secObjInstID, void * userData) { @@ -286,6 +324,12 @@ void * lwm2m_connect_server(uint16_t secObjInstID, } #endif +/** + * @brief Closes the connection. + * + * @param sessionH Session handler. + * @param userData User data. + */ void lwm2m_close_connection(void * sessionH, void * userData) { @@ -329,6 +373,13 @@ void lwm2m_close_connection(void * sessionH, } } +/** + * @brief Outputs information about bootstrap servers and LWM2M servers. + * + * @param lwm2mH Pointer to the LWM2M context. + * @param buffer Pointer to a character buffer. + * @param user_data Unused parameter. + */ static void prv_output_servers(lwm2m_context_t * lwm2mH, char * buffer, void * user_data) @@ -416,6 +467,13 @@ static void prv_output_servers(lwm2m_context_t * lwm2mH, } } +/** + * @brief Handles resource value changes or value change reports. + * + * @param lwm2mH Pointer to the LWM2M context. + * @param buffer Pointer to a character buffer. + * @param user_data Unused parameter. + */ static void prv_change(lwm2m_context_t * lwm2mH, char * buffer, void * user_data) @@ -450,6 +508,13 @@ static void prv_change(lwm2m_context_t * lwm2mH, fprintf(stdout, "Syntax error !\n"); } +/** + * @brief Outputs a list of registered LWM2M objects and their instances. + * + * @param lwm2mH Pointer to the LWM2M context. + * @param buffer Pointer to a character buffer. + * @param user_data Unused parameter. + */ static void prv_object_list(lwm2m_context_t * lwm2mH, char * buffer, void * user_data) @@ -478,6 +543,13 @@ static void prv_object_list(lwm2m_context_t * lwm2mH, } } +/** + * @brief Dumps the TLV data for a given instance of an object. + * + * @param lwm2mH Pointer to the LWM2M context. + * @param objectP Pointer to the LWM2M object structure. + * @param id Instance ID of the object. + */ static void prv_instance_dump(lwm2m_context_t * lwm2mH, lwm2m_object_t * objectP, uint16_t id) @@ -500,6 +572,13 @@ static void prv_instance_dump(lwm2m_context_t * lwm2mH, } +/** + * @brief Dumps the TLV data for an object or its instances. + * + * @param lwm2mH Pointer to the LWM2M context. + * @param buffer Pointer to a character buffer. + * @param user_data Unused parameter. + */ static void prv_object_dump(lwm2m_context_t * lwm2mH, char * buffer, void * user_data) @@ -548,6 +627,13 @@ static void prv_object_dump(lwm2m_context_t * lwm2mH, fprintf(stdout, "Syntax error !\n"); } +/** + * @brief Updates the registration with a specified server. + * + * @param lwm2mH Pointer to the LWM2M context. + * @param buffer Pointer to a character buffer containing the server ID. + * @param user_data Unused parameter. + */ static void prv_update(lwm2m_context_t * lwm2mH, char * buffer, void * user_data) @@ -572,6 +658,13 @@ static void prv_update(lwm2m_context_t * lwm2mH, } #ifndef LWM2M_VERSION_1_0 +/** + * @brief Sends data to specified LWM2M server(s). + * + * @param lwm2mH Pointer to the LWM2M context. + * @param buffer Pointer to a character buffer containing server ID(s) and URI(s). + * @param user_data Unused parameter. + */ static void prv_send(lwm2m_context_t *lwm2mH, char *buffer, void *user_data) { lwm2m_uri_t uri; lwm2m_uri_t *uris = NULL; @@ -637,6 +730,11 @@ static void prv_send(lwm2m_context_t *lwm2mH, char *buffer, void *user_data) { } #endif +/** + * @brief Updates the simulated battery level and reports it to the LWM2M server. + * + * @param context Pointer to the LWM2M context. + */ static void update_battery_level(lwm2m_context_t * context) { static time_t next_change_time = 0; @@ -665,6 +763,13 @@ static void update_battery_level(lwm2m_context_t * context) } } +/** + * @brief Adds a test object to the LWM2M server. + * + * @param lwm2mH Pointer to the LWM2M context. + * @param buffer Pointer to a character buffer. + * @param user_data Unused parameter. + */ static void prv_add(lwm2m_context_t * lwm2mH, char * buffer, void * user_data) @@ -695,6 +800,13 @@ static void prv_add(lwm2m_context_t * lwm2mH, return; } +/** + * @brief Removes the specified object from the LWM2M server. + * + * @param lwm2mH Pointer to the LWM2M context. + * @param buffer Pointer to a character buffer. + * @param user_data Unused parameter. + */ static void prv_remove(lwm2m_context_t * lwm2mH, char * buffer, void * user_data) @@ -719,7 +831,13 @@ static void prv_remove(lwm2m_context_t * lwm2mH, } #ifdef LWM2M_BOOTSTRAP - +/** + * @brief Initiates the bootstrap process by resetting the state and lifetime of bootstrap servers. + * + * @param lwm2mH Pointer to the LWM2M context. + * @param buffer Pointer to a character buffer. + * @param user_data Unused parameter. + */ static void prv_initiate_bootstrap(lwm2m_context_t * lwm2mH, char * buffer, void * user_data) @@ -739,6 +857,13 @@ static void prv_initiate_bootstrap(lwm2m_context_t * lwm2mH, } } +/** + * @brief Displays the backup of security and server objects. + * + * @param lwm2mH Pointer to the LWM2M context. + * @param buffer Pointer to a character buffer. + * @param user_data Unused parameter. + */ static void prv_display_backup(lwm2m_context_t * lwm2mH, char * buffer, void * user_data) @@ -768,6 +893,11 @@ static void prv_display_backup(lwm2m_context_t * lwm2mH, } } +/** + * @brief Backs up the content of security and server objects. + * + * @param context Pointer to the LWM2M context. + */ static void prv_backup_objects(lwm2m_context_t * context) { uint16_t i; @@ -799,6 +929,11 @@ static void prv_backup_objects(lwm2m_context_t * context) copy_server_object(backupObjectArray[1], (lwm2m_object_t *)LWM2M_LIST_FIND(context->objectList, LWM2M_SERVER_OBJECT_ID)); } +/** + * @brief Restores the content of security and server objects from backup. + * + * @param context Pointer to the LWM2M context. + */ static void prv_restore_objects(lwm2m_context_t * context) { lwm2m_object_t * targetP; @@ -822,6 +957,12 @@ static void prv_restore_objects(lwm2m_context_t * context) fprintf(stdout, "[BOOTSTRAP] ObjectList restored\r\n"); } +/** + * @brief Updates the bootstrap information based on changes in the context state. + * + * @param previousBootstrapState Pointer to the previous bootstrap state. + * @param context Pointer to the LWM2M context. + */ static void update_bootstrap_info(lwm2m_client_state_t * previousBootstrapState, lwm2m_context_t * context) { @@ -842,6 +983,9 @@ static void update_bootstrap_info(lwm2m_client_state_t * previousBootstrapState, } } +/** + * @brief Closes backup objects by cleaning up and freeing memory. + */ static void close_backup_object(void) { int i; for (i = 0; i < BACKUP_OBJECT_COUNT; i++) { @@ -864,6 +1008,13 @@ static void close_backup_object(void) { } #endif +/** + * @brief Displays the objects present in the LWM2M context. + * + * @param lwm2mH Pointer to the LWM2M context. + * @param buffer Pointer to a character buffer. + * @param user_data Unused parameter. + */ static void prv_display_objects(lwm2m_context_t *lwm2mH, char *buffer, void *user_data) { lwm2m_object_t *object; @@ -905,6 +1056,9 @@ static void prv_display_objects(lwm2m_context_t *lwm2mH, char *buffer, void *use } } +/** + * @brief Prints usage instructions for the LWM2M client. + */ void print_usage(void) { fprintf(stdout, "Usage: lwm2mclient [OPTION]\r\n"); @@ -927,21 +1081,28 @@ void print_usage(void) fprintf(stdout, "\r\n"); } +/** + * @brief Main function. + * + * @param argc Argument count - number of arguments. + * @param argv Argument vector. + * @return Execution status. + */ int main(int argc, char *argv[]) { - client_data_t data; - int result; - lwm2m_context_t * lwm2mH = NULL; - const char * localPort = "56830"; - const char * server = NULL; - const char * serverPort = LWM2M_STANDARD_PORT_STR; - const char *name = "testlwm2mclient"; - int lifetime = 300; - int batterylevelchanging = 0; - time_t reboot_time = 0; - int opt; - bool bootstrapRequested = false; - bool serverPortChanged = false; + client_data_t data; // Structure for client data + int result; // Variable to store the result of operations + lwm2m_context_t * lwm2mH = NULL; // Pointer to LWM2M context + const char * localPort = "56830"; // Default local UDP port + const char * server = NULL; // Pointer to server address + const char * serverPort = LWM2M_STANDARD_PORT_STR; // Default server port + const char *name = "testlwm2mclient"; // Default client name + int lifetime = 300; // Default client lifetime + int batterylevelchanging = 0; // Flag to indicate battery level change + time_t reboot_time = 0; // Time for rebooting + int opt; // Variable for command line options + bool bootstrapRequested = false; // Flag to indicate bootstrap request + bool serverPortChanged = false; // Flag to indicate if server port is changed #ifdef LWM2M_BOOTSTRAP lwm2m_client_state_t previousState = STATE_INITIAL; diff --git a/examples/server/lwm2mserver.c b/examples/server/lwm2mserver.c index 74fd031a..23c0781f 100644 --- a/examples/server/lwm2mserver.c +++ b/examples/server/lwm2mserver.c @@ -77,12 +77,23 @@ static int g_quit = 0; +/** + * @brief Prints an error message based on the provided status. + * + * @param status The status code representing the error. + */ static void prv_print_error(uint8_t status) { fprintf(stdout, "Error: "); print_status(stdout, status); fprintf(stdout, "\r\n"); } +/** + * @brief Returns a string representation of the provided LwM2M version. + * + * @param version The LwM2M version. + * @returns A string representing the LwM2M version. + */ static const char *prv_dump_version(lwm2m_version_t version) { switch (version) { case VERSION_MISSING: @@ -98,6 +109,11 @@ static const char *prv_dump_version(lwm2m_version_t version) { } } +/** + * @brief Prints the binding mode of a client. + * + * @param binding The binding mode of the client. + */ static void prv_dump_binding(lwm2m_binding_t binding) { if (BINDING_UNKNOWN == binding) { fprintf(stdout, "\tbinding: \"Not specified\"\r\n"); @@ -126,6 +142,11 @@ static void prv_dump_binding(lwm2m_binding_t binding) { } } +/** + * @brief Prints details of a client. + * + * @param targetP Pointer to the client structure. + */ static void prv_dump_client(lwm2m_client_t *targetP) { lwm2m_client_object_t *objectP; @@ -161,6 +182,13 @@ static void prv_dump_client(lwm2m_client_t *targetP) { fprintf(stdout, "\r\n"); } +/** + * @brief Prints details of all registered clients. + * + * @param lwm2mH Pointer to the LwM2M context. + * @param buffer Buffer for output. + * @param user_data User data (unused). + */ static void prv_output_clients(lwm2m_context_t *lwm2mH, char *buffer, void *user_data) { lwm2m_client_t *targetP; @@ -179,6 +207,13 @@ static void prv_output_clients(lwm2m_context_t *lwm2mH, char *buffer, void *user } } +/** + * @brief Reads an ID from a buffer. + * + * @param buffer Buffer containing the ID. + * @param idP Pointer to store the read ID. + * @returns The number of items successfully read. + */ static int prv_read_id(char *buffer, uint16_t *idP) { int nb; int value; @@ -195,6 +230,11 @@ static int prv_read_id(char *buffer, uint16_t *idP) { return nb; } +/** + * @brief Prints a URI. + * + * @param uriP Pointer to the URI structure. + */ static void prv_printUri(const lwm2m_uri_t *uriP) { fprintf(stdout, "/%d", uriP->objectId); if (LWM2M_URI_IS_SET_INSTANCE(uriP)) @@ -211,6 +251,19 @@ static void prv_printUri(const lwm2m_uri_t *uriP) { #endif } +/** + * @brief Callback function to handle result of an operation. + * + * @param contextP Pointer to the LwM2M context. + * @param clientID ID of the client. + * @param uriP Pointer to the URI structure. + * @param status Status of the operation. + * @param block_info Pointer to block information. + * @param format Media type format. + * @param data Pointer to data. + * @param dataLength: Length of the data. + * @param userData: User data (unused). + */ static void prv_result_callback(lwm2m_context_t *contextP, uint16_t clientID, lwm2m_uri_t *uriP, int status, block_info_t *block_info, lwm2m_media_type_t format, uint8_t *data, size_t dataLength, void *userData) { @@ -230,6 +283,19 @@ static void prv_result_callback(lwm2m_context_t *contextP, uint16_t clientID, lw fflush(stdout); } +/** + * @brief Callback function to handle notifications. + * + * @param contextP Pointer to the LwM2M context. + * @param clientID ID of the client. + * @param uriP Pointer to the URI structure. + * @param count Notification count. + * @param block_info Pointer to block information. + * @param format Media type format. + * @param data Pointer to data. + * @param dataLength: Length of the data. + * @param userData: User data (unused). + */ static void prv_notify_callback(lwm2m_context_t *contextP, uint16_t clientID, lwm2m_uri_t *uriP, int count, block_info_t *block_info, lwm2m_media_type_t format, uint8_t *data, size_t dataLength, void *userData) { @@ -247,6 +313,13 @@ static void prv_notify_callback(lwm2m_context_t *contextP, uint16_t clientID, lw fflush(stdout); } +/** + * @brief Reads data from a client. + * + * @param lwm2mH Pointer to the LwM2M context. + * @param buffer Buffer containing client data. + * @param user_data User data (unused). + */ static void prv_read_client(lwm2m_context_t *lwm2mH, char *buffer, void *user_data) { uint16_t clientId; lwm2m_uri_t uri; @@ -284,6 +357,13 @@ static void prv_read_client(lwm2m_context_t *lwm2mH, char *buffer, void *user_da fprintf(stdout, "Syntax error !"); } +/** + * @brief Discovers resources of a client. + * + * @param lwm2mH Pointer to the LwM2M context. + * @param buffer Buffer containing client data. + * @param user_data User data (unused). + */ static void prv_discover_client(lwm2m_context_t *lwm2mH, char *buffer, void *user_data) { uint16_t clientId; lwm2m_uri_t uri; @@ -321,6 +401,13 @@ static void prv_discover_client(lwm2m_context_t *lwm2mH, char *buffer, void *use fprintf(stdout, "Syntax error !"); } +/** + * @brief Writes data to a client. + * + * @param buffer Buffer containing client data. + * @param lwm2mH Pointer to the LwM2M context. + * @param partialUpdate Flag indicating whether it's a partial update. + */ static void prv_do_write_client(char *buffer, lwm2m_context_t *lwm2mH, bool partialUpdate) { uint16_t clientId; lwm2m_uri_t uri; @@ -394,6 +481,13 @@ static void prv_do_write_client(char *buffer, lwm2m_context_t *lwm2mH, bool part fprintf(stdout, "Syntax error !"); } +/** + * @brief Writes data to the LwM2M client. + * + * @param lwm2mH Pointer to the LwM2M context. + * @param buffer Data buffer containing information to be written. + * @param user_data User data (unused). + */ static void prv_write_client(lwm2m_context_t *lwm2mH, char *buffer, void *user_data) { /* unused parameter */ (void)user_data; @@ -401,6 +495,13 @@ static void prv_write_client(lwm2m_context_t *lwm2mH, char *buffer, void *user_d prv_do_write_client(buffer, lwm2mH, false); } +/** + * @brief Updates data on the LwM2M client. + * + * @param lwm2mH Pointer to the LwM2M context. + * @param buffer Data buffer containing information to be updated. + * @param user_data User data (unused). + */ static void prv_update_client(lwm2m_context_t *lwm2mH, char *buffer, void *user_data) { /* unused parameter */ (void)user_data; @@ -408,6 +509,13 @@ static void prv_update_client(lwm2m_context_t *lwm2mH, char *buffer, void *user_ prv_do_write_client(buffer, lwm2mH, true); } +/** + * @brief Sets time-related attributes for the LwM2M client. + * + * @param lwm2mH Pointer to the LwM2M context. + * @param buffer Data buffer containing attribute information. + * @param user_data User data (unused). + */ static void prv_time_client(lwm2m_context_t *lwm2mH, char *buffer, void *user_data) { uint16_t clientId; lwm2m_uri_t uri; @@ -473,6 +581,13 @@ static void prv_time_client(lwm2m_context_t *lwm2mH, char *buffer, void *user_da fprintf(stdout, "Syntax error !"); } +/** + * @brief Sets value-related attributes for the LwM2M client. + * + * @param lwm2mH Pointer to the LwM2M context. + * @param buffer Data buffer containing attribute information. + * @param user_data User data (unused). + */ static void prv_attr_client(lwm2m_context_t *lwm2mH, char *buffer, void *user_data) { uint16_t clientId; lwm2m_uri_t uri; @@ -544,6 +659,13 @@ static void prv_attr_client(lwm2m_context_t *lwm2mH, char *buffer, void *user_da fprintf(stdout, "Syntax error !"); } +/** + * @brief Clears attributes for the LwM2M client. + * + * @param lwm2mH Pointer to the LwM2M context. + * @param buffer Data buffer containing attribute information. + * @param user_data User data (unused). + */ static void prv_clear_client(lwm2m_context_t *lwm2mH, char *buffer, void *user_data) { uint16_t clientId; lwm2m_uri_t uri; @@ -587,6 +709,13 @@ static void prv_clear_client(lwm2m_context_t *lwm2mH, char *buffer, void *user_d fprintf(stdout, "Syntax error !"); } +/** + * @brief Executes a command on the LwM2M client. + * + * @param lwm2mH Pointer to the LwM2M context. + * @param buffer Data buffer containing command information. + * @param user_data User data (unused). + */ static void prv_exec_client(lwm2m_context_t *lwm2mH, char *buffer, void *user_data) { uint16_t clientId; lwm2m_uri_t uri; @@ -631,6 +760,13 @@ static void prv_exec_client(lwm2m_context_t *lwm2mH, char *buffer, void *user_da fprintf(stdout, "Syntax error !"); } +/** + * @brief Creates a new object instance on the LwM2M client. + * + * @param lwm2mH Pointer to the LwM2M context. + * @param buffer Data buffer containing object instance information. + * @param user_data User data (unused). + */ static void prv_create_client(lwm2m_context_t *lwm2mH, char *buffer, void *user_data) { uint16_t clientId; lwm2m_uri_t uri; @@ -735,6 +871,13 @@ static void prv_create_client(lwm2m_context_t *lwm2mH, char *buffer, void *user_ fprintf(stdout, "Syntax error !"); } +/** + * @brief Deletes an object instance on the LwM2M client. + * + * @param lwm2mH Pointer to the LwM2M context. + * @param buffer Data buffer containing object instance information. + * @param user_data User data (unused). + */ static void prv_delete_client(lwm2m_context_t *lwm2mH, char *buffer, void *user_data) { uint16_t clientId; lwm2m_uri_t uri; @@ -772,6 +915,13 @@ static void prv_delete_client(lwm2m_context_t *lwm2mH, char *buffer, void *user_ fprintf(stdout, "Syntax error !"); } +/** + * @brief Observes a resource on the LwM2M client. + * + * @param lwm2mH Pointer to the LwM2M context. + * @param buffer Data buffer containing observation information. + * @param user_data User data (unused). + */ static void prv_observe_client(lwm2m_context_t *lwm2mH, char *buffer, void *user_data) { uint16_t clientId; lwm2m_uri_t uri; @@ -809,6 +959,13 @@ static void prv_observe_client(lwm2m_context_t *lwm2mH, char *buffer, void *user fprintf(stdout, "Syntax error !"); } +/** + * @brief Cancels an observation on the LwM2M client. + * + * @param lwm2mH Pointer to the LwM2M context. + * @param buffer Data buffer containing observation cancellation information. + * @param user_data User data (unused). + */ static void prv_cancel_client(lwm2m_context_t *lwm2mH, char *buffer, void *user_data) { uint16_t clientId; lwm2m_uri_t uri; @@ -846,6 +1003,19 @@ static void prv_cancel_client(lwm2m_context_t *lwm2mH, char *buffer, void *user_ fprintf(stdout, "Syntax error !"); } +/** + * @brief Callback function for monitoring client registrations, updates, and unregistrations. + * + * @param lwm2mH Pointer to the LwM2M context. + * @param clientID ID of the client. + * @param uriP Pointer to the URI structure. + * @param status Status of the operation. + * @param block_info Pointer to block information. + * @param format Media format of the data. + * @param data Pointer to the data. + * @param dataLength Length of the data. + * @param userData User data (unused). + */ static void prv_monitor_callback(lwm2m_context_t *lwm2mH, uint16_t clientID, lwm2m_uri_t *uriP, int status, block_info_t *block_info, lwm2m_media_type_t format, uint8_t *data, size_t dataLength, void *userData) { @@ -884,16 +1054,32 @@ static void prv_monitor_callback(lwm2m_context_t *lwm2mH, uint16_t clientID, lwm fflush(stdout); } +/** + * @brief Callback function to quit the LwM2M server. + * + * @param lwm2mH Pointer to the LwM2M context (unused). + * @param buffer Pointer to the data buffer. + * @param user_data User data (unused). + */ static void prv_quit(lwm2m_context_t *lwm2mH, char *buffer, void *user_data) { /* unused parameters */ (void)lwm2mH; (void)user_data; + // Set the quit flag to terminate the program g_quit = 1; } +/** + * @brief Handles the SIGINT signal to quit the server. + * + * @param signum Signal number. + */ void handle_sigint(int signum) { g_quit = 2; } +/** + * @brief Prints usage information for the server. + */ void print_usage(void) { fprintf(stderr, "Usage: lwm2mserver [OPTION]\r\n"); fprintf(stderr, "Launch a LWM2M server on localhost.\r\n\n"); @@ -905,6 +1091,9 @@ void print_usage(void) { fprintf(stdout, "\r\n"); } +/** + * @brief Array containing command descriptions. + */ command_desc_t commands[] = {{"list", "List registered clients.", NULL, prv_output_clients, NULL}, {"read", "Read from a client.", " read CLIENT# URI\r\n" @@ -992,6 +1181,9 @@ command_desc_t commands[] = {{"list", "List registered clients.", NULL, prv_outp COMMAND_END_LIST}; +/** + * @brief Starts the CoAP server. + */ void startCoapServer() { int sock; const char *localPort = LWM2M_STANDARD_PORT_STR; @@ -1113,10 +1305,24 @@ void startCoapServer() { close(sock); connection_free(connList); } + +/** + * @brief Returns a test link. + * + * @return Test link string. + */ const char *testLink() { const char *mystr = "Hello from Wakaama server source !!!"; return mystr; } + +/** + * @brief Main function. + * + * @param argc Argument count - number of arguments. + * @param argv Argument vector. + * @return Execution status. + */ int main(int argc, char *argv[]) { // int addressFamily = AF_INET6; int opt;