ESP32物联网应用开发与安全特性解析
1. 应用程序编码
1.1 客户端实现文件
在项目中添加的第一个源代码文件是 main/AppRestClient.hpp ,用于客户端实现:
#pragma once
#include <string>
#include "freertos/FreeRTOS.h"
#include "freertos/task.h"
#include "json.hpp"
#include "AppEsp32C3Bsp.hpp"
#include "esp_http_client.h"
ESP-IDF 在 esp_http_client.h 中提供了 HTTP 客户端功能,我们将使用其中的函数和结构连接到 RESTful 服务器。接着定义与服务器上资源对应的 C 结构:
namespace app
{
struct sSensorConfig
{
std::string name;
bool enabled;
};
NLOHMANN_DEFINE_TYPE_NON_INTRUSIVE(sSensorConfig, name, enabled);
struct sSensorData
{
std::string name;
std::string button;
};
NLOHMANN_D
超级会员免费看
订阅专栏 解锁全文

被折叠的 条评论
为什么被折叠?



