MeshX 0.4
This repository provides an implementation for Bluetooth Low Energy (BLE) Mesh network nodes. The project allows you to create BLE mesh nodes that can communicate with each other, enabling the development of smart home solutions or other IoT-based applications.
Loading...
Searching...
No Matches
meshx_ble_mesh_gen_srv.h File Reference

Header file for Generic Server Models in MeshX BLE Mesh. More...

Go to the source code of this file.

Data Structures

struct  meshx_state_change_gen_onoff_set_t
struct  meshx_state_change_gen_level_set_t
struct  meshx_state_change_gen_delta_set_t
struct  meshx_state_change_gen_move_set_t
struct  meshx_state_change_gen_def_trans_time_set_t
struct  meshx_state_change_gen_onpowerup_set_t
struct  meshx_state_change_gen_power_level_set_t
struct  meshx_state_change_gen_power_default_set_t
struct  meshx_state_change_gen_power_range_set_t
struct  meshx_state_change_gen_loc_global_set_t
struct  meshx_state_change_gen_loc_local_set_t
struct  meshx_state_change_gen_user_property_set_t
struct  meshx_state_change_gen_admin_property_set_t
struct  meshx_state_change_gen_manu_property_set_t
union  meshx_gen_srv_state_change_t
struct  meshx_gen_srv_cb_param
struct  meshx_gen_onoff_state_t
struct  meshx_gen_level_state_t
struct  meshx_gen_battery_state_t
struct  meshx_gen_location_state_t
struct  meshx_gen_onpowerup_state_t
struct  meshx_gen_power_level_state_t
struct  meshx_gen_def_trans_time_state_t
struct  meshx_gen_server_state
 Generic Server Model state Used to set/restore the model state values internally. More...

Typedefs

typedef struct meshx_gen_srv_cb_param meshx_gen_srv_cb_param_t
typedef struct meshx_gen_server_state meshx_gen_server_state_t
 Generic Server Model state Used to set/restore the model state values internally.
typedef control_task_msg_handle_t meshx_server_cb

Functions

meshx_err_t meshx_plat_on_off_gen_srv_create (void *p_model, void **p_pub, void **p_onoff_srv)
 Creates a Generic OnOff Server model and its publication context.
meshx_err_t meshx_plat_level_gen_srv_create (void *p_model, void **p_pub, void **p_level_srv)
 Creates a Generic Level Server model and its publication context.
meshx_err_t meshx_plat_battery_gen_srv_create (void *p_model, void **p_pub, void **p_battery_srv)
 Creates a Generic Battery Server model and its publication context.
meshx_err_t meshx_plat_location_gen_srv_create (void *p_model, void **p_pub, void **p_location_srv)
 Creates a Generic Location Server model and its publication context.
meshx_err_t meshx_plat_power_onoff_gen_srv_create (void *p_model, void **p_pub, void **p_power_onoff_srv)
 Creates a Generic Power OnOff Server model and its publication context.
meshx_err_t meshx_plat_power_onoff_setup_gen_srv_create (void *p_model, void **p_pub, void **p_power_onoff_setup_srv)
 Creates a Generic Power OnOff Setup Server model and its publication context.
meshx_err_t meshx_plat_power_level_gen_srv_create (void *p_model, void **p_pub, void **p_power_level_srv)
 Creates a Generic Power Level Server model and its publication context.
meshx_err_t meshx_plat_def_trans_time_gen_srv_create (void *p_model, void **p_pub, void **p_trans_time_srv)
 Creates a Generic Default Transition Time Server model and its publication context.
meshx_err_t meshx_plat_gen_srv_delete (void **p_pub, void **p_srv)
 Deletes the Generic OnOff Server model and its associated resources.
meshx_err_t meshx_plat_gen_srv_init (void)
 Initialize the generic server model platform.
meshx_err_t meshx_plat_set_gen_srv_state (void *p_model, const meshx_gen_server_state_t *state, uint16_t state_len)
 Set the state of a generic server model.
meshx_err_t meshx_plat_gen_on_off_srv_restore (void *p_model, uint8_t state)
 Restores the state of the Generic OnOff Server model.
meshx_err_t meshx_plat_gen_srv_send_status (meshx_model_t *p_model, meshx_ctx_t *p_ctx, meshx_ptr_t p_data, uint32_t data_len)
 Send a status message from the Generic Server model.

Detailed Description

Header file for Generic Server Models in MeshX BLE Mesh.

Copyright (c) 2024 - 2025 MeshX

This file defines the structures, types, and APIs for implementing Generic Server Models in the MeshX BLE Mesh stack. It includes definitions for various state change events, server callbacks, and functions to create, delete, and manage the state of Generic Server Models.

