feat: add samples files
This commit is contained in:
parent
c40e22c81c
commit
877c8fa206
86
others/HttpServerTests.h
Normal file
86
others/HttpServerTests.h
Normal file
@ -0,0 +1,86 @@
|
|||||||
|
void SendNotifAsyncInt(void *pvParameters)
|
||||||
|
{
|
||||||
|
for (;;)
|
||||||
|
{
|
||||||
|
if (!s.sendNotif && !s.isFired)
|
||||||
|
{
|
||||||
|
vTaskDelay(100 / portTICK_PERIOD_MS);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
if (s.sendNotif)
|
||||||
|
{
|
||||||
|
s.eventId = millis();
|
||||||
|
}
|
||||||
|
SendNotif();
|
||||||
|
s.sendNotif = false;
|
||||||
|
vTaskDelay(FromSeconds(3) / portTICK_PERIOD_MS);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
void SendNotif()
|
||||||
|
{
|
||||||
|
// client2 = new WiFiClientSecure;
|
||||||
|
client2 = new WiFiClient;
|
||||||
|
|
||||||
|
if (client2)
|
||||||
|
{
|
||||||
|
// set secure client with certificate
|
||||||
|
// client2->setCACert(francelsoft_root_ca);
|
||||||
|
// client2->setInsecure();
|
||||||
|
// create an HTTPClient instance
|
||||||
|
HTTPClient https;
|
||||||
|
|
||||||
|
// Initializing an HTTPS communication using the secure client
|
||||||
|
// if (https.begin(*client2, "https://push.francelsoft.com/test/publish?message=Unauthzorized+Access&priority=high&tags=warning,rotating_light")) { // HTTPS
|
||||||
|
|
||||||
|
String eventtype = s.sendNotif ? "Fired" : "EventUpdate";
|
||||||
|
String url = "http://10.88.88.169:9003/?eventId=" + String(s.eventId) + "&eventType=" + eventtype + "&eventData=t";
|
||||||
|
Serial.print("[HTTPS] " + url);
|
||||||
|
if (https.begin(*client2, url))
|
||||||
|
{ // HTTPS
|
||||||
|
// Serial.print("[HTTPS] GET...\n");
|
||||||
|
// start connection and send HTTP header
|
||||||
|
int httpCode = https.GET();
|
||||||
|
// httpCode will be negative on error
|
||||||
|
if (httpCode > 0)
|
||||||
|
{
|
||||||
|
// HTTP header has been send and Server response header has been handled
|
||||||
|
// Serial.printf("[HTTPS] GET Finished... code: %d\n", httpCode);
|
||||||
|
// file found at server
|
||||||
|
if (httpCode == HTTP_CODE_OK || httpCode == HTTP_CODE_MOVED_PERMANENTLY)
|
||||||
|
{
|
||||||
|
// print server response payload
|
||||||
|
String payload = https.getString();
|
||||||
|
if (payload == "AUTHORIZE_ENTRANCE")
|
||||||
|
{
|
||||||
|
// Todo Extract to Disarm method
|
||||||
|
Serial.println("Entrace authorized by servcer.");
|
||||||
|
s.isFired = false;
|
||||||
|
s.isArmed = s.doorStatus == DOOR_CLOSED;
|
||||||
|
}
|
||||||
|
|
||||||
|
Serial.println(payload);
|
||||||
|
|
||||||
|
// Dictionary &d = *(new Dictionary());
|
||||||
|
// d.jload(payload);
|
||||||
|
|
||||||
|
// Serial.println(d["authorizeEntrace"]);
|
||||||
|
// if(d["authorizeEntrance"]=="true"){
|
||||||
|
// //Todo Extract to Disarm method
|
||||||
|
// Serial.println("Entrace authorized by servcer.");
|
||||||
|
// s.isFired=false;
|
||||||
|
// s.isArmed=s.doorStatus==DOOR_CLOSED;
|
||||||
|
// }
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
Serial.printf("[HTTPS] GET... failed, error: %s\n", https.errorToString(httpCode).c_str());
|
||||||
|
}
|
||||||
|
https.end();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
Serial.printf("[HTTPS] Unable to connect\n");
|
||||||
|
}
|
||||||
|
}
|
83
others/MultiTaskTests.h
Normal file
83
others/MultiTaskTests.h
Normal file
@ -0,0 +1,83 @@
|
|||||||
|
TaskHandle_t Task1;
|
||||||
|
TaskHandle_t Task2;
|
||||||
|
const int led1 = 2;
|
||||||
|
const int led2 = 4;
|
||||||
|
|
||||||
|
void stp()
|
||||||
|
{
|
||||||
|
pinMode(led1, OUTPUT);
|
||||||
|
pinMode(led2, OUTPUT);
|
||||||
|
|
||||||
|
xTaskCreatePinnedToCore(
|
||||||
|
Task1code, /* Task function. */
|
||||||
|
"Task1", /* name of task. */
|
||||||
|
10000, /* Stack size of task */
|
||||||
|
NULL, /* parameter of the task */
|
||||||
|
1, /* priority of the task */
|
||||||
|
&Task1, /* Task handle to keep track of created task */
|
||||||
|
0); /* pin task to core 0 */
|
||||||
|
// xTaskCreate(Task1code, "task1", 1000, NULL, 1, NULL);
|
||||||
|
delay(500);
|
||||||
|
|
||||||
|
xTaskCreatePinnedToCore(
|
||||||
|
Task2code, /* Task function. */
|
||||||
|
"Task2", /* name of task. */
|
||||||
|
10000, /* Stack size of task */
|
||||||
|
NULL, /* parameter of the task */
|
||||||
|
1, /* priority of the task */
|
||||||
|
&Task2, /* Task handle to keep track of created task */
|
||||||
|
1); /* pin task to core 1 */
|
||||||
|
// xTaskCreate(Task2code, "task2", 1000, NULL, 1, NULL);
|
||||||
|
delay(500);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Task1code: blinks an LED every 1000 ms
|
||||||
|
void Task1code(void *pvParameters)
|
||||||
|
{
|
||||||
|
Serial.print("Task1 running on core ");
|
||||||
|
Serial.println(xPortGetCoreID());
|
||||||
|
|
||||||
|
for (;;)
|
||||||
|
{
|
||||||
|
digitalWrite(led1, HIGH);
|
||||||
|
delay(1000);
|
||||||
|
digitalWrite(led1, LOW);
|
||||||
|
delay(1000);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Task2code: blinks an LED every 700 ms
|
||||||
|
void Task2code(void *pvParameters)
|
||||||
|
{
|
||||||
|
Serial.print("Task2 running on core ");
|
||||||
|
Serial.println(xPortGetCoreID());
|
||||||
|
|
||||||
|
for (;;)
|
||||||
|
{
|
||||||
|
digitalWrite(led2, HIGH);
|
||||||
|
delay(700);
|
||||||
|
if (!s.isFired)
|
||||||
|
{
|
||||||
|
digitalWrite(led2, LOW);
|
||||||
|
delay(700);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void killOne()
|
||||||
|
{
|
||||||
|
// Kill task1 if it's running
|
||||||
|
if (Task1 != NULL)
|
||||||
|
{
|
||||||
|
eTaskState taskState = eTaskGetState(Task1);
|
||||||
|
if (taskState == eDeleted)
|
||||||
|
{
|
||||||
|
Serial.println("Task deleted");
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
Serial.println("No more green");
|
||||||
|
vTaskDelete(Task1);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
13
others/updateResponse.json
Normal file
13
others/updateResponse.json
Normal file
@ -0,0 +1,13 @@
|
|||||||
|
{
|
||||||
|
"disarm": false,
|
||||||
|
"cards": [
|
||||||
|
{
|
||||||
|
"id": "0015",
|
||||||
|
"name": "guille"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"id": "AA111f",
|
||||||
|
"name": "Andre"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user