74 lines
1.9 KiB
C++
74 lines
1.9 KiB
C++
#include "tasks.h"
|
|
|
|
boolean task_blink(void *pData)
|
|
{
|
|
SAB *p = (SAB *) pData;
|
|
p->getIoManager().getPcf().togglePin(PCF8574::P2);
|
|
|
|
return true;
|
|
}
|
|
|
|
boolean task_batt_sensing(void *pData)
|
|
{
|
|
View1Packet *p = (View1Packet *) pData;
|
|
Serial.printf_P(PSTR("BATT SENSING...\nRunning since : %d s\n"), millis()/1000);
|
|
p->powerInfo = p->sab->getPowerManager().getPowerInfo();
|
|
|
|
return true;
|
|
}
|
|
|
|
boolean task_esp_reset_restart(void * pData)
|
|
{
|
|
ESP.restart();
|
|
|
|
return true;
|
|
}
|
|
|
|
boolean task_post_data_logger(void * pData)
|
|
{
|
|
DataLogger *p = (DataLogger *) pData;
|
|
//This routine is here to test the new HttpClient class
|
|
//HttpClient httpClient("192.168.0.17", "/esp8266/dataLogger.php", 1234);
|
|
|
|
if(p->counter == 0)
|
|
{
|
|
Dictionary<DictionaryHelper::StringEntity> getData;
|
|
getData.add("key1", DictionaryHelper::StringEntity("value1"));
|
|
getData.add("key2", DictionaryHelper::StringEntity(NULL));
|
|
getData.add("key3", DictionaryHelper::StringEntity("value3"));
|
|
getData.add("key4", NULL);
|
|
|
|
Dictionary<DictionaryHelper::StringEntity> postData;
|
|
postData.add("post1", DictionaryHelper::StringEntity("postvalue1"));
|
|
postData.add("post2", DictionaryHelper::StringEntity(NULL));
|
|
postData.add("post3", DictionaryHelper::StringEntity("postvalue3"));
|
|
postData.add("post4", NULL);
|
|
|
|
|
|
if(p->client.sendHttpQuery(HttpClient::HttpRequestMethod::POST, &getData, &postData))
|
|
{
|
|
Serial.println("Send successful");
|
|
p->rdy = false;
|
|
}
|
|
}
|
|
else if(p->client.isReplyAvailable() != HttpClient::HTTP_CODE::UNDEFINED_CODE && !p->rdy)
|
|
{
|
|
Serial.printf("Code : %d, counter : %u\n", p->client.isReplyAvailable(), p->counter);
|
|
p->rdy = true;
|
|
}
|
|
|
|
if(p->rdy)
|
|
{
|
|
char buff[100];
|
|
p->client.readHttpBody((uint8_t *)buff, 100);
|
|
Serial.print(buff);
|
|
}
|
|
|
|
p->counter++;
|
|
|
|
if(p->counter == 30)
|
|
p->counter = 0;
|
|
|
|
return true;
|
|
}
|