Author
Pranjal Chanda

Typedef Documentation

◆ meshx_gen_server_state_t

Generic Server Model state Used to set/restore the model state values internally.

◆ meshx_gen_srv_cb_param_t

◆ meshx_server_cb

Function Documentation

◆ meshx_plat_battery_gen_srv_create()

meshx_err_t meshx_plat_battery_gen_srv_create ( void * p_model,
void ** p_pub,
void ** p_battery_srv )

Creates a Generic Battery Server model and its publication context.

This function initializes the Generic Battery Server model, its publication context, and allocates memory for the server instance. It checks for invalid arguments and handles memory allocation failures.

Parameters
[out]p_modelPointer to the model structure to be created.
[out]p_pubPointer to the publication context to be created.
[out]p_battery_srvPointer to the Battery server instance to be allocated.
Returns
  • MESHX_SUCCESS: Successfully created the model and publication context.
  • MESHX_INVALID_ARG: One or more arguments are invalid.
  • MESHX_NO_MEM: Memory allocation failed.

◆ meshx_plat_def_trans_time_gen_srv_create()

meshx_err_t meshx_plat_def_trans_time_gen_srv_create ( void * p_model,
void ** p_pub,
void ** p_trans_time_srv )

Creates a Generic Default Transition Time Server model and its publication context.

This function initializes the Generic Default Transition Time Server model, its publication context, and allocates memory for the server instance. It checks for invalid arguments and handles memory allocation failures.

Parameters
[out]p_modelPointer to the model structure to be created.
[out]p_pubPointer to the publication context to be created.
[out]p_trans_time_srvPointer to the Default Transition Time server instance to be allocated.
Returns
  • MESHX_SUCCESS: Successfully created the model and publication context.
  • MESHX_INVALID_ARG: One or more arguments are invalid.
  • MESHX_NO_MEM: Memory allocation failed.

◆ meshx_plat_gen_on_off_srv_restore()

meshx_err_t meshx_plat_gen_on_off_srv_restore ( void * p_model,
uint8_t state )

Restores the state of the Generic OnOff Server model.

This function sets the user data of the specified model to the given state. It checks if the model pointer is valid before proceeding with the operation.

Parameters
[in]p_modelPointer to the model structure.
[in]stateThe state to be restored in the model.
Returns
  • MESHX_SUCCESS: State restored successfully.
  • MESHX_INVALID_ARG: Invalid model pointer.

◆ meshx_plat_gen_srv_delete()

meshx_err_t meshx_plat_gen_srv_delete ( void ** p_pub,
void ** p_srv )

Deletes the Generic OnOff Server model and its associated resources.

This function frees the memory allocated for the Generic OnOff Server and sets the pointer to NULL. It also deletes the model publication resources associated with the server.

Parameters
[in,out]p_pubPointer to the publication structure to be deleted.
[in,out]p_srvPointer to the Generic Server structure to be freed.
Returns
  • MESHX_SUCCESS: Model and publication deleted successfully.
  • MESHX_FAIL: Failed to delete the model or publication.

◆ meshx_plat_gen_srv_init()

meshx_err_t meshx_plat_gen_srv_init ( void )

Initialize the generic server model platform.

Returns
MESHX_SUCCESS on success, or an appropriate error code on failure.

◆ meshx_plat_gen_srv_send_status()

meshx_err_t meshx_plat_gen_srv_send_status ( meshx_model_t * p_model,
meshx_ctx_t * p_ctx,
meshx_ptr_t p_data,
uint32_t data_len )

Send a status message from the Generic Server model.

This function sends a status message to the specified context with the provided data.

Parameters
[in]p_modelPointer to the model instance.
[in]p_ctxPointer to the context structure containing destination address and other parameters.
[in]p_dataPointer to the data to be sent.
[in]data_lenLength of the data to be sent.
Returns
  • MESHX_SUCCESS: Message sent successfully.
  • MESHX_NO_MEM: Memory allocation failed.
  • MESHX_ERR_PLAT: Platform error occurred while sending the message.

◆ meshx_plat_level_gen_srv_create()

meshx_err_t meshx_plat_level_gen_srv_create ( void * p_model,
void ** p_pub,
void ** p_level_srv )

Creates a Generic Level Server model and its publication context.

This function initializes the Generic Level Server model, its publication context, and allocates memory for the server instance. It checks for invalid arguments and handles memory allocation failures.

Parameters
[out]p_modelPointer to the model structure to be created.
[out]p_pubPointer to the publication context to be created.
[out]p_level_srvPointer to the Level server instance to be allocated.
Returns
  • MESHX_SUCCESS: Successfully created the model and publication context.
  • MESHX_INVALID_ARG: One or more arguments are invalid.
  • MESHX_NO_MEM: Memory allocation failed.

