You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
59 lines
1.1 KiB
59 lines
1.1 KiB
/*
|
|
* application.s
|
|
*
|
|
* Created on: 25.11.2022
|
|
* Author: jonas
|
|
*/
|
|
|
|
#include "application.h"
|
|
#include "freertos/FreeRTOS.h"
|
|
#include "freertos/task.h"
|
|
#include "myMqtt.h"
|
|
#include "wifi.h"
|
|
|
|
static TaskHandle_t appTaskHandle;
|
|
|
|
static void appTask(void *pv){
|
|
if(pv != NULL){
|
|
printf("task argument: %s\n", (char*)pv);
|
|
}
|
|
|
|
printf("Application was started");
|
|
fflush(stdout);
|
|
|
|
while(WiFi_isConnected() == false){
|
|
vTaskDelay(pdMS_TO_TICKS(1000));
|
|
}
|
|
|
|
// wifi now connected
|
|
printf("Application task detected that WiFi is connected\n");
|
|
if(MyMqtt_Init()){
|
|
vTaskDelay(pdMS_TO_TICKS(1000));
|
|
printf("5s done\n");
|
|
|
|
MyMqtt_Subscribe("scada/status");
|
|
|
|
printf("Application endless task was started\n");
|
|
fflush(stdout);
|
|
|
|
// endless loop
|
|
for(;;){
|
|
MyMqtt_Publish("scada/status", "Testmessage from ESP");
|
|
|
|
vTaskDelay(pdMS_TO_TICKS(10000));
|
|
}
|
|
} else {
|
|
printf("Init of MyMqtt failed! Quitting application task.\n");
|
|
}
|
|
|
|
}
|
|
|
|
BaseType_t res;
|
|
|
|
void Application_Start(void){
|
|
res = xTaskCreate(appTask, "task1", 4096/sizeof(StackType_t), (void*)"ARG_0", tskIDLE_PRIORITY, &appTaskHandle);
|
|
if(res != pdPASS){
|
|
printf("creating myTask failed!\r\n");
|
|
}
|
|
}
|
|
|
|
|