MeshX 0.3
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_gen_server.h File Reference

Header file for the generic server model in the BLE mesh node application. More...

Include dependency graph for meshx_gen_server.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Functions

meshx_err_t meshx_gen_srv_send_msg_to_ble (control_task_msg_evt_to_ble_t evt, const meshx_gen_srv_cb_param_t *params)
 Sends a message to the BLE subsystem via the control task.
 
meshx_err_t meshx_gen_srv_reg_cb (uint32_t model_id, meshx_server_cb cb)
 Registers a callback function for a specific generic server model.
 
meshx_err_t meshx_gen_srv_dereg_cb (uint32_t model_id, meshx_server_cb cb)
 Callback function to deregister a generic server model.
 
meshx_err_t meshx_gen_srv_init (void)
 Initialize the meshxuction generic server.
 
meshx_err_t meshx_gen_srv_status_send (meshx_model_t *p_model, meshx_ctx_t *p_ctx, meshx_gen_srv_state_change_t state_change, size_t data_len)
 Sends a status message for the Generic Server model.
 

Detailed Description

Header file for the generic server model in the BLE mesh node application.

Copyright © 2024 - 2025 MeshX

This file contains the function declarations and data structures for registering, deregistering, and initializing the generic server model callbacks in the BLE mesh node application.

Definition in file meshx_gen_server.h.

Function Documentation

◆ meshx_gen_srv_dereg_cb()

meshx_err_t meshx_gen_srv_dereg_cb ( uint32_t model_id,
meshx_server_cb cb )

Callback function to deregister a generic server model.

This function is called to deregister a generic server model identified by the given model ID.

Parameters
[in]model_idThe ID of the model to be deregistered.
[in]cbThe callback function to be deregistered.
Returns
  • MESHX_SUCCESS: Success
  • MESHX_INVALID_ARG: Invalid argument
  • MESHX_FAIL: Other failures

Definition at line 148 of file meshx_gen_server.c.

149{
152 model_id,
154}
meshx_err_t(* control_task_msg_handle_t)(dev_struct_t *pdev, control_task_msg_evt_t evt, void *params)
Function pointer type for control task message handler.
meshx_err_t control_task_msg_unsubscribe(control_task_msg_code_t msg_code, control_task_msg_evt_t evt_bmap, control_task_msg_handle_t callback)
Deregister a callback for a specific message code and event bitmap.
@ CONTROL_TASK_MSG_CODE_FRM_BLE
Here is the call graph for this function:

◆ meshx_gen_srv_init()

meshx_err_t meshx_gen_srv_init ( void )

Initialize the meshxuction generic server.

This function sets up the necessary configurations and initializes the meshxuction generic server for the BLE mesh node.

Returns
  • MESHX_SUCCESS: Success
  • MESHX_FAIL: Failed to initialize the server

Definition at line 166 of file meshx_gen_server.c.

167{
169 return MESHX_SUCCESS;
171
173}
meshx_err_t meshx_plat_gen_srv_init(void)
Initialize the generic server model platform.
@ MESHX_SUCCESS
Definition meshx_err.h:40
#define MESHX_SERVER_INIT_MAGIC_NO
static uint16_t meshx_server_init
Here is the call graph for this function:

◆ meshx_gen_srv_reg_cb()

meshx_err_t meshx_gen_srv_reg_cb ( uint32_t model_id,
meshx_server_cb cb )

Registers a callback function for a specific generic server model.

This function associates a callback with the given model ID, allowing the server to handle events or messages related to that model.

Parameters
[in]model_idThe unique identifier of the generic server model.
[in]cbThe callback function to be registered for the model.
Returns
meshx_err_t Returns an error code indicating the result of the registration. Possible values include success or specific error codes.

Definition at line 127 of file meshx_gen_server.c.

128{
131 model_id,
133}
meshx_err_t control_task_msg_subscribe(control_task_msg_code_t msg_code, control_task_msg_evt_t evt_bmap, control_task_msg_handle_t callback)
Subscribe to a control task message.
Here is the call graph for this function:

◆ meshx_gen_srv_send_msg_to_ble()

meshx_err_t meshx_gen_srv_send_msg_to_ble ( control_task_msg_evt_to_ble_t evt,
const meshx_gen_srv_cb_param_t * params )

Sends a message to the BLE subsystem via the control task.

This function wraps the call to control_task_msg_publish with the appropriate message code for BLE communication. It allows sending an event and associated parameters to the BLE handler.

Parameters
evtThe event type to send to BLE, of type control_task_msg_evt_to_ble_t.
paramsPointer to the parameters associated with the event.
Returns
meshx_err_t Returns the result of the message publish operation.

Definition at line 100 of file meshx_gen_server.c.

103{
105 (uint16_t)(params->ctx.opcode)))
106 {
107 return MESHX_INVALID_ARG;
108 }
109
111 evt,
112 params,
114}
struct meshx_gen_srv_cb_param meshx_gen_srv_cb_param_t
@ CONTROL_TASK_MSG_CODE_TO_BLE
meshx_err_t control_task_msg_publish(control_task_msg_code_t msg_code, control_task_msg_evt_t msg_evt, const void *msg_evt_params, size_t sizeof_msg_evt_params)
Publish a control task message.
@ MESHX_INVALID_ARG
Definition meshx_err.h:42
meshx_err_t meshx_is_status_in_gen_srv_grp(uint16_t opcode)
Checks if the given opcode corresponds to a status message in the Generic Server group.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ meshx_gen_srv_status_send()

meshx_err_t meshx_gen_srv_status_send ( meshx_model_t * p_model,
meshx_ctx_t * p_ctx,
meshx_gen_srv_state_change_t state_change,
size_t data_len )

Sends a status message for the Generic Server model.

This function sends a status message for the Generic Server model to the BLE Mesh network. It checks if the provided model and context are valid, and if the opcode is within the range of supported Generic Server opcodes.

Parameters
[in]p_modelPointer to the Generic Server model structure.
[in]p_ctxPointer to the context containing message information.
[in]state_changeThe state change data to be sent in the status message.
[in]data_lenThe length of the data to be sent in the status message.
Returns
  • MESHX_SUCCESS: Successfully sent the status message.
  • MESHX_INVALID_ARG: Invalid argument provided.
  • MESHX_ERR_PLAT: Platform-specific error occurred.

Definition at line 71 of file meshx_gen_server.c.

76{
77 if (!p_model || !p_ctx || p_ctx->dst_addr == MESHX_ADDR_UNASSIGNED)
78 return MESHX_INVALID_ARG;
80 return MESHX_INVALID_ARG;
81
83 p_model,
84 p_ctx,
85 &state_change,
86 data_len
87 );
88}
#define MESHX_ADDR_UNASSIGNED
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.
uint16_t dst_addr
Here is the call graph for this function: