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
meshXDevice Class Reference

Singleton wrapper for the raw C dev_struct_t. More...

#include <meshx_device.hpp>

Public Member Functions

void init (dev_struct_t *pdev)
 Initialize the device wrapper with a raw C struct.
dev_struct_tget_raw_struct ()
 Get the underlying C structure.
bool is_initialized () const
 Check if initialized.
void visualize_status ()
 Visualize the current composition and element status.

Static Public Member Functions

static meshXDeviceget_instance ()
 Get the singleton instance.

Private Member Functions

 meshXDevice ()
 ~meshXDevice ()=default

Private Attributes

dev_struct_tpdev

Detailed Description

Singleton wrapper for the raw C dev_struct_t.

This class provides a bridge between the C-centric device structure and the rich C++ element/model system.

Constructor & Destructor Documentation

◆ meshXDevice()

meshXDevice::meshXDevice ( )
inlineprivate
51: pdev(nullptr) {}
dev_struct_t * pdev
Definition meshx_device.hpp:54

◆ ~meshXDevice()

meshXDevice::~meshXDevice ( )
privatedefault

Member Function Documentation

◆ get_instance()

meshXDevice & meshXDevice::get_instance ( )
static

Get the singleton instance.

14 {
15 static meshXDevice instance;
16 return instance;
17}
meshXDevice()
Definition meshx_device.hpp:51

◆ get_raw_struct()

dev_struct_t * meshXDevice::get_raw_struct ( )
inline

Get the underlying C structure.

38{ return pdev; }

◆ init()

void meshXDevice::init ( dev_struct_t * pdev)
inline

Initialize the device wrapper with a raw C struct.

Parameters
pdevPointer to the dev_struct_t
31 {
32 this->pdev = pdev;
33 }

◆ is_initialized()

bool meshXDevice::is_initialized ( ) const
inline

Check if initialized.

43{ return pdev != nullptr; }

◆ visualize_status()

void meshXDevice::visualize_status ( )

Visualize the current composition and element status.

19 {
20 if (!pdev) {
21 MESHX_LOGW(MODULE_ID_COMMON, "Device not initialized, cannot visualize status");
22 return;
23 }
24 MESHX_LOGI(MODULE_ID_COMMON, "==================================================");
25 MESHX_LOGI(MODULE_ID_COMMON, " MESHX DEVICE STATUS VISUALIZATION");
26 MESHX_LOGI(MODULE_ID_COMMON, "==================================================");
27 MESHX_LOGI(MODULE_ID_COMMON, "Device UUID: %02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x",
28 pdev->uuid[0], pdev->uuid[1], pdev->uuid[2], pdev->uuid[3],
29 pdev->uuid[4], pdev->uuid[5], pdev->uuid[6], pdev->uuid[7],
30 pdev->uuid[8], pdev->uuid[9], pdev->uuid[10], pdev->uuid[11],
31 pdev->uuid[12], pdev->uuid[13], pdev->uuid[14], pdev->uuid[15]);
32 MESHX_LOGI(MODULE_ID_COMMON, "Total Elements: %zu", pdev->element_cnt);
33 MESHX_LOGI(MODULE_ID_COMMON, "--------------------------------------------------");
34
35 auto& registry = meshXElementRegistry::get_instance();
36
37 for (size_t i = 0; i < pdev->element_cnt; ++i) {
38 meshXElementIF* el = registry.find_element((uint16_t)i);
39
40 if (el) {
41 MESHX_LOGI(MODULE_ID_COMMON, "Element [%zu]: (%s)", i, el->get_element_name());
42
43 // List SIG Models
44 auto& sig_models = el->get_sig_models();
45 for (auto& m : sig_models) {
46 MESHX_LOGI(MODULE_ID_COMMON, " - SIG Model: 0x%04x (%s)",
47 m->get_model_id(), m->is_initialized() ? "Active" : "Idle");
48 }
49
50 // List Vendor Models
51 auto& ven_models = el->get_ven_models();
52 for (auto& m : ven_models) {
53 MESHX_LOGI(MODULE_ID_COMMON, " - VND Model: 0x%04x", m->get_model_id());
54 }
55 } else {
56 MESHX_LOGW(MODULE_ID_COMMON, "Element [%zu]: NO C++ OBJECT MAPPED", i);
57 }
58 }
59 MESHX_LOGI(MODULE_ID_COMMON, "==================================================");
60}
virtual std::vector< std::unique_ptr< meshXModelIF > > & get_ven_models(void)=0
Get the Vendor models vector.
virtual const char * get_element_name(void) const =0
Get the name of the element.
virtual std::vector< std::unique_ptr< meshXModelIF > > & get_sig_models(void)=0
Get the SIG models vector.
static meshXElementRegistry & get_instance()
Definition meshx_element_registry.hpp:33
#define MESHX_LOGW(module_id, format,...)
Definition meshx_log.h:120
#define MESHX_LOGI(module_id, format,...)
Definition meshx_log.h:126
@ MODULE_ID_COMMON
Definition module_id.h:36

Field Documentation

◆ pdev

dev_struct_t* meshXDevice::pdev
private

The documentation for this class was generated from the following files: