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_light_server.c File Reference

Implementation of the BLE Mesh Lighting Server for the ESP32. More...

Include dependency graph for meshx_light_server.c:

Go to the source code of this file.

Macros

#define MESHX_SERVER_INIT_MAGIC_NO   0x2483
 

Functions

meshx_err_t meshx_is_status_in_gen_light_grp (uint16_t opcode)
 Checks if the given opcode belongs to the Generic Light group.
 
meshx_err_t meshx_gen_light_srv_send_msg_to_ble (control_task_msg_evt_to_ble_t evt, const meshx_lighting_server_cb_param_t *params)
 Sends a message to the BLE subsystem via the control task.
 
meshx_err_t meshx_lighting_srv_dereg_cb (uint32_t model_id, meshx_lighting_server_cb cb)
 Callback function to deregister a lighting server model.
 
meshx_err_t meshx_lighting_reg_cb (uint32_t model_id, meshx_lighting_server_cb cb)
 Register a callback function for the lighting server model.
 
meshx_err_t meshx_lighting_srv_init (void)
 Initialize the meshxuction lighting server.
 
meshx_err_t meshx_gen_light_srv_status_send (meshx_model_t *p_model, meshx_ctx_t *ctx, meshx_lighting_server_state_change_t *state_change)
 Sends a status message for the Lighting Server model.
 

Variables

static uint16_t meshx_lighting_server_init = 0
 

Detailed Description

Implementation of the BLE Mesh Lighting Server for the ESP32.

Copyright © 2024 - 2025 MeshX

This file contains the implementation of the BLE Mesh Lighting Server, including initialization, event handling, and callback registration.

Author
Pranjal Chanda

Definition in file meshx_light_server.c.

Macro Definition Documentation

◆ MESHX_SERVER_INIT_MAGIC_NO

#define MESHX_SERVER_INIT_MAGIC_NO   0x2483

Definition at line 17 of file meshx_light_server.c.

Function Documentation

◆ meshx_gen_light_srv_send_msg_to_ble()

meshx_err_t meshx_gen_light_srv_send_msg_to_ble ( control_task_msg_evt_to_ble_t evt,
const meshx_lighting_server_cb_param_t * params )

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

This function publishes a message to the BLE layer with the specified event and parameters.

Parameters
[in]evtThe event to be sent to the BLE layer.
[in]paramsPointer to the parameters associated with the event.
Returns
  • MESHX_SUCCESS: Message sent successfully.
  • MESHX_FAIL: Failed to send the message.

Definition at line 62 of file meshx_light_server.c.

65{
67 (uint16_t)(params->ctx.opcode)))
68 {
69 return MESHX_SUCCESS; // No action needed for non-light group opcodes
70 }
72 evt,
73 params,
75}
struct meshx_lighting_server_cb_param meshx_lighting_server_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_SUCCESS
Definition meshx_err.h:40
meshx_err_t meshx_is_status_in_gen_light_grp(uint16_t opcode)
Checks if the given opcode belongs to the Generic Light group.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ meshx_gen_light_srv_status_send()

meshx_err_t meshx_gen_light_srv_status_send ( meshx_model_t * p_model,
meshx_ctx_t * ctx,
meshx_lighting_server_state_change_t * state_change )

Sends a status message for the Lighting Server model.

This function sends a status message for the Lighting Server model with the specified parameters.

Parameters
[in]p_modelPointer to the Lighting Server model.
[in]ctxPointer to the context of the received messages.
[in]state_changePointer to the state change data for the Lighting Server.
Returns
MESHX_SUCCESS on success, or an appropriate error code on failure.

Definition at line 143 of file meshx_light_server.c.

148{
149 if (!p_model || !ctx || !state_change)
150 return MESHX_INVALID_ARG;
151
153 {
154 return MESHX_NOT_SUPPORTED;
155 }
156
158 p_model,
159 ctx,
160 state_change
161 );
162}
meshx_err_t meshx_plat_gen_light_srv_send_status(const meshx_model_t *p_model, const meshx_ctx_t *p_ctx, const meshx_lighting_server_state_change_t *state_change)
Send a status message from the Light Server. This function constructs and sends a status message cont...
@ MESHX_INVALID_ARG
Definition meshx_err.h:42
@ MESHX_NOT_SUPPORTED
Definition meshx_err.h:47
Here is the call graph for this function:
Here is the caller graph for this function:

◆ meshx_is_status_in_gen_light_grp()

meshx_err_t meshx_is_status_in_gen_light_grp ( uint16_t opcode)

Checks if the given opcode belongs to the Generic Light group.

This function determines whether the specified opcode is part of the Generic Light group opcodes as defined in the MeshX Light Server model.

Parameters
opcodeThe opcode to check.
Returns
meshx_err_t Returns an error code indicating whether the opcode is in the Generic Light group.
  • MESHX_OK if the opcode is in the group.
  • MESHX_ERR_NOT_FOUND if the opcode is not in the group.

Definition at line 33 of file meshx_light_server.c.

34{
35 switch (opcode)
36 {
44 return MESHX_SUCCESS;
45 default:
46 return MESHX_FAIL;
47 }
48}
#define MESHX_MODEL_OP_LIGHT_CTL_STATUS
#define MESHX_MODEL_OP_LIGHT_LIGHTNESS_STATUS
#define MESHX_MODEL_OP_LIGHT_CTL_TEMPERATURE_STATUS
#define MESHX_MODEL_OP_LIGHT_LIGHTNESS_LINEAR_STATUS
#define MESHX_MODEL_OP_LIGHT_HSL_STATUS
#define MESHX_MODEL_OP_LIGHT_HSL_HUE_STATUS
#define MESHX_MODEL_OP_LIGHT_HSL_SATURATION_STATUS
@ MESHX_FAIL
Definition meshx_err.h:41
Here is the caller graph for this function:

◆ meshx_lighting_reg_cb()

meshx_err_t meshx_lighting_reg_cb ( uint32_t model_id,
meshx_lighting_server_cb cb )

Register a callback function for the lighting server model.

This function registers a callback function that will be called when certain events occur in the lighting server model.

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

Definition at line 108 of file meshx_light_server.c.

109{
111}
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.
@ CONTROL_TASK_MSG_CODE_FRM_BLE
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:
Here is the caller graph for this function:

◆ meshx_lighting_srv_dereg_cb()

meshx_err_t meshx_lighting_srv_dereg_cb ( uint32_t model_id,
meshx_lighting_server_cb cb )

Callback function to deregister a lighting server model.

This function is called to deregister a lighting 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 90 of file meshx_light_server.c.

91{
93}
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.
Here is the call graph for this function:

◆ meshx_lighting_srv_init()

meshx_err_t meshx_lighting_srv_init ( void )

Initialize the meshxuction lighting server.

Initialize the production lighting server.

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

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

Definition at line 123 of file meshx_light_server.c.

124{
126 return MESHX_SUCCESS;
128
130}
meshx_err_t meshx_plat_light_srv_init(void)
Initialize the platform-specific Light Server.
#define MESHX_SERVER_INIT_MAGIC_NO
static uint16_t meshx_lighting_server_init
Here is the call graph for this function:
Here is the caller graph for this function:

Variable Documentation

◆ meshx_lighting_server_init

uint16_t meshx_lighting_server_init = 0
static

Definition at line 19 of file meshx_light_server.c.