feat: add GPIO policy module and tool header

This commit is contained in:
Asklv
2026-03-07 16:15:28 +08:00
parent b6e11d837b
commit e278264133
3 changed files with 156 additions and 0 deletions

27
main/tools/tool_gpio.h Normal file
View File

@@ -0,0 +1,27 @@
#pragma once
#include "esp_err.h"
#include <stddef.h>
/**
* Initialize GPIO tool — configure allowed pins and directions.
*/
esp_err_t tool_gpio_init(void);
/**
* Write a GPIO pin HIGH or LOW.
* Input JSON: {"pin": <int>, "state": <0|1>}
*/
esp_err_t tool_gpio_write_execute(const char *input_json, char *output, size_t output_size);
/**
* Read a single GPIO pin state.
* Input JSON: {"pin": <int>}
*/
esp_err_t tool_gpio_read_execute(const char *input_json, char *output, size_t output_size);
/**
* Read all allowed GPIO pin states at once.
* Input JSON: {} (no parameters)
*/
esp_err_t tool_gpio_read_all_execute(const char *input_json, char *output, size_t output_size);