From 212f66288235ff24dab5034e9d84f577f359e53e Mon Sep 17 00:00:00 2001 From: Clement Date: Mon, 27 Mar 2023 15:58:56 +0200 Subject: [PATCH] feat: send value in https with auth user --- IOT/src/main.cpp | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/IOT/src/main.cpp b/IOT/src/main.cpp index 1d2d8d1..f8758c5 100644 --- a/IOT/src/main.cpp +++ b/IOT/src/main.cpp @@ -16,12 +16,15 @@ SoftwareSerial Serial1(6, 7); // RX, TX #endif char ssid[] = "Clement4G"; // TODO: mettre id wifi dans config.ini -char pass[] = "***"; // TODO: mettre pass wifi dans config.ini +char pass[] = "Clement123"; // TODO: mettre pass wifi dans config.ini int status = WL_IDLE_STATUS; // the Wifi radio's status //char server[] = "arduino.tips"; -char server[] = "iot2.epi.cb85.software"; +char server[] = "iot.epi.cb85.software"; + + +String tocken = "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJjb2xsZWN0aW9uSWQiOiJfcGJfdXNlcnNfYXV0aF8iLCJleHAiOjE2ODExMzM4NDMsImlkIjoiZnNlNm9uZ3AxNHN5bHVvIiwidHlwZSI6ImF1dGhSZWNvcmQifQ.QKvfyAQ-lxLHTLyZIQ0FrMYFn5XPTujY_N1Oz6BRHn4"; void printWifiStatus(); @@ -63,14 +66,16 @@ void setup() { Serial.println("Connected to server"); // Make a HTTP request // client.println("GET /api/collections/poubelle_status/records HTTP/1.1"); - // client.println("Host: iot2.epi.cb85.software"); + // client.println("Host: iot.epi.cb85.software"); // client.println("Connection: close"); // client.println(); - String data = "{\"value\": \"test123\"}"; - client.println("POST /api/collections/poubelle_status/records HTTP/1.1"); - client.println("Host: iot2.epi.cb85.software"); + String data = "{\"value\": \"123\",\"trash_id\": \"gdnuxl0wlgurtj3\",\"unit\": \"test\",\"status\": true}"; + + client.println("POST /api/collections/data/records HTTP/1.1"); + client.println("Host: iot.epi.cb85.software"); client.println("Content-Type: application/json"); client.println("Content-Length: " + String(data.length())); + client.println("Authorization: Bearer "+tocken); client.println(); client.println(data); client.println("Connection: close");