static void send_data_to_edge_impulse() {
// Set up HTTP client request
struct http_client_request req;
struct http_client_ctx ctx;
char data_buf[512];
snprintf(data_buf, sizeof(data_buf), "{\"label\":\"%s\",\"data\":\"%s\"}", "my_label", "my_data");
http_client_request_init(&req);
req.method = HTTP_POST;
req.url = "http://ingestion.edgeimpulse.com/api/training/data";
req.protocol = "HTTP/1.1";
req.host = "ingestion.edgeimpulse.com";
req.header_fields = "Content-Type: application/json\r\n"
"x-api-key: " EDGE_IMPULSE_API_KEY "\r\n";
req.payload = data_buf;
req.payload_len = strlen(data_buf);
http_client_init(&ctx, &req);
// Send HTTP request
int ret = http_client_send(&ctx);
if (ret < 0) {
printf("HTTP request failed: %d\n", ret);
} else {
printf("HTTP request sent successfully\n");
}
}