This commit is contained in:
2020-07-16 23:08:21 -05:00
parent 7604f25fca
commit de90a43021
10 changed files with 427 additions and 75 deletions

View File

@@ -1,30 +1,72 @@
#include <Arduino.h>
#include "BluetoothSerial.h"
#include "carroEsp32.h"
#include "OpenTB6612FNG/OpenTB6612FNG.h"
#include "wifi_config.hpp"
#include "SPIFFS.h"
#include <ArduinoOTA.h>
#include "config_ota.hpp"
TaskHandle_t TareaProcesador1;
TaskHandle_t TareaProcesador2;
void loop1(void *pvParameters);
void loop2(void *pvParameters);
int anterior = millis();
char sensorCadena[16];
OpenTB6612FNG misMotores(0);
BluetoothSerial ESP_BT; //Object for Bluetooth
#include "managerServer.hpp"
void setup() {
init_sensores();
void setup()
{
Serial.begin(115200);
wifi();
ota_init();
SPIFFS.begin();
init_sensores();
webSocket.begin();
webSocket.onEvent(webSocketEvent);
server.begin();
xTaskCreatePinnedToCore(loop1, "Tarea1", 10000, NULL, 1, &TareaProcesador1, 0);
xTaskCreatePinnedToCore(loop2, "Tarea2", 10000, NULL, 1, &TareaProcesador2, 1);
delay(200);
Serial.println("Carro Esp32");
ESP_BT.begin("CARRO ESP32"); //Name of your Bluetooth Signal
// handle index
server.on("/", []() {
File index = SPIFFS.open("/index.html", "r");
server.streamFile(index, "text/html");
index.close();
});
}
void loop() {
misMotores.Forward();
misMotores.Motores(255,255);
if (ESP_BT.available()) //Check if we receive anything from Bluetooth
void loop()
{
}
void loop1(void *pvParameters)
{
for (;;)
{
//incoming = ESP_BT.read(); //Read what we recevive
Serial.print("Received:"); Serial.println(ESP_BT.read());
webSocket.loop();
ArduinoOTA.handle();
server.handleClient();
delay(10);
}
//readSensors();
//printSensores();
//delay(500);
}
void loop2(void *pvParameters)
{
for (;;)
{
if (((millis() - anterior) > 100) && (nCliente > -1))
{
anterior = millis();
sprintf(sensorCadena, "%d",readSensors(0));
webSocket.sendTXT(nCliente, sensorCadena);
}
}
}