◆ meshx_plat_location_gen_srv_create()

meshx_err_t meshx_plat_location_gen_srv_create ( void * p_model,
void ** p_pub,
void ** p_location_srv )

Creates a Generic Location Server model and its publication context.

This function initializes the Generic Location Server model, its publication context, and allocates memory for the server instance. It checks for invalid arguments and handles memory allocation failures.

Parameters
[out]p_modelPointer to the model structure to be created.
[out]p_pubPointer to the publication context to be created.
[out]p_location_srvPointer to the Location server instance to be allocated.
Returns
  • MESHX_SUCCESS: Successfully created the model and publication context.
  • MESHX_INVALID_ARG: One or more arguments are invalid.
  • MESHX_NO_MEM: Memory allocation failed.

◆ meshx_plat_on_off_gen_srv_create()

meshx_err_t meshx_plat_on_off_gen_srv_create ( void * p_model,
void ** p_pub,
void ** p_onoff_srv )

Creates a Generic OnOff Server model and its publication context.

This function initializes the Generic OnOff Server model, its publication context, and allocates memory for the server instance. It checks for invalid arguments and handles memory allocation failures.

Parameters
[out]p_modelPointer to the model structure to be created.
[out]p_pubPointer to the publication context to be created.
[out]p_onoff_srvPointer to the OnOff server instance to be allocated.
Returns
  • MESHX_SUCCESS: Successfully created the model and publication context.
  • MESHX_INVALID_ARG: One or more arguments are invalid.
  • MESHX_NO_MEM: Memory allocation failed.

◆ meshx_plat_power_level_gen_srv_create()

meshx_err_t meshx_plat_power_level_gen_srv_create ( void * p_model,
void ** p_pub,
void ** p_power_level_srv )

Creates a Generic Power Level Server model and its publication context.

This function initializes the Generic Power Level Server model, its publication context, and allocates memory for the server instance. It checks for invalid arguments and handles memory allocation failures.

Parameters
[out]p_modelPointer to the model structure to be created.
[out]p_pubPointer to the publication context to be created.
[out]p_power_level_srvPointer to the Power Level server instance to be allocated.
Returns
  • MESHX_SUCCESS: Successfully created the model and publication context.
  • MESHX_INVALID_ARG: One or more arguments are invalid.
  • MESHX_NO_MEM: Memory allocation failed.

◆ meshx_plat_power_onoff_gen_srv_create()

meshx_err_t meshx_plat_power_onoff_gen_srv_create ( void * p_model,
void ** p_pub,
void ** p_power_onoff_srv )

Creates a Generic Power OnOff Server model and its publication context.

This function initializes the Generic Power OnOff Server model, its publication context, and allocates memory for the server instance. It checks for invalid arguments and handles memory allocation failures.

Parameters
[out]p_modelPointer to the model structure to be created.
[out]p_pubPointer to the publication context to be created.
[out]p_power_onoff_srvPointer to the Power OnOff server instance to be allocated.
Returns
  • MESHX_SUCCESS: Successfully created the model and publication context.
  • MESHX_INVALID_ARG: One or more arguments are invalid.
  • MESHX_NO_MEM: Memory allocation failed.

◆ meshx_plat_power_onoff_setup_gen_srv_create()

meshx_err_t meshx_plat_power_onoff_setup_gen_srv_create ( void * p_model,
void ** p_pub,
void ** p_power_onoff_setup_srv )

Creates a Generic Power OnOff Setup Server model and its publication context.

This function initializes the Generic Power OnOff Setup Server model, its publication context, and allocates memory for the server instance. It checks for invalid arguments and handles memory allocation failures.

Parameters
[out]p_modelPointer to the model structure to be created.
[out]p_pubPointer to the publication context to be created.
[out]p_power_onoff_setup_srvPointer to the Power OnOff setup server instance to be allocated.
Returns
  • MESHX_SUCCESS: Successfully created the model and publication context.
  • MESHX_INVALID_ARG: One or more arguments are invalid.
  • MESHX_NO_MEM: Memory allocation failed.

◆ meshx_plat_set_gen_srv_state()

meshx_err_t meshx_plat_set_gen_srv_state ( void * p_model,
const meshx_gen_server_state_t * state,
uint16_t state_len )

Set the state of a generic server model.

This function updates the on/off state of a specified generic server model.

Parameters
[in]p_modelPointer to the model whose state is to be set.
[in]stateThe desired on/off state to set for the model.
[in]state_lenThe length of the state data.
Returns
MESHX_SUCCESS on success, or an appropriate error code on failure.