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

Property-based tests for GPIO element integration validation. More...

Functions

static meshx_err_t test_property_io_bridge_dispatch (void)
 Property 6.1: IO Bridge Function Dispatch.
static meshx_err_t run_gpio_integration_property_tests (void)
 Run all Property 6 tests.
static meshx_err_t gpio_integration_property_test_handler (int cmd_id, int argc, char **argv)
 GPIO integration property test command handler.
meshx_err_t register_gpio_integration_property_tests (void)
 Register GPIO integration property tests.

Detailed Description

Property-based tests for GPIO element integration validation.

This file implements property-based tests for Property 6: Element-IO Integration Consistency.

Author
MeshX Team
Date
2024

Function Documentation

◆ gpio_integration_property_test_handler()

meshx_err_t gpio_integration_property_test_handler ( int cmd_id,
int argc,
char ** argv )
static

GPIO integration property test command handler.

118{
119 (void)argc;
120 (void)argv;
121
122 switch (cmd_id) {
124 case 1: return test_property_io_bridge_dispatch();
125 default: return MESHX_INVALID_ARG;
126 }
127}
static meshx_err_t run_gpio_integration_property_tests(void)
Run all Property 6 tests.
Definition gpio_integration_property_test.c:101
static meshx_err_t test_property_io_bridge_dispatch(void)
Property 6.1: IO Bridge Function Dispatch.
Definition gpio_integration_property_test.c:29
@ MESHX_INVALID_ARG
Definition meshx_err.h:46

◆ register_gpio_integration_property_tests()

meshx_err_t register_gpio_integration_property_tests ( void )

Register GPIO integration property tests.

Returns
meshx_err_t Registration result
133{
135}
static meshx_err_t gpio_integration_property_test_handler(int cmd_id, int argc, char **argv)
GPIO integration property test command handler.
Definition gpio_integration_property_test.c:117
@ MODULE_ID_GPIO_ELEMENT_TEST
Definition module_id.h:50
meshx_err_t register_unit_test(module_id_t module_id, module_callback_t callback)
Register a unit test for a specific module.
Definition unit_test.c:137

◆ run_gpio_integration_property_tests()

meshx_err_t run_gpio_integration_property_tests ( void )
static

Run all Property 6 tests.

102{
103 MESHX_LOGD(MODULE_ID_COMMON, "Starting GPIO Integration Property Tests (Property 6)");
104
105 meshx_err_t result;
106
108 if (result != MESHX_SUCCESS) return result;
109
110 MESHX_LOGI(MODULE_ID_COMMON, "All GPIO Integration Property Tests PASSED");
111 return MESHX_SUCCESS;
112}
meshx_err_t
MeshX Error Codes.
Definition meshx_err.h:43
#define MESHX_LOGI(module_id, format,...)
Definition meshx_log.h:126
#define MESHX_LOGD(module_id, format,...)
Definition meshx_log.h:132
**This function is called by the parent element when a state change request *is received It validates the request and returns a result to the element not the model layer **return * MESHX_SUCCESS
Definition meshx_model_level.cpp:385
@ MODULE_ID_COMMON
Definition module_id.h:36

◆ test_property_io_bridge_dispatch()

meshx_err_t test_property_io_bridge_dispatch ( void )
static

Property 6.1: IO Bridge Function Dispatch.

Validates that the IO bridge correctly dispatches commands to the underlying GPIO subsystem and maintains consistency.

30{
31 MESHX_LOGD(MODULE_ID_COMMON, "Testing Property 6.1: IO Bridge Function Dispatch");
32
33 // Initialize subsystems
35 if (err != MESHX_SUCCESS) return MESHX_FAIL;
36
37 // Use logical pin 0 which is RELAY_1 in prod_profile.yml
38 uint8_t logical_pin = 0;
39
40 // Create IO instance for logical pin 0
41 meshx_io_config_t config = {
42 .logical_pin = logical_pin,
43 .io_type = 0, // GPIO
44 .name = "INTEGRATION_TEST_PIN",
45 .config.gpio = {
49 .initial_level = 0,
50 .signal_inversion = false,
51 }
52 };
53
54 meshx_io_handle_t handle = meshx_io_create(&config);
55 if (handle == NULL) {
56 MESHX_LOGE(MODULE_ID_COMMON, "FAIL: IO instance creation failed");
57 return MESHX_FAIL;
58 }
59
60 // Set level via IO interface
61 err = meshx_io_set_level(handle, 1);
62 if (err != MESHX_SUCCESS) {
63 MESHX_LOGE(MODULE_ID_COMMON, "FAIL: IO set_level failed: %d", err);
64 meshx_io_destroy(handle);
65 return MESHX_FAIL;
66 }
67
68 // Verify level via GPIO subsystem direct API
69 uint8_t direct_level = 0;
70 err = meshx_gpio_get_level(logical_pin, &direct_level);
71 if (err != MESHX_SUCCESS || direct_level != 1) {
72 MESHX_LOGE(MODULE_ID_COMMON, "FAIL: GPIO direct level mismatch: %d, val=%u", err, direct_level);
73 meshx_io_destroy(handle);
74 return MESHX_FAIL;
75 }
76
77 // Toggle via IO interface
78 err = meshx_io_toggle(handle);
79 if (err != MESHX_SUCCESS) {
80 MESHX_LOGE(MODULE_ID_COMMON, "FAIL: IO toggle failed: %d", err);
81 meshx_io_destroy(handle);
82 return MESHX_FAIL;
83 }
84
85 // Verify level again
86 err = meshx_gpio_get_level(logical_pin, &direct_level);
87 if (err != MESHX_SUCCESS || direct_level != 0) {
88 MESHX_LOGE(MODULE_ID_COMMON, "FAIL: GPIO direct level mismatch after toggle: %d, val=%u", err, direct_level);
89 meshx_io_destroy(handle);
90 return MESHX_FAIL;
91 }
92
93 meshx_io_destroy(handle);
94 MESHX_LOGI(MODULE_ID_COMMON, "PASS: Property 6.1 - IO Bridge Function Dispatch");
95 return MESHX_SUCCESS;
96}
@ MESHX_FAIL
Definition meshx_err.h:45
@ MESHX_GPIO_PULL_NONE
Definition meshx_gpio.h:42
meshx_err_t meshx_gpio_get_level(uint8_t logical_pin, uint8_t *level)
Get GPIO pin level.
Definition meshx_gpio.c:392
meshx_err_t meshx_gpio_init(void)
Initialize GPIO subsystem.
Definition meshx_gpio.c:95
@ MESHX_GPIO_MODE_OUTPUT
Definition meshx_gpio.h:30
@ MESHX_GPIO_DRIVE_MEDIUM
Definition meshx_gpio.h:54
meshx_io_handle_t meshx_io_create(const meshx_io_config_t *config)
Create IO instance from configuration.
Definition meshx_io_bridge.cpp:23
meshx_err_t meshx_io_set_level(meshx_io_handle_t handle, uint8_t level)
Set pin level (convenience function).
Definition meshx_io_bridge.cpp:102
void meshx_io_destroy(meshx_io_handle_t handle)
Destroy IO instance.
Definition meshx_io_bridge.cpp:56
meshx_err_t meshx_io_toggle(meshx_io_handle_t handle)
Toggle pin level (convenience function).
Definition meshx_io_bridge.cpp:118
void * meshx_io_handle_t
Opaque handle to IO instance.
Definition meshx_io_bridge.h:26
#define MESHX_LOGE(module_id, format,...)
Definition meshx_log.h:114
IO configuration structure (C compatible).
Definition meshx_io_bridge.h:47