Files
BR_YKC/Core/LWIP/App/httpd_cgi.c

37 lines
798 B
C
Raw Normal View History

2026-03-31 15:46:04 +08:00
#include "httpd_cgi.h"
#include "lwip/apps/httpd.h"
#include "main.h"
// ????(?????? ADC?????)
volatile float g_temperature = 25.5f;
volatile uint8_t g_led_state = 0;
#define LED_PIN GPIO_PIN_14
#define LED_PORT GPIOB
static const char* api_status_handler(int iIndex, int iNumParams, char *pcParam[], char *pcValue[])
{
static char json[64];
snprintf(json, sizeof(json), "{\"temp\":%.1f,\"led\":%d}", g_temperature, g_led_state);
return json;
}
static const char* api_success_handler(int iIndex, int iNumParams, char *pcParam[], char *pcValue[])
{
return ""; // ?????
}
void setup_web_api(void)
{
const tCGI handlers[] = {
{ "/api/status", api_status_handler },
{ "/api/success", api_success_handler }
};
http_set_cgi_handlers(handlers, 2);
}