v2.1
This commit is contained in:
@ -4,5 +4,5 @@
|
|||||||
nvs, data, nvs, 0x9000, 0x4000,
|
nvs, data, nvs, 0x9000, 0x4000,
|
||||||
otadata, data, ota, 0xd000, 0x2000,
|
otadata, data, ota, 0xd000, 0x2000,
|
||||||
phy_init, data, phy, 0xf000, 0x1000,
|
phy_init, data, phy, 0xf000, 0x1000,
|
||||||
ota_0, app, ota_0, 0x10000, 0xF00000,
|
ota_0, app, ota_0, 0x10000, 0x180000,
|
||||||
ota_1, app, ota_1, 0xF10000, 0xF00000,
|
ota_1, app, ota_1, 0x190000, 0x180000,
|
||||||
|
@ -26,7 +26,7 @@ lib_deps =
|
|||||||
; knolleary/PubSubClient@^2.8
|
; knolleary/PubSubClient@^2.8
|
||||||
; plerup/EspSoftwareSerial@^6.15.2
|
; plerup/EspSoftwareSerial@^6.15.2
|
||||||
; arduino-libraries/ArduinoHttpClient@^0.4.0
|
; arduino-libraries/ArduinoHttpClient@^0.4.0
|
||||||
; janelia-arduino/Vector@^1.2.2
|
; janelia-arduino/Vector@^1.2.2
|
||||||
|
|
||||||
; milesburton/DallasTemperature@^3.11.0
|
; milesburton/DallasTemperature@^3.11.0
|
||||||
; adafruit/Adafruit MLX90614 Library@^2.1.3
|
; adafruit/Adafruit MLX90614 Library@^2.1.3
|
||||||
@ -50,4 +50,5 @@ board_build.filesystem = spiffs
|
|||||||
|
|
||||||
|
|
||||||
monitor_filters = esp32_exception_decoder
|
monitor_filters = esp32_exception_decoder
|
||||||
monitor_speed = 115200
|
monitor_speed = 115200
|
||||||
|
|
||||||
|
|||||||
@ -9,9 +9,12 @@ const uint32_t mqtt_port = 40000;
|
|||||||
const char *mqtt_client_id = "gaoguangpu_001";
|
const char *mqtt_client_id = "gaoguangpu_001";
|
||||||
const char *mqtt_username = "remotecontroler";
|
const char *mqtt_username = "remotecontroler";
|
||||||
const char *mqtt_password = "irishk";
|
const char *mqtt_password = "irishk";
|
||||||
const char *publish_topic = "gaoguangpu/return/IS11_id";
|
// const char *publish_topic = "gaoguangpu/return/IS11_id";
|
||||||
const char *subscribe_topic = "gaoguangpu/command/IS11_id";
|
// const char *subscribe_topic = "gaoguangpu/command/IS11_id";
|
||||||
|
// SpectraSenorV2/command
|
||||||
|
// SpectraSenorV2/return
|
||||||
|
String str_publish_topic ="SpectraSenorV2/command/";
|
||||||
|
String str_subscribe_topic = "SpectraSenorV2/return/";
|
||||||
EventGroupHandle_t http_event_group;
|
EventGroupHandle_t http_event_group;
|
||||||
|
|
||||||
void callback(char* topic, byte* payload, unsigned int length) {
|
void callback(char* topic, byte* payload, unsigned int length) {
|
||||||
@ -34,6 +37,8 @@ void callback(char* topic, byte* payload, unsigned int length) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void reconnect() {
|
void reconnect() {
|
||||||
|
const char *subscribe_topic = str_subscribe_topic.c_str();
|
||||||
|
|
||||||
// 重新连接MQTT
|
// 重新连接MQTT
|
||||||
while (!mqtt_client->connected())
|
while (!mqtt_client->connected())
|
||||||
{
|
{
|
||||||
@ -88,8 +93,12 @@ void gsmm_mqtt_loop_task(void *pvParameters)
|
|||||||
HttpClient *http;
|
HttpClient *http;
|
||||||
|
|
||||||
UpDateClassByme ggp_UpDate(http);
|
UpDateClassByme ggp_UpDate(http);
|
||||||
void gsmm_mqtt_init()
|
// String str_publish_topic ="SpectraSenorV2/command/";
|
||||||
|
// String str_subscribe_topic = "SpectraSenorV2/return/";
|
||||||
|
void gsmm_mqtt_init(String sensor_id)
|
||||||
{
|
{
|
||||||
|
str_publish_topic = str_publish_topic + sensor_id;
|
||||||
|
str_subscribe_topic = str_subscribe_topic + sensor_id;
|
||||||
http_event_group = xEventGroupCreate();
|
http_event_group = xEventGroupCreate();
|
||||||
// if(http_event_group == NULL)
|
// if(http_event_group == NULL)
|
||||||
// {
|
// {
|
||||||
@ -103,14 +112,14 @@ void gsmm_mqtt_init()
|
|||||||
// http = new HttpClient(*gsmmanger->client, "82.156.1.111");
|
// http = new HttpClient(*gsmmanger->client, "82.156.1.111");
|
||||||
http = new HttpClient(*gsmmanger->client, mqtt_server);
|
http = new HttpClient(*gsmmanger->client, mqtt_server);
|
||||||
xTaskCreatePinnedToCore(gsmm_mqtt_loop_task, "gsmm_mqtt_loop_task",1024*3,NULL, 1, NULL, 1);
|
xTaskCreatePinnedToCore(gsmm_mqtt_loop_task, "gsmm_mqtt_loop_task",1024*3,NULL, 1, NULL, 1);
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void mqtt_write(uint8_t *data , uint32_t lenth)
|
void mqtt_write(uint8_t *data , uint32_t lenth)
|
||||||
{
|
{
|
||||||
|
const char *publish_topic = str_publish_topic.c_str();
|
||||||
bool messageSent = false;
|
bool messageSent = false;
|
||||||
|
// String str_publish_topic =publish_topic + '/' + ;
|
||||||
do
|
do
|
||||||
{
|
{
|
||||||
messageSent = mqtt_client->publish(publish_topic,data,lenth);
|
messageSent = mqtt_client->publish(publish_topic,data,lenth);
|
||||||
@ -348,7 +357,7 @@ size_t http_download(String url)
|
|||||||
{
|
{
|
||||||
String headerName = http->readHeaderName();
|
String headerName = http->readHeaderName();
|
||||||
String headerValue = http->readHeaderValue();
|
String headerValue = http->readHeaderValue();
|
||||||
Serial0.println("Date: " + headerName + " : " + headerValue);
|
Serial0.println("Date: " + headerName + " : " + headerValue);
|
||||||
if (headerName=="Content-Length")
|
if (headerName=="Content-Length")
|
||||||
{
|
{
|
||||||
count=headerValue.toInt();
|
count=headerValue.toInt();
|
||||||
|
|||||||
@ -26,7 +26,8 @@ typedef struct gps_struct{
|
|||||||
float longitude;
|
float longitude;
|
||||||
}gps_struct;
|
}gps_struct;
|
||||||
|
|
||||||
void gsmm_mqtt_init();
|
// void gsmm_mqtt_init();
|
||||||
|
void gsmm_mqtt_init(String sensor_id);
|
||||||
void mqtt_write(uint8_t *data , uint32_t lenth);
|
void mqtt_write(uint8_t *data , uint32_t lenth);
|
||||||
bool UpdateData(String path,uint8_t *data, size_t lenth, String Contenttype);
|
bool UpdateData(String path,uint8_t *data, size_t lenth, String Contenttype);
|
||||||
void httpUpload(uint8_t *data,uint32_t lenth);
|
void httpUpload(uint8_t *data,uint32_t lenth);
|
||||||
|
|||||||
@ -47,7 +47,7 @@ void log_init()
|
|||||||
|
|
||||||
void write_log(String path,String write_data,unsigned char level)
|
void write_log(String path,String write_data,unsigned char level)
|
||||||
{
|
{
|
||||||
if(level <150) {
|
if(level <5) {
|
||||||
// U0_Serial.println(write_data);
|
// U0_Serial.println(write_data);
|
||||||
Serial0.println(write_data);
|
Serial0.println(write_data);
|
||||||
}
|
}
|
||||||
|
|||||||
34
src/main.cpp
34
src/main.cpp
@ -172,8 +172,8 @@ void setup()
|
|||||||
|
|
||||||
// while (1)
|
// while (1)
|
||||||
// {
|
// {
|
||||||
// Serial0.println("66666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666");
|
// Serial0.println("66666666666666666666666");
|
||||||
// vTaskDelay(10);
|
// vTaskDelay(1000);
|
||||||
// }
|
// }
|
||||||
|
|
||||||
log_init();
|
log_init();
|
||||||
@ -250,8 +250,6 @@ void setup()
|
|||||||
Serial0.println("IS_SN :" +STRSensorInfos_structure.serialnumber);
|
Serial0.println("IS_SN :" +STRSensorInfos_structure.serialnumber);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
sys_info_init();
|
sys_info_init();
|
||||||
|
|
||||||
dingbiao_init("/dingbiao/dingbiao_up_gain.bin");
|
dingbiao_init("/dingbiao/dingbiao_up_gain.bin");
|
||||||
@ -281,7 +279,7 @@ void setup()
|
|||||||
|
|
||||||
if(sys_sd_doc["status_4g"] == "open_4g")
|
if(sys_sd_doc["status_4g"] == "open_4g")
|
||||||
{
|
{
|
||||||
gsmm_mqtt_init();
|
gsmm_mqtt_init(STRSensorInfos_structure.serialnumber);
|
||||||
|
|
||||||
xTaskCreatePinnedToCore(task_4G_mode, "task_4G_mode",1024*(20),NULL, 1,NULL, 1);
|
xTaskCreatePinnedToCore(task_4G_mode, "task_4G_mode",1024*(20),NULL, 1,NULL, 1);
|
||||||
xTaskCreatePinnedToCore(OTA_task, "OTA_task",1024*(10),NULL, 1,NULL, 1);
|
xTaskCreatePinnedToCore(OTA_task, "OTA_task",1024*(10),NULL, 1,NULL, 1);
|
||||||
@ -368,13 +366,11 @@ void Task0(void *pvParameters)
|
|||||||
if (atuo_return == 1)
|
if (atuo_return == 1)
|
||||||
{
|
{
|
||||||
is11Sensor->senddata(&wb485Serial,return_data_type, fengbao_num);
|
is11Sensor->senddata(&wb485Serial,return_data_type, fengbao_num);
|
||||||
|
|
||||||
}
|
}
|
||||||
vTaskDelay(1000 * time_interval);
|
vTaskDelay(1000 * time_interval);
|
||||||
break;
|
break;
|
||||||
case 3:
|
case 3:
|
||||||
is11Sensor->senddata(&wb485Serial,return_data_type, fengbao_num);
|
is11Sensor->senddata(&wb485Serial,return_data_type, fengbao_num);
|
||||||
|
|
||||||
uint_work_task0 = 100;
|
uint_work_task0 = 100;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
@ -421,8 +417,8 @@ void Task1(void *pvParameters)
|
|||||||
{
|
{
|
||||||
vTaskDelay(3);
|
vTaskDelay(3);
|
||||||
write_log(log_path,"task 1",10);
|
write_log(log_path,"task 1",10);
|
||||||
uint8_t last_day = 100;
|
uint8_t last_day = 100;
|
||||||
uint32_t count=10;
|
uint32_t count = 10;
|
||||||
while(1)
|
while(1)
|
||||||
{
|
{
|
||||||
// vTaskDelay(1000);
|
// vTaskDelay(1000);
|
||||||
@ -554,9 +550,9 @@ void Task1(void *pvParameters)
|
|||||||
write_log(log_path,"sdcard will full," + String(used_percent * 100) + "%" +"used.",20);
|
write_log(log_path,"sdcard will full," + String(used_percent * 100) + "%" +"used.",20);
|
||||||
}
|
}
|
||||||
|
|
||||||
if(SD_MMC.exists("/guangpu_data/"+ String(now.year - 10) ))
|
if(SD_MMC.exists("/guangpu_data/" + String(now.year - 10) ))
|
||||||
{
|
{
|
||||||
String path = "/guangpu_data/"+ String(now.year - 10);
|
String path = "/guangpu_data/" + String(now.year - 10);
|
||||||
rm_dir_or_file(path.c_str());
|
rm_dir_or_file(path.c_str());
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -836,7 +832,6 @@ void task_4G_mode(void *pvParameters)
|
|||||||
doc_4G["SN"] = STRSensorInfos_structure.serialnumber;
|
doc_4G["SN"] = STRSensorInfos_structure.serialnumber;
|
||||||
if(check_tuigan() == false )
|
if(check_tuigan() == false )
|
||||||
{
|
{
|
||||||
|
|
||||||
warn_sta = true;
|
warn_sta = true;
|
||||||
doc_4G["tuigan"] = "warn";
|
doc_4G["tuigan"] = "warn";
|
||||||
if(get_tuigan_status() == tui)
|
if(get_tuigan_status() == tui)
|
||||||
@ -1306,7 +1301,7 @@ void json_command(uint8_t port_type)
|
|||||||
//command 2
|
//command 2
|
||||||
else if (doc["command"] == "set_sensor_info")
|
else if (doc["command"] == "set_sensor_info")
|
||||||
{
|
{
|
||||||
write_log(log_path,"set_sensor_info",log_level);
|
write_log(log_path,"set_sensor_info",log_level);
|
||||||
if(doc["name"] == NULL)
|
if(doc["name"] == NULL)
|
||||||
{
|
{
|
||||||
send_str = "";
|
send_str = "";
|
||||||
@ -1598,7 +1593,7 @@ void json_command(uint8_t port_type)
|
|||||||
doc["work_mode"] = sys_sd_doc["work_mode"].as<String>();
|
doc["work_mode"] = sys_sd_doc["work_mode"].as<String>();
|
||||||
doc["caiji_mode"] = sys_sd_doc["caiji_mode"].as<String>();
|
doc["caiji_mode"] = sys_sd_doc["caiji_mode"].as<String>();
|
||||||
doc["atuo_return"] = sys_sd_doc["atuo_return"].as<String>();
|
doc["atuo_return"] = sys_sd_doc["atuo_return"].as<String>();
|
||||||
doc["return_data_type"] =sys_sd_doc["return_data_type"];
|
doc["return_data_type"] = sys_sd_doc["return_data_type"];
|
||||||
serializeJson(doc, send_str);
|
serializeJson(doc, send_str);
|
||||||
ret = IRIS_Protocol_Pack(0x00,(uint16_t)send_str.length(), (uint8_t *)send_str.c_str(),send_buff);
|
ret = IRIS_Protocol_Pack(0x00,(uint16_t)send_str.length(), (uint8_t *)send_str.c_str(),send_buff);
|
||||||
// wb485Serial.write(send_buff, ret);
|
// wb485Serial.write(send_buff, ret);
|
||||||
@ -1727,7 +1722,7 @@ void json_command(uint8_t port_type)
|
|||||||
|
|
||||||
if(b1!=0 && b2 !=0 && b3 != 0 && b4 != 0)
|
if(b1!=0 && b2 !=0 && b3 != 0 && b4 != 0)
|
||||||
{
|
{
|
||||||
save = true;
|
save = true;
|
||||||
bc_b1 = doc["bochangxishu"]["b0"];
|
bc_b1 = doc["bochangxishu"]["b0"];
|
||||||
bc_b2 = doc["bochangxishu"]["b1"];
|
bc_b2 = doc["bochangxishu"]["b1"];
|
||||||
bc_b3 = doc["bochangxishu"]["b2"];
|
bc_b3 = doc["bochangxishu"]["b2"];
|
||||||
@ -2265,7 +2260,7 @@ void json_command(uint8_t port_type)
|
|||||||
}
|
}
|
||||||
//command 28
|
//command 28
|
||||||
//获取电源电压
|
//获取电源电压
|
||||||
else if(doc["command"] == "get_voltage")
|
else if(doc["command"] == "get_voltage" )
|
||||||
{
|
{
|
||||||
float voltage = adc_read();
|
float voltage = adc_read();
|
||||||
doc["voltage"] = voltage;
|
doc["voltage"] = voltage;
|
||||||
@ -2319,6 +2314,7 @@ void json_command(uint8_t port_type)
|
|||||||
if(port_type == 1) wb485Serial.write(send_buff,ret);
|
if(port_type == 1) wb485Serial.write(send_buff,ret);
|
||||||
else if(port_type == 2) mqtt_write(send_buff,ret);
|
else if(port_type == 2) mqtt_write(send_buff,ret);
|
||||||
}
|
}
|
||||||
|
|
||||||
//command 31
|
//command 31
|
||||||
//计算波长
|
//计算波长
|
||||||
else if(doc["command"] =="calculation")
|
else if(doc["command"] =="calculation")
|
||||||
@ -2368,11 +2364,12 @@ void json_command(uint8_t port_type)
|
|||||||
if(port_type == 1) wb485Serial.write(send_buff,ret);
|
if(port_type == 1) wb485Serial.write(send_buff,ret);
|
||||||
else if(port_type == 2) mqtt_write(send_buff,ret);
|
else if(port_type == 2) mqtt_write(send_buff,ret);
|
||||||
}
|
}
|
||||||
|
//command 34
|
||||||
else if(doc["command"] == "get_fanshelv_gain")
|
else if(doc["command"] == "get_fanshelv_gain")
|
||||||
{
|
{
|
||||||
send_dingbiao("/dingbiao/fanshelv_gain.bin");
|
send_dingbiao("/dingbiao/fanshelv_gain.bin");
|
||||||
|
|
||||||
}
|
}
|
||||||
|
//command 35
|
||||||
else if(doc["command"] == "set_4g")
|
else if(doc["command"] == "set_4g")
|
||||||
{
|
{
|
||||||
save = true;
|
save = true;
|
||||||
@ -2384,6 +2381,7 @@ void json_command(uint8_t port_type)
|
|||||||
if(port_type == 1) wb485Serial.write(send_buff,ret);
|
if(port_type == 1) wb485Serial.write(send_buff,ret);
|
||||||
else if(port_type == 2) mqtt_write(send_buff,ret);
|
else if(port_type == 2) mqtt_write(send_buff,ret);
|
||||||
}
|
}
|
||||||
|
//command 36
|
||||||
else if(doc["command"] == "OTA")
|
else if(doc["command"] == "OTA")
|
||||||
{
|
{
|
||||||
sys_sd_doc["version_url"] = doc["version_url"];
|
sys_sd_doc["version_url"] = doc["version_url"];
|
||||||
@ -2396,6 +2394,7 @@ void json_command(uint8_t port_type)
|
|||||||
else if(port_type == 2) mqtt_write(send_buff,ret);
|
else if(port_type == 2) mqtt_write(send_buff,ret);
|
||||||
xEventGroupSetBits(Main_EventGroup, OTA_BIT);
|
xEventGroupSetBits(Main_EventGroup, OTA_BIT);
|
||||||
}
|
}
|
||||||
|
//command 37
|
||||||
else if(doc["command"] == "USB")
|
else if(doc["command"] == "USB")
|
||||||
{
|
{
|
||||||
send_str = "";
|
send_str = "";
|
||||||
@ -2407,6 +2406,7 @@ void json_command(uint8_t port_type)
|
|||||||
// myusb_init();
|
// myusb_init();
|
||||||
setupmsc();
|
setupmsc();
|
||||||
}
|
}
|
||||||
|
//command 38
|
||||||
else if(doc["command"] == "reboot")
|
else if(doc["command"] == "reboot")
|
||||||
{
|
{
|
||||||
// setupmsc();
|
// setupmsc();
|
||||||
|
|||||||
@ -78,13 +78,13 @@ static bool onStartStop(uint8_t power_condition, bool start, bool load_eject) {
|
|||||||
// case ARDUINO_USB_STOPPED_EVENT: Serial.println("USB UNPLUGGED"); break;
|
// case ARDUINO_USB_STOPPED_EVENT: Serial.println("USB UNPLUGGED"); break;
|
||||||
// case ARDUINO_USB_SUSPEND_EVENT: Serial.printf("USB SUSPENDED: remote_wakeup_en: %u\n", data->suspend.remote_wakeup_en); break;
|
// case ARDUINO_USB_SUSPEND_EVENT: Serial.printf("USB SUSPENDED: remote_wakeup_en: %u\n", data->suspend.remote_wakeup_en); break;
|
||||||
// case ARDUINO_USB_RESUME_EVENT: Serial.println("USB RESUMED"); break;
|
// case ARDUINO_USB_RESUME_EVENT: Serial.println("USB RESUMED"); break;
|
||||||
|
|
||||||
// default: break;
|
// default: break;
|
||||||
// }
|
// }
|
||||||
// }
|
// }
|
||||||
// }
|
// }
|
||||||
|
|
||||||
void setupmsc() {
|
void setupmsc()
|
||||||
|
{
|
||||||
msc.vendorID("ESP32123");
|
msc.vendorID("ESP32123");
|
||||||
msc.productID("USB_MSC123");
|
msc.productID("USB_MSC123");
|
||||||
msc.productRevision("1.0");
|
msc.productRevision("1.0");
|
||||||
@ -94,10 +94,8 @@ void setupmsc() {
|
|||||||
msc.mediaPresent(true);
|
msc.mediaPresent(true);
|
||||||
msc.begin(SD_MMC.numSectors(), SD_MMC.sectorSize());
|
msc.begin(SD_MMC.numSectors(), SD_MMC.sectorSize());
|
||||||
|
|
||||||
|
|
||||||
vTaskDelay(100);
|
vTaskDelay(100);
|
||||||
|
|
||||||
|
|
||||||
USB.begin();
|
USB.begin();
|
||||||
USB.onEvent(usbEventCallback);
|
USB.onEvent(usbEventCallback);
|
||||||
}
|
}
|
||||||
|
|||||||
@ -163,18 +163,7 @@ bool UpDateClassByme::CheckAndUpdate()
|
|||||||
return true;
|
return true;
|
||||||
/* code */
|
/* code */
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user