Compare commits
3 Commits
ef4eae6128
...
master
| Author | SHA1 | Date | |
|---|---|---|---|
| 3276dc5981 | |||
| 9014267de0 | |||
| 12904d5507 |
80
Version.txt
Normal file
80
Version.txt
Normal file
@ -0,0 +1,80 @@
|
|||||||
|
Version : V2.0.3
|
||||||
|
主要解决问题:
|
||||||
|
描述:光路改成双光纤进入双通道光闸再进入仪器,上下通道存在波长漂移。
|
||||||
|
解决方法:对上下通道进行波长定标后,将下通道的数据重采样到和上通道同一波长,进行数据处理。
|
||||||
|
|
||||||
|
功能:
|
||||||
|
|
||||||
|
1、上下通道需进行波长定标
|
||||||
|
在没有波长定标系数时,一直处于定标模式
|
||||||
|
如何进行波长定标:
|
||||||
|
1、将485接口接上电脑 串口选择对应的COM 波特率115200 打开串口
|
||||||
|
2、在 设置-->工作模式-->高级模式-->设置
|
||||||
|
3、断电重启仪器
|
||||||
|
4、使用SpectralPlot采集上下同道各50条数据
|
||||||
|
5、交给张欣欣处理得到波长系数
|
||||||
|
6、使用SpectralPlot 文件-->高级 -->打开串口 发送json命令
|
||||||
|
a是上通道定标系数
|
||||||
|
b是下通道定标系数
|
||||||
|
{
|
||||||
|
"command": "set_bochangxishu",
|
||||||
|
"bochangxishu": {
|
||||||
|
"a0": -1.37016491e-9,
|
||||||
|
"a1": -0.000052,
|
||||||
|
"a2": 0.440364,
|
||||||
|
"a3": 348.4284,
|
||||||
|
"b0": -1.2597071e-9,
|
||||||
|
"b1": -0.000053,
|
||||||
|
"b2": 0.440609,
|
||||||
|
"b3": 348.3989
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
如果是重新波长定标 先把波长定标系数设置为0,重启就进入定标模式
|
||||||
|
{
|
||||||
|
"command": "set_bochangxishu",
|
||||||
|
"bochangxishu": {
|
||||||
|
"a0": 0,
|
||||||
|
"a1": 0,
|
||||||
|
"a2": 0,
|
||||||
|
"a3": 0,
|
||||||
|
"b0": 0,
|
||||||
|
"b1": 0,
|
||||||
|
"b2": 0,
|
||||||
|
"b3": 0
|
||||||
|
}
|
||||||
|
}
|
||||||
|
7、断电重启
|
||||||
|
|
||||||
|
2、上下通道进行能量定标
|
||||||
|
能量定标必须先做波长定标后
|
||||||
|
1、使用SpectralPlot 文件-->设置-->定标-->导入灯文件-->设置光照-->采集数据-->计算 在SpectralPlot安装目录下就会有downgain.bin 和 upgain.bin两个文件
|
||||||
|
2、插上USB调试口,不打开
|
||||||
|
2、使用SpectralPlot 文件-->高级 -->打开串口 发送json命令
|
||||||
|
{
|
||||||
|
"command": "USB"
|
||||||
|
}
|
||||||
|
3、等待一会电脑就会将仪器识别为U盘,将两个文件复制到U盘目录中的/calfiles 文件夹下
|
||||||
|
4、断电重启
|
||||||
|
|
||||||
|
3、4G模式
|
||||||
|
开启4G模式后数据会自动上传到服务器
|
||||||
|
同时支持 mqtt 远程通讯控制
|
||||||
|
从服务器自动获取时间配置时间
|
||||||
|
获取GPS信息
|
||||||
|
|
||||||
|
1、使用SpectralPlot 文件-->高级 -->打开串口 发送json命令
|
||||||
|
{
|
||||||
|
"command": "set_4g",
|
||||||
|
"status_4g": "open_4g"
|
||||||
|
}
|
||||||
|
|
||||||
|
2、命令2
|
||||||
|
{
|
||||||
|
"command": "set_work_mode",
|
||||||
|
"work_mode": "4G_mode"
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@ -1,17 +1,23 @@
|
|||||||
float catmullSlope(float x[], float y[], int n, int i)
|
#include "CastumullSpline.h"
|
||||||
|
|
||||||
|
float catmullSlope(float *x, float *y, int n, int i)
|
||||||
{
|
{
|
||||||
if (x[i + 1] == x[i - 1]) return 0;
|
if (x[i + 1] == x[i - 1]) return 0;
|
||||||
return (y[i + 1] - y[i - 1]) / (x[i + 1] - x[i - 1]);
|
return (y[i + 1] - y[i - 1]) / (x[i + 1] - x[i - 1]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
float CatmullSpline(float xValues[], float yValues[], int numValues, float pointX, bool trim)
|
float CatmullSpline(float *xValues, float *yValues, int numValues, float pointX, int trim)
|
||||||
{
|
{
|
||||||
if (trim)
|
// if (trim)
|
||||||
{
|
// {
|
||||||
if (pointX <= xValues[0]) return yValues[0];
|
// if (pointX <= xValues[0]) return yValues[0];
|
||||||
if (pointX >= xValues[numValues - 1]) return yValues[numValues - 1];
|
// if (pointX >= xValues[numValues - 1]) return yValues[numValues - 1];
|
||||||
}
|
// }
|
||||||
|
|
||||||
|
|
||||||
|
if (pointX <= xValues[0]) return yValues[trim];
|
||||||
|
if (pointX >= xValues[numValues - 1]) return yValues[trim];
|
||||||
|
|
||||||
auto i = 0;
|
auto i = 0;
|
||||||
if (pointX <= xValues[0]) i = 0;
|
if (pointX <= xValues[0]) i = 0;
|
||||||
@ -55,3 +61,43 @@ float CatmullSpline(float xValues[], float yValues[], int numValues, float point
|
|||||||
return rst;
|
return rst;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
float LinearSpectrumInterp(const float *wave,const float *data,int n,float targetWave,int count)
|
||||||
|
{
|
||||||
|
|
||||||
|
if(targetWave <= wave[0])
|
||||||
|
{
|
||||||
|
// Serial.printf("count: %d \n",count);
|
||||||
|
// Serial.printf("targetWave: %f \n",targetWave);
|
||||||
|
// Serial.printf("wave: %f \n",wave[0]);
|
||||||
|
return data[count];
|
||||||
|
}
|
||||||
|
|
||||||
|
if(targetWave >= wave[n-1])
|
||||||
|
{
|
||||||
|
// Serial.printf("count: %d \n",count);
|
||||||
|
// Serial.printf("targetWave: %f \n",targetWave);
|
||||||
|
// Serial.printf("wave: %f \n",wave[n-1]);
|
||||||
|
return data[count];
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
int left = 0;
|
||||||
|
int right = n - 1;
|
||||||
|
|
||||||
|
|
||||||
|
while(right - left > 1)
|
||||||
|
{
|
||||||
|
int mid = (left + right) >> 1;
|
||||||
|
|
||||||
|
if(wave[mid] > targetWave)
|
||||||
|
right = mid;
|
||||||
|
else
|
||||||
|
left = mid;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
float t = (targetWave - wave[left]) / (wave[right] - wave[left]);
|
||||||
|
|
||||||
|
return data[left] + t * (data[right] - data[left]);
|
||||||
|
}
|
||||||
@ -2,8 +2,8 @@
|
|||||||
#define CASTUMULLSPLINE_H
|
#define CASTUMULLSPLINE_H
|
||||||
|
|
||||||
#include <Arduino.h>
|
#include <Arduino.h>
|
||||||
float CatmullSpline(float xValues[], float yValues[], int numValues, float pointX, bool trim = true);
|
float CatmullSpline(float *xValues, float *yValues, int numValues, float pointX, int trim);
|
||||||
|
float LinearSpectrumInterp(const float *wave,const float *data,int n,float targetWave,int count);
|
||||||
|
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@ -17,34 +17,34 @@ DallasTemperature DS18b20(&oneWire);
|
|||||||
int temp_number;
|
int temp_number;
|
||||||
|
|
||||||
|
|
||||||
uint8_t *p[8] = {sensoraddr[0],sensoraddr[1],sensoraddr[2],sensoraddr[3],sensoraddr[4],sensoraddr[5],sensoraddr[6],sensoraddr[7]};
|
// uint8_t *p[8] = {sensoraddr[0],sensoraddr[1],sensoraddr[2],sensoraddr[3],sensoraddr[4],sensoraddr[5],sensoraddr[6],sensoraddr[7]};
|
||||||
|
|
||||||
//冒泡排序 将温度地址 DeviceAddress sensoraddr[30]; 从小到大排序
|
//冒泡排序 将温度地址 DeviceAddress sensoraddr[30]; 从小到大排序
|
||||||
void bubble_sort(DeviceAddress *addr,int n)
|
// void bubble_sort(DeviceAddress *addr,int n)
|
||||||
{
|
// {
|
||||||
uint64_t a1 ,a2;
|
// uint64_t a1 ,a2;
|
||||||
for (int i = 0; i < n; i++)
|
// for (int i = 0; i < n; i++)
|
||||||
{
|
// {
|
||||||
for(uint8_t b = 0 ; b<8;b++)
|
// for(uint8_t b = 0 ; b<8;b++)
|
||||||
{
|
// {
|
||||||
a1 += addr[i][b];
|
// a1 += addr[i][b];
|
||||||
}
|
// }
|
||||||
|
|
||||||
for (int j = 0; j < n-i-1; j++)
|
// for (int j = 0; j < n-i-1; j++)
|
||||||
{
|
// {
|
||||||
for(uint8_t c = 0 ; c<8;c++)
|
// for(uint8_t c = 0 ; c<8;c++)
|
||||||
{
|
// {
|
||||||
a2 += addr[j][c];
|
// a2 += addr[j][c];
|
||||||
}
|
// }
|
||||||
if (a1 > a2)
|
// if (a1 > a2)
|
||||||
{
|
// {
|
||||||
uint8_t *temp = p[i];
|
// uint8_t *temp = p[i];
|
||||||
p[i] = p[j];
|
// p[i] = p[j];
|
||||||
p[j] = temp;
|
// p[j] = temp;
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
|
|
||||||
|
|
||||||
uint8_t DS18b20_init()
|
uint8_t DS18b20_init()
|
||||||
@ -65,26 +65,52 @@ uint8_t DS18b20_init()
|
|||||||
}
|
}
|
||||||
i++;
|
i++;
|
||||||
}
|
}
|
||||||
write_log(log_path,"ds18b20 has" + String(temp_number),10);
|
write_log(log_path,"ds18b20 has" + String(temp_number),20);
|
||||||
for(size_t i = 0; i < temp_number; i++)
|
for(size_t i = 0; i < temp_number; i++)
|
||||||
{
|
{
|
||||||
DS18b20.getAddress(sensoraddr[i],i);
|
DS18b20.getAddress(sensoraddr[i],i);
|
||||||
}
|
}
|
||||||
bubble_sort(sensoraddr,temp_number);
|
// bubble_sort(sensoraddr,temp_number);
|
||||||
return temp_number;
|
return temp_number;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
//温度监测
|
//温度监测
|
||||||
|
float temp_last[8] = {25,25,25,25,25,25,25,25};
|
||||||
void getall_temp(float *temp)
|
void getall_temp(float *temp)
|
||||||
{
|
{
|
||||||
DS18b20.requestTemperatures(); // Send the command to get temperatures
|
DS18b20.requestTemperatures(); // Send the command to get temperatures
|
||||||
for(int8_t i ;i<temp_number;i++)
|
// vTaskDelay(1000);
|
||||||
|
|
||||||
|
for(int8_t i =0 ;i<temp_number;i++)
|
||||||
{
|
{
|
||||||
temp[i] = DS18b20.getTempC(p[i]);
|
temp[i] = DS18b20.getTempC(sensoraddr[i]);
|
||||||
// temp[i] = getone_temp(i);
|
uint32_t n = 0;
|
||||||
|
while(temp[i] < -110)
|
||||||
|
{
|
||||||
|
vTaskDelay(100);
|
||||||
|
// temp[i] = DS18b20.getTempC(p[i]);
|
||||||
|
temp[i] = getone_temp(i);
|
||||||
|
n++;
|
||||||
|
if (n>5)
|
||||||
|
{
|
||||||
|
write_log(log_path,"ds18b20 get temperature failed",10);
|
||||||
|
// return;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (temp[i] < -110)
|
||||||
|
{
|
||||||
|
temp[i] = temp_last[i];
|
||||||
|
write_log(log_path,"ds18b20 get temperature failed, use last temperature",10);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
temp_last[i] = temp[i];
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// write_log(log_path,"get temperatures ok",10);
|
// write_log(log_path,"get temperatures ok",10);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -92,7 +118,7 @@ float getone_temp(uint8_t address)
|
|||||||
{
|
{
|
||||||
float temp;
|
float temp;
|
||||||
DS18b20.requestTemperatures(); // Send the command to get temperatures
|
DS18b20.requestTemperatures(); // Send the command to get temperatures
|
||||||
temp = DS18b20.getTempC(p[address]);
|
temp = DS18b20.getTempC(sensoraddr[address]);
|
||||||
return temp;
|
return temp;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -273,7 +273,7 @@ int SensorIS11::OptSnenser(int persent)
|
|||||||
{
|
{
|
||||||
if (maxvaluenow > maxvalue)
|
if (maxvaluenow > maxvalue)
|
||||||
{
|
{
|
||||||
shutternow = shutternow *0.7;
|
shutternow = shutternow *0.7 - 1;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@ -285,11 +285,10 @@ int SensorIS11::OptSnenser(int persent)
|
|||||||
shutternow = maxtime;
|
shutternow = maxtime;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
GetOneDate(shutternow);
|
GetOneDate(shutternow);
|
||||||
maxvaluenow = Getmaxvalue(DATABUFF, SensorInfo.BandNum);
|
maxvaluenow = Getmaxvalue(DATABUFF, SensorInfo.BandNum);
|
||||||
#ifdef ARDUINO
|
|
||||||
|
|
||||||
#endif
|
|
||||||
numberoftry++;
|
numberoftry++;
|
||||||
if (numberoftry > 200)
|
if (numberoftry > 200)
|
||||||
{
|
{
|
||||||
@ -303,9 +302,9 @@ int SensorIS11::OptSnenser(int persent)
|
|||||||
}
|
}
|
||||||
vTaskDelay(1);
|
vTaskDelay(1);
|
||||||
}
|
}
|
||||||
#ifdef ARDUINO
|
// #ifdef ARDUINO
|
||||||
write_log(log_path,"zi dong value:"+String(shutternow),10);
|
write_log(log_path,"zi dong value:"+String(shutternow),10);
|
||||||
#endif
|
// #endif
|
||||||
if (shutternow<0)
|
if (shutternow<0)
|
||||||
{
|
{
|
||||||
shutternow=maxtime;
|
shutternow=maxtime;
|
||||||
@ -507,96 +506,207 @@ void SensorIS11::TakeOneJob1(bool dingbing)
|
|||||||
|
|
||||||
index++;
|
index++;
|
||||||
work_progress = 100 ;
|
work_progress = 100 ;
|
||||||
IS11_datastruct_fanshelv.NCa == 0;
|
IS11_datastruct_fanshelv.NCa = 0;
|
||||||
write_log(log_path,"take one job end.",20);
|
write_log(log_path,"take one job end.",20);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// void SensorIS11::TakeOneJob()
|
||||||
|
// {
|
||||||
|
// index++;
|
||||||
|
// ds1302_date.getDateTime(&sys_time);
|
||||||
|
// String time = String(sys_time.year) +"."+ String(sys_time.month) +"."+ String(sys_time.day)+" "+String(sys_time.hour)+":"+String(sys_time.minute)+":"+String(sys_time.second);
|
||||||
|
// write_log(log_path,time + " start take one job",10);
|
||||||
|
// SensorInfo.BandNum = 2048;
|
||||||
|
// work_progress = 0 ;
|
||||||
|
// float temp[8];
|
||||||
|
// getall_temp(temp);
|
||||||
|
// //opt_up opt_down dark_up dn_up dn_down dark_down
|
||||||
|
// // write_log(log_path,"start take one jon",20);
|
||||||
|
// // write_log(log_path,"start",10);
|
||||||
|
|
||||||
|
// //1 opt_up
|
||||||
|
// #if SHUTTER_TYPE == 1
|
||||||
|
// servo_direction(1);
|
||||||
|
// SetShutter(2);
|
||||||
|
// #elif SHUTTER_TYPE == 2
|
||||||
|
// shutter_up();
|
||||||
|
// #endif
|
||||||
|
|
||||||
|
// shutterup=OptSnenser(70);
|
||||||
|
// shutterdown = shutterup;
|
||||||
|
|
||||||
|
|
||||||
|
// #if SHUTTER_TYPE == 1
|
||||||
|
// SetShutter(1);
|
||||||
|
// #elif SHUTTER_TYPE == 2
|
||||||
|
// shutter_off();
|
||||||
|
// #endif
|
||||||
|
// work_progress = 30;
|
||||||
|
|
||||||
|
// //2 dark
|
||||||
|
// //dark_up
|
||||||
|
// #if SHUTTER_TYPE == 1
|
||||||
|
// SetShutter(1);
|
||||||
|
// #elif SHUTTER_TYPE == 2
|
||||||
|
// shutter_up();
|
||||||
|
// #endif
|
||||||
|
|
||||||
|
// GetOneDate(shutterup);
|
||||||
|
// for (int i = 0; i < SensorInfo.BandNum;i++)
|
||||||
|
// {
|
||||||
|
// IS11_datastruct_dark_up.data[i] = DATABUFF[i];
|
||||||
|
// IS11_datastruct_dark_down.data[i] = DATABUFF[i];
|
||||||
|
// }
|
||||||
|
// IS11_datastruct_dark_up.type = 0;
|
||||||
|
// IS11_datastruct_dark_up.direction = 2;
|
||||||
|
// IS11_datastruct_dark_up.tuigan_stat = get_tuigan_status();
|
||||||
|
// IS11_datastruct_dark_up.year = sys_time.year;
|
||||||
|
// IS11_datastruct_dark_up.month = sys_time.month;
|
||||||
|
// IS11_datastruct_dark_up.day = sys_time.day;
|
||||||
|
// IS11_datastruct_dark_up.hour = sys_time.hour;
|
||||||
|
// IS11_datastruct_dark_up.minute = sys_time.minute;
|
||||||
|
// IS11_datastruct_dark_up.second = sys_time.second;
|
||||||
|
// IS11_datastruct_dark_up.shutter_time = shutterup;
|
||||||
|
// IS11_datastruct_dark_up.index = index;
|
||||||
|
// memcpy(IS11_datastruct_dark_up.temprature,temp,8*sizeof(float));
|
||||||
|
|
||||||
|
// // dark_down
|
||||||
|
// IS11_datastruct_dark_down.type = 0;
|
||||||
|
// IS11_datastruct_dark_down.direction = 3;
|
||||||
|
// IS11_datastruct_dark_down.tuigan_stat = get_tuigan_status();
|
||||||
|
// IS11_datastruct_dark_down.year = sys_time.year;
|
||||||
|
// IS11_datastruct_dark_down.month = sys_time.month;
|
||||||
|
// IS11_datastruct_dark_down.day = sys_time.day;
|
||||||
|
// IS11_datastruct_dark_down.hour = sys_time.hour;
|
||||||
|
// IS11_datastruct_dark_down.minute = sys_time.minute;
|
||||||
|
// IS11_datastruct_dark_down.second = sys_time.second;
|
||||||
|
// IS11_datastruct_dark_down.shutter_time = shutterdown;
|
||||||
|
// IS11_datastruct_dark_down.index = index;
|
||||||
|
// memcpy(IS11_datastruct_dark_down.temprature,temp,8*sizeof(float));
|
||||||
|
|
||||||
|
// work_progress = 45;
|
||||||
|
|
||||||
|
// //3 dn_up
|
||||||
|
// #if SHUTTER_TYPE == 1
|
||||||
|
// SetShutter(2);
|
||||||
|
// GetOneDate(shutterup);
|
||||||
|
// SetShutter(1);
|
||||||
|
// #elif SHUTTER_TYPE == 2
|
||||||
|
// shutter_up();
|
||||||
|
// GetOneDate(shutterup);
|
||||||
|
// shutter_off();
|
||||||
|
// #endif
|
||||||
|
|
||||||
|
// for (int i = 0; i < SensorInfo.BandNum;i++)
|
||||||
|
// {
|
||||||
|
// IS11_datastruct_up.data[i] = DATABUFF[i];
|
||||||
|
// }
|
||||||
|
// IS11_datastruct_up.type = 0;
|
||||||
|
// IS11_datastruct_up.direction = 0;
|
||||||
|
// IS11_datastruct_up.tuigan_stat = get_tuigan_status();
|
||||||
|
// IS11_datastruct_up.year = sys_time.year;
|
||||||
|
// IS11_datastruct_up.month = sys_time.month;
|
||||||
|
// IS11_datastruct_up.day = sys_time.day;
|
||||||
|
// IS11_datastruct_up.hour = sys_time.hour;
|
||||||
|
// IS11_datastruct_up.minute = sys_time.minute;
|
||||||
|
// IS11_datastruct_up.second = sys_time.second;
|
||||||
|
// IS11_datastruct_up.shutter_time = shutterup;
|
||||||
|
// IS11_datastruct_up.index = index;
|
||||||
|
// memcpy(IS11_datastruct_up.temprature,temp,8*sizeof(float));
|
||||||
|
// work_progress = 60;
|
||||||
|
|
||||||
|
// //4 dn_down
|
||||||
|
|
||||||
|
// #if SHUTTER_TYPE == 1
|
||||||
|
// servo_direction(0);
|
||||||
|
// SetShutter(2);
|
||||||
|
// GetOneDate(shutterdown);
|
||||||
|
// SetShutter(1);
|
||||||
|
// #elif SHUTTER_TYPE == 2
|
||||||
|
// shutter_down();
|
||||||
|
// GetOneDate(shutterup);
|
||||||
|
// shutter_off();
|
||||||
|
// #endif
|
||||||
|
|
||||||
|
// for (int i = 0; i < SensorInfo.BandNum;i++) {
|
||||||
|
// IS11_datastruct_down.data[i] = DATABUFF[i];
|
||||||
|
// }
|
||||||
|
// IS11_datastruct_down.type = 0;
|
||||||
|
// IS11_datastruct_down.direction = 1;
|
||||||
|
// IS11_datastruct_down.tuigan_stat = get_tuigan_status();
|
||||||
|
// IS11_datastruct_down.year = sys_time.year;
|
||||||
|
// IS11_datastruct_down.month = sys_time.month;
|
||||||
|
// IS11_datastruct_down.day = sys_time.day;
|
||||||
|
// IS11_datastruct_down.hour = sys_time.hour;
|
||||||
|
// IS11_datastruct_down.minute = sys_time.minute;
|
||||||
|
// IS11_datastruct_down.second = sys_time.second;
|
||||||
|
// IS11_datastruct_down.shutter_time = shutterdown;
|
||||||
|
// IS11_datastruct_down.index = index;
|
||||||
|
// memcpy(IS11_datastruct_down.temprature,temp,8*sizeof(float));
|
||||||
|
// servo_off();
|
||||||
|
// work_progress = 75;
|
||||||
|
|
||||||
|
// write_log(log_path,"start SD.",10);
|
||||||
|
// if(!SD_MMC.exists("/guangpu_data/"+ String(sys_time.year)))
|
||||||
|
// {
|
||||||
|
// sdcard::Mkdir("/guangpu_data/"+ String(sys_time.year));
|
||||||
|
// }
|
||||||
|
// if(!SD_MMC.exists("/guangpu_data/"+ String(sys_time.year) + "/" + String(sys_time.month)))
|
||||||
|
// {
|
||||||
|
// sdcard::Mkdir("/guangpu_data/"+ String(sys_time.year) + "/" + String(sys_time.month));
|
||||||
|
// }
|
||||||
|
// if(!SD_MMC.exists("/guangpu_data/"+ String(sys_time.year) + "/" + String(sys_time.month) + "/" + String(sys_time.day)))
|
||||||
|
// {
|
||||||
|
// sdcard::Mkdir("/guangpu_data/"+ String(sys_time.year) + "/" + String(sys_time.month) + "/" + String(sys_time.day));
|
||||||
|
// }
|
||||||
|
// String path1 = "/guangpu_data/"+ String(sys_time.year) + "/" + String(sys_time.month) + "/" + String(sys_time.day);
|
||||||
|
|
||||||
|
// // sdcard::Mkdir(path1);
|
||||||
|
|
||||||
|
// String path2 = path1 + "/" + String(sys_time.hour) + "-" + String(sys_time.minute) + "-" + String(sys_time.second) + ".bin";
|
||||||
|
// File file;
|
||||||
|
// file = SD_MMC.open(path2,"wb");
|
||||||
|
// file.write((uint8_t *)(&IS11_datastruct_up),sizeof(IS11_datastruct));
|
||||||
|
// file.write((uint8_t *)(&IS11_datastruct_dark_up),sizeof(IS11_datastruct));
|
||||||
|
// file.write((uint8_t *)(&IS11_datastruct_down),sizeof(IS11_datastruct));
|
||||||
|
// file.write((uint8_t *)(&IS11_datastruct_dark_down),sizeof(IS11_datastruct));
|
||||||
|
// file.flush();
|
||||||
|
// file.close();
|
||||||
|
// work_progress = 90;
|
||||||
|
|
||||||
|
|
||||||
|
// path2 = "/system/index.bin";
|
||||||
|
// file = SD_MMC.open(path2,"wb");
|
||||||
|
// file.write((uint8_t *) &index,4);
|
||||||
|
// file.flush();
|
||||||
|
// file.close();
|
||||||
|
|
||||||
|
|
||||||
|
// work_progress = 100;
|
||||||
|
// IS11_datastruct_fanshelv.NCa = 0;
|
||||||
|
// write_log(log_path,"take one job end.",10);
|
||||||
|
// }
|
||||||
|
|
||||||
void SensorIS11::TakeOneJob()
|
void SensorIS11::TakeOneJob()
|
||||||
{
|
{
|
||||||
index++;
|
index++;
|
||||||
ds1302_date.getDateTime(&sys_time);
|
ds1302_date.getDateTime(&sys_time);
|
||||||
String time = String(sys_time.year) +"."+ String(sys_time.month) +"."+ String(sys_time.day)+" "+String(sys_time.hour)+":"+String(sys_time.minute)+":"+String(sys_time.second);
|
String time = String(sys_time.year) +"."+ String(sys_time.month) +"."+ String(sys_time.day)+" "+String(sys_time.hour)+":"+String(sys_time.minute)+":"+String(sys_time.second);
|
||||||
|
write_log(log_path," ",10);
|
||||||
write_log(log_path,time + " start take one job",10);
|
write_log(log_path,time + " start take one job",10);
|
||||||
SensorInfo.BandNum = 2048;
|
SensorInfo.BandNum = 2048;
|
||||||
work_progress = 0 ;
|
work_progress = 0 ;
|
||||||
float temp[8];
|
float temp[8];
|
||||||
getall_temp(temp);
|
getall_temp(temp);
|
||||||
//opt_up opt_down dark_up dn_up dn_down dark_down
|
|
||||||
// write_log(log_path,"start take one jon",20);
|
|
||||||
// write_log(log_path,"start",10);
|
|
||||||
|
|
||||||
//1 opt_up
|
//up_opt
|
||||||
#if SHUTTER_TYPE == 1
|
|
||||||
servo_direction(1);
|
|
||||||
SetShutter(2);
|
|
||||||
#elif SHUTTER_TYPE == 2
|
|
||||||
shutter_up();
|
|
||||||
#endif
|
|
||||||
|
|
||||||
shutterup=OptSnenser(70);
|
|
||||||
shutterdown = shutterup;
|
|
||||||
|
|
||||||
|
|
||||||
#if SHUTTER_TYPE == 1
|
|
||||||
SetShutter(1);
|
|
||||||
#elif SHUTTER_TYPE == 2
|
|
||||||
shutter_off();
|
|
||||||
#endif
|
|
||||||
work_progress = 30;
|
|
||||||
|
|
||||||
//2 dark
|
|
||||||
//dark_up
|
|
||||||
#if SHUTTER_TYPE == 1
|
|
||||||
SetShutter(1);
|
|
||||||
#elif SHUTTER_TYPE == 2
|
|
||||||
shutter_up();
|
shutter_up();
|
||||||
#endif
|
shutterup = OptSnenser(70);
|
||||||
|
|
||||||
|
Serial.printf("up_opt shutterup = %d \n",shutterup);
|
||||||
|
//up_dn
|
||||||
GetOneDate(shutterup);
|
GetOneDate(shutterup);
|
||||||
for (int i = 0; i < SensorInfo.BandNum;i++)
|
|
||||||
{
|
|
||||||
IS11_datastruct_dark_up.data[i] = DATABUFF[i];
|
|
||||||
IS11_datastruct_dark_down.data[i] = DATABUFF[i];
|
|
||||||
}
|
|
||||||
IS11_datastruct_dark_up.type = 0;
|
|
||||||
IS11_datastruct_dark_up.direction = 2;
|
|
||||||
IS11_datastruct_dark_up.tuigan_stat = get_tuigan_status();
|
|
||||||
IS11_datastruct_dark_up.year = sys_time.year;
|
|
||||||
IS11_datastruct_dark_up.month = sys_time.month;
|
|
||||||
IS11_datastruct_dark_up.day = sys_time.day;
|
|
||||||
IS11_datastruct_dark_up.hour = sys_time.hour;
|
|
||||||
IS11_datastruct_dark_up.minute = sys_time.minute;
|
|
||||||
IS11_datastruct_dark_up.second = sys_time.second;
|
|
||||||
IS11_datastruct_dark_up.shutter_time = shutterup;
|
|
||||||
IS11_datastruct_dark_up.index = index;
|
|
||||||
memcpy(IS11_datastruct_dark_up.temprature,temp,8*sizeof(float));
|
|
||||||
|
|
||||||
// dark_down
|
|
||||||
IS11_datastruct_dark_down.type = 0;
|
|
||||||
IS11_datastruct_dark_down.direction = 3;
|
|
||||||
IS11_datastruct_dark_down.tuigan_stat = get_tuigan_status();
|
|
||||||
IS11_datastruct_dark_down.year = sys_time.year;
|
|
||||||
IS11_datastruct_dark_down.month = sys_time.month;
|
|
||||||
IS11_datastruct_dark_down.day = sys_time.day;
|
|
||||||
IS11_datastruct_dark_down.hour = sys_time.hour;
|
|
||||||
IS11_datastruct_dark_down.minute = sys_time.minute;
|
|
||||||
IS11_datastruct_dark_down.second = sys_time.second;
|
|
||||||
IS11_datastruct_dark_down.shutter_time = shutterdown;
|
|
||||||
IS11_datastruct_dark_down.index = index;
|
|
||||||
memcpy(IS11_datastruct_dark_down.temprature,temp,8*sizeof(float));
|
|
||||||
|
|
||||||
work_progress = 45;
|
|
||||||
|
|
||||||
//3 dn_up
|
|
||||||
#if SHUTTER_TYPE == 1
|
|
||||||
SetShutter(2);
|
|
||||||
GetOneDate(shutterup);
|
|
||||||
SetShutter(1);
|
|
||||||
#elif SHUTTER_TYPE == 2
|
|
||||||
shutter_up();
|
|
||||||
GetOneDate(shutterup);
|
|
||||||
shutter_off();
|
|
||||||
#endif
|
|
||||||
|
|
||||||
for (int i = 0; i < SensorInfo.BandNum;i++)
|
for (int i = 0; i < SensorInfo.BandNum;i++)
|
||||||
{
|
{
|
||||||
@ -614,24 +724,85 @@ void SensorIS11::TakeOneJob()
|
|||||||
IS11_datastruct_up.shutter_time = shutterup;
|
IS11_datastruct_up.shutter_time = shutterup;
|
||||||
IS11_datastruct_up.index = index;
|
IS11_datastruct_up.index = index;
|
||||||
memcpy(IS11_datastruct_up.temprature,temp,8*sizeof(float));
|
memcpy(IS11_datastruct_up.temprature,temp,8*sizeof(float));
|
||||||
work_progress = 60;
|
work_progress = 30;
|
||||||
|
|
||||||
//4 dn_down
|
//up_dark
|
||||||
|
|
||||||
#if SHUTTER_TYPE == 1
|
|
||||||
servo_direction(0);
|
|
||||||
SetShutter(2);
|
|
||||||
GetOneDate(shutterdown);
|
|
||||||
SetShutter(1);
|
|
||||||
#elif SHUTTER_TYPE == 2
|
|
||||||
shutter_down();
|
|
||||||
GetOneDate(shutterup);
|
|
||||||
shutter_off();
|
shutter_off();
|
||||||
#endif
|
work_progress = 45;
|
||||||
|
|
||||||
for (int i = 0; i < SensorInfo.BandNum;i++) {
|
GetOneDate(shutterup);
|
||||||
IS11_datastruct_down.data[i] = DATABUFF[i];
|
for (int i = 0; i < SensorInfo.BandNum;i++)
|
||||||
|
{
|
||||||
|
IS11_datastruct_dark_up.data[i] = DATABUFF[i];
|
||||||
}
|
}
|
||||||
|
IS11_datastruct_dark_up.type = 0;
|
||||||
|
IS11_datastruct_dark_up.direction = 2;
|
||||||
|
IS11_datastruct_dark_up.tuigan_stat = get_tuigan_status();
|
||||||
|
IS11_datastruct_dark_up.year = sys_time.year;
|
||||||
|
IS11_datastruct_dark_up.month = sys_time.month;
|
||||||
|
IS11_datastruct_dark_up.day = sys_time.day;
|
||||||
|
IS11_datastruct_dark_up.hour = sys_time.hour;
|
||||||
|
IS11_datastruct_dark_up.minute = sys_time.minute;
|
||||||
|
IS11_datastruct_dark_up.second = sys_time.second;
|
||||||
|
IS11_datastruct_dark_up.shutter_time = shutterup;
|
||||||
|
IS11_datastruct_dark_up.index = index;
|
||||||
|
memcpy(IS11_datastruct_dark_up.temprature,temp,8*sizeof(float));
|
||||||
|
|
||||||
|
work_progress = 60;
|
||||||
|
|
||||||
|
|
||||||
|
//down_opt
|
||||||
|
shutter_down();
|
||||||
|
shutterdown = OptSnenser(70);
|
||||||
|
Serial.printf("down_opt shutterdown = %d \n",shutterdown);
|
||||||
|
//down_dn
|
||||||
|
GetOneDate(shutterdown);
|
||||||
|
///////////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
bool flag = SensorIS11::guangpu_bochang.is_valid;
|
||||||
|
|
||||||
|
if(flag)
|
||||||
|
{
|
||||||
|
write_log(log_path,"guangpu bochang is valid",10);
|
||||||
|
const int numValues = SensorInfo.BandNum;
|
||||||
|
float xValues[2048];
|
||||||
|
float *yValues;
|
||||||
|
|
||||||
|
double b0 = SensorIS11::guangpu_bochang.b0;
|
||||||
|
double b1 = SensorIS11::guangpu_bochang.b1;
|
||||||
|
double b2 = SensorIS11::guangpu_bochang.b2;
|
||||||
|
double b3 = SensorIS11::guangpu_bochang.b3;
|
||||||
|
for (uint32_t i = 0; i < 2048; i++)
|
||||||
|
{
|
||||||
|
xValues[i] = b0 * i * i * i + b1 * i * i + b2 * i+ b3;
|
||||||
|
IS11_datastruct_down.data[i] = DATABUFF[i];
|
||||||
|
|
||||||
|
}
|
||||||
|
yValues = IS11_datastruct_down.data;
|
||||||
|
for (int i = 0; i < SensorInfo.BandNum;i++) {
|
||||||
|
float xValue_target = SensorInfo.a1 * i * i * i + SensorInfo.a2 * i * i + SensorInfo.a3 * i+ SensorInfo.a4;
|
||||||
|
|
||||||
|
IS11_datastruct_down.data[i] = LinearSpectrumInterp(xValues, yValues, numValues, xValue_target , i);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
write_log(log_path,"guangpu bochang is invalid",10);
|
||||||
|
for (uint32_t i = 0; i < 2048; i++)
|
||||||
|
{
|
||||||
|
IS11_datastruct_down.data[i] = DATABUFF[i];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// Serial.printf("down SensorInfo.BandNum = %d \n",SensorInfo.BandNum);
|
||||||
|
// vTaskDelay(10);
|
||||||
|
// for (int i = 0; i < SensorInfo.BandNum;i++)
|
||||||
|
// {
|
||||||
|
// IS11_datastruct_down.data[i] = DATABUFF[i];
|
||||||
|
// }
|
||||||
|
|
||||||
|
/////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
IS11_datastruct_down.type = 0;
|
IS11_datastruct_down.type = 0;
|
||||||
IS11_datastruct_down.direction = 1;
|
IS11_datastruct_down.direction = 1;
|
||||||
IS11_datastruct_down.tuigan_stat = get_tuigan_status();
|
IS11_datastruct_down.tuigan_stat = get_tuigan_status();
|
||||||
@ -644,23 +815,43 @@ void SensorIS11::TakeOneJob()
|
|||||||
IS11_datastruct_down.shutter_time = shutterdown;
|
IS11_datastruct_down.shutter_time = shutterdown;
|
||||||
IS11_datastruct_down.index = index;
|
IS11_datastruct_down.index = index;
|
||||||
memcpy(IS11_datastruct_down.temprature,temp,8*sizeof(float));
|
memcpy(IS11_datastruct_down.temprature,temp,8*sizeof(float));
|
||||||
servo_off();
|
|
||||||
work_progress = 75;
|
work_progress = 75;
|
||||||
|
//down_dark
|
||||||
|
shutter_off();
|
||||||
|
GetOneDate(shutterdown);
|
||||||
|
for (int i = 0; i < SensorInfo.BandNum;i++)
|
||||||
|
{
|
||||||
|
IS11_datastruct_dark_down.data[i] = DATABUFF[i];
|
||||||
|
}
|
||||||
|
IS11_datastruct_dark_down.type = 0;
|
||||||
|
IS11_datastruct_dark_down.direction = 3;
|
||||||
|
IS11_datastruct_dark_down.tuigan_stat = get_tuigan_status();
|
||||||
|
IS11_datastruct_dark_down.year = sys_time.year;
|
||||||
|
IS11_datastruct_dark_down.month = sys_time.month;
|
||||||
|
IS11_datastruct_dark_down.day = sys_time.day;
|
||||||
|
IS11_datastruct_dark_down.hour = sys_time.hour;
|
||||||
|
IS11_datastruct_dark_down.minute = sys_time.minute;
|
||||||
|
IS11_datastruct_dark_down.second = sys_time.second;
|
||||||
|
IS11_datastruct_dark_down.shutter_time = shutterdown;
|
||||||
|
IS11_datastruct_dark_down.index = index;
|
||||||
|
memcpy(IS11_datastruct_dark_down.temprature,temp,8*sizeof(float));
|
||||||
|
|
||||||
|
|
||||||
write_log(log_path,"start SD.",10);
|
write_log(log_path,"start SD.",10);
|
||||||
if(!SD_MMC.exists("/guangpu_data/"+ String(sys_time.year)))
|
if(!SD_MMC.exists("/data/"+ String(sys_time.year)))
|
||||||
{
|
{
|
||||||
sdcard::Mkdir("/guangpu_data/"+ String(sys_time.year));
|
sdcard::Mkdir("/data/"+ String(sys_time.year));
|
||||||
}
|
}
|
||||||
if(!SD_MMC.exists("/guangpu_data/"+ String(sys_time.year) + "/" + String(sys_time.month)))
|
if(!SD_MMC.exists("/data/"+ String(sys_time.year) + "/" + String(sys_time.month)))
|
||||||
{
|
{
|
||||||
sdcard::Mkdir("/guangpu_data/"+ String(sys_time.year) + "/" + String(sys_time.month));
|
sdcard::Mkdir("/data/"+ String(sys_time.year) + "/" + String(sys_time.month));
|
||||||
}
|
}
|
||||||
if(!SD_MMC.exists("/guangpu_data/"+ String(sys_time.year) + "/" + String(sys_time.month) + "/" + String(sys_time.day)))
|
if(!SD_MMC.exists("/data/"+ String(sys_time.year) + "/" + String(sys_time.month) + "/" + String(sys_time.day)))
|
||||||
{
|
{
|
||||||
sdcard::Mkdir("/guangpu_data/"+ String(sys_time.year) + "/" + String(sys_time.month) + "/" + String(sys_time.day));
|
sdcard::Mkdir("/data/"+ String(sys_time.year) + "/" + String(sys_time.month) + "/" + String(sys_time.day));
|
||||||
}
|
}
|
||||||
String path1 = "/guangpu_data/"+ String(sys_time.year) + "/" + String(sys_time.month) + "/" + String(sys_time.day);
|
String path1 = "/data/"+ String(sys_time.year) + "/" + String(sys_time.month) + "/" + String(sys_time.day);
|
||||||
|
|
||||||
// sdcard::Mkdir(path1);
|
// sdcard::Mkdir(path1);
|
||||||
|
|
||||||
@ -684,11 +875,10 @@ void SensorIS11::TakeOneJob()
|
|||||||
|
|
||||||
|
|
||||||
work_progress = 100;
|
work_progress = 100;
|
||||||
IS11_datastruct_fanshelv.NCa == 0;
|
IS11_datastruct_fanshelv.NCa = 0;
|
||||||
|
shutter_down();
|
||||||
write_log(log_path,"take one job end.",10);
|
write_log(log_path,"take one job end.",10);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
SensorIS11::SensorIS11()
|
SensorIS11::SensorIS11()
|
||||||
{
|
{
|
||||||
shutternow = 0;
|
shutternow = 0;
|
||||||
@ -817,7 +1007,7 @@ void SensorIS11::send_chongcaiyang(HardwareSerial *wb485Serial,IS11_datastruct
|
|||||||
uint32_t b = 0;
|
uint32_t b = 0;
|
||||||
while(xValue_target < xValue_stop)
|
while(xValue_target < xValue_stop)
|
||||||
{
|
{
|
||||||
IS11_datastruct_send.data[b] = CatmullSpline(xValues, yValues, numValues, xValue_target);
|
IS11_datastruct_send.data[b] = LinearSpectrumInterp(xValues, yValues, numValues, xValue_target,b);
|
||||||
b++;
|
b++;
|
||||||
xValue_target += chongcaiyang_step;
|
xValue_target += chongcaiyang_step;
|
||||||
}
|
}
|
||||||
@ -865,6 +1055,45 @@ void SensorIS11::send_chongcaiyang(HardwareSerial *wb485Serial,IS11_datastruct
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
// void SensorIS11::get_fanshelv()
|
||||||
|
// {
|
||||||
|
// IS11_datastruct_fanshelv.type = 0x06;
|
||||||
|
// IS11_datastruct_fanshelv.direction = IS11_datastruct_up.direction;
|
||||||
|
// IS11_datastruct_fanshelv.tuigan_stat = IS11_datastruct_up.tuigan_stat;
|
||||||
|
// IS11_datastruct_fanshelv.year = IS11_datastruct_up.year;
|
||||||
|
// IS11_datastruct_fanshelv.month = IS11_datastruct_up.month;
|
||||||
|
// IS11_datastruct_fanshelv.day = IS11_datastruct_up.day;
|
||||||
|
// IS11_datastruct_fanshelv.minute = IS11_datastruct_up.minute;
|
||||||
|
// IS11_datastruct_fanshelv.hour = IS11_datastruct_up.hour;
|
||||||
|
// IS11_datastruct_fanshelv.second = IS11_datastruct_up.second;
|
||||||
|
// IS11_datastruct_fanshelv.NCa = IS11_datastruct_up.NCa;
|
||||||
|
// IS11_datastruct_fanshelv.NCb = IS11_datastruct_up.NCb;
|
||||||
|
// IS11_datastruct_fanshelv.NCc = IS11_datastruct_up.NCc;
|
||||||
|
// // IS11_datastruct_fanshelv.NCc = 0;
|
||||||
|
// IS11_datastruct_fanshelv.shutter_time = IS11_datastruct_up.shutter_time;
|
||||||
|
// IS11_datastruct_fanshelv.index = IS11_datastruct_up.index;
|
||||||
|
// for(int i = 0; i < 8;i++)
|
||||||
|
// {
|
||||||
|
// IS11_datastruct_fanshelv.temprature[i] = IS11_datastruct_up.temprature[i];
|
||||||
|
// }
|
||||||
|
// for (int i = 0; i < 2048;i++)
|
||||||
|
// {
|
||||||
|
// IS11_datastruct_fanshelv.data[i] = (IS11_datastruct_down.data[i] - IS11_datastruct_dark_down.data[i]) / (IS11_datastruct_up.data[i] - IS11_datastruct_dark_up.data[i]);
|
||||||
|
// if(fanshelv_struct.shutter == 1)
|
||||||
|
// {
|
||||||
|
// IS11_datastruct_fanshelv.data[i] =IS11_datastruct_fanshelv.data[i]*fanshelv_struct.gain[i];
|
||||||
|
// }
|
||||||
|
// // IS11_datastruct_fanshelv.data[i] = IS11_datastruct_up.data[i];
|
||||||
|
// }
|
||||||
|
// // Serial0.println("fanshelv");
|
||||||
|
// // Serial0.printf("fanshelv_struct.shutter = %d \n",fanshelv_struct.shutter);
|
||||||
|
// // Serial0.printf("fanshelv_struct.data[%d] = %f\n",1,IS11_datastruct_fanshelv.data[0]);
|
||||||
|
// // Serial0.printf("fanshelv_struct.data[%d] = %f\n",2047,IS11_datastruct_fanshelv.data[2047]);
|
||||||
|
|
||||||
|
// IS11_datastruct_fanshelv.NCa = 1;
|
||||||
|
// }
|
||||||
|
|
||||||
|
|
||||||
void SensorIS11::get_fanshelv()
|
void SensorIS11::get_fanshelv()
|
||||||
{
|
{
|
||||||
IS11_datastruct_fanshelv.type = 0x06;
|
IS11_datastruct_fanshelv.type = 0x06;
|
||||||
@ -879,21 +1108,48 @@ void SensorIS11::get_fanshelv()
|
|||||||
IS11_datastruct_fanshelv.NCa = IS11_datastruct_up.NCa;
|
IS11_datastruct_fanshelv.NCa = IS11_datastruct_up.NCa;
|
||||||
IS11_datastruct_fanshelv.NCb = IS11_datastruct_up.NCb;
|
IS11_datastruct_fanshelv.NCb = IS11_datastruct_up.NCb;
|
||||||
IS11_datastruct_fanshelv.NCc = IS11_datastruct_up.NCc;
|
IS11_datastruct_fanshelv.NCc = IS11_datastruct_up.NCc;
|
||||||
IS11_datastruct_fanshelv.NCc = 0;
|
// IS11_datastruct_fanshelv.NCc = 0;
|
||||||
IS11_datastruct_fanshelv.shutter_time = IS11_datastruct_up.shutter_time;
|
IS11_datastruct_fanshelv.shutter_time = IS11_datastruct_up.shutter_time;
|
||||||
IS11_datastruct_fanshelv.index = IS11_datastruct_up.index;
|
IS11_datastruct_fanshelv.index = IS11_datastruct_up.index;
|
||||||
for(int i = 0; i < 8;i++)
|
for(int i = 0; i < 8;i++)
|
||||||
{
|
{
|
||||||
IS11_datastruct_fanshelv.temprature[i] = IS11_datastruct_up.temprature[i];
|
IS11_datastruct_fanshelv.temprature[i] = IS11_datastruct_up.temprature[i];
|
||||||
}
|
}
|
||||||
for (int i = 0; i < 2048;i++)
|
|
||||||
|
// Serial.println("fanshelv");
|
||||||
|
// Serial.printf("radiance_struct_up.shutter = %d \n",radiance_struct_up.shutter);
|
||||||
|
// Serial.printf("radiance_struct_down.shutter = %d \n",radiance_struct_down.shutter);
|
||||||
|
// Serial.printf("IS11_datastruct_up.shutter_time = %d\n",IS11_datastruct_up.shutter_time);
|
||||||
|
// Serial.printf("IS11_datastruct_down.shutter_time = %d\n",IS11_datastruct_down.shutter_time);
|
||||||
|
|
||||||
|
|
||||||
|
if(radiance_struct_up.shutter != 1)
|
||||||
{
|
{
|
||||||
IS11_datastruct_fanshelv.data[i] = (IS11_datastruct_down.data[i] - IS11_datastruct_dark_down.data[i]) / (IS11_datastruct_up.data[i] - IS11_datastruct_dark_up.data[i]);
|
for (int i = 0; i < 2048;i++)
|
||||||
if(fanshelv_struct.shutter == 1)
|
{
|
||||||
{
|
float rad_down = (IS11_datastruct_down.data[i]- IS11_datastruct_dark_down.data[i]) / IS11_datastruct_down.shutter_time *radiance_struct_down.shutter *radiance_struct_down.gain[i] ;
|
||||||
IS11_datastruct_fanshelv.data[i] =IS11_datastruct_fanshelv.data[i]*fanshelv_struct.gain[i];
|
float rad_up = (IS11_datastruct_up.data[i] - IS11_datastruct_dark_up.data[i]) / IS11_datastruct_up.shutter_time *radiance_struct_up.shutter *radiance_struct_up.gain[i];
|
||||||
|
IS11_datastruct_fanshelv.data[i] = rad_down / rad_up * PI;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
for (int i = 0; i < 2048;i++)
|
||||||
|
{
|
||||||
|
IS11_datastruct_fanshelv.data[i] = IS11_datastruct_down.data[i];
|
||||||
|
}
|
||||||
|
write_log(log_path,"no califile ",10);
|
||||||
|
}
|
||||||
|
|
||||||
|
// IS11_datastruct_fanshelv.data[i] = IS11_datastruct_up.data[i];
|
||||||
|
|
||||||
|
|
||||||
|
/////////////
|
||||||
|
// Serial0.println("fanshelv");
|
||||||
|
// Serial0.printf("fanshelv_struct.shutter = %d \n",fanshelv_struct.shutter);
|
||||||
|
// Serial0.printf("fanshelv_struct.data[%d] = %f\n",1,IS11_datastruct_fanshelv.data[0]);
|
||||||
|
// Serial0.printf("fanshelv_struct.data[%d] = %f\n",2047,IS11_datastruct_fanshelv.data[2047]);
|
||||||
|
|
||||||
IS11_datastruct_fanshelv.NCa = 1;
|
IS11_datastruct_fanshelv.NCa = 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -967,8 +1223,8 @@ void SensorIS11::calculation(float bochang1,float bochang2)
|
|||||||
{
|
{
|
||||||
xValues[i] = SensorInfo.a1 * i * i * i + SensorInfo.a2 * i * i + SensorInfo.a3 * i+ SensorInfo.a4;
|
xValues[i] = SensorInfo.a1 * i * i * i + SensorInfo.a2 * i * i + SensorInfo.a3 * i+ SensorInfo.a4;
|
||||||
}
|
}
|
||||||
float R1 = CatmullSpline(xValues, yValues, numValues, bochang1);
|
float R1 = LinearSpectrumInterp(xValues, yValues, numValues, bochang1,0);
|
||||||
float R2 = CatmullSpline(xValues, yValues, numValues, bochang2);
|
float R2 = LinearSpectrumInterp(xValues, yValues, numValues, bochang2,0);
|
||||||
|
|
||||||
calculation_value = (R1 - R2) / (R1 + R2);
|
calculation_value = (R1 - R2) / (R1 + R2);
|
||||||
}
|
}
|
||||||
@ -1104,17 +1360,25 @@ void SensorIS11::advanced_mode(u_int32_t direction,u_int32_t shutter_time,u_int3
|
|||||||
switch (direction)
|
switch (direction)
|
||||||
{
|
{
|
||||||
case 0:
|
case 0:
|
||||||
servo_direction(1);
|
// servo_direction(1);
|
||||||
SetShutter(2);
|
// SetShutter(2);
|
||||||
|
|
||||||
|
shutter_up();
|
||||||
IS11_datastructure_avn = &IS11_datastruct_up;
|
IS11_datastructure_avn = &IS11_datastruct_up;
|
||||||
|
|
||||||
|
|
||||||
|
// shutter_down();
|
||||||
|
// IS11_datastructure_avn = &IS11_datastruct_up;
|
||||||
break;
|
break;
|
||||||
case 1:
|
case 1:
|
||||||
servo_direction(0);
|
// servo_direction(0);
|
||||||
SetShutter(2);
|
// SetShutter(2);
|
||||||
|
shutter_down();
|
||||||
IS11_datastructure_avn = &IS11_datastruct_down;
|
IS11_datastructure_avn = &IS11_datastruct_down;
|
||||||
break;
|
break;
|
||||||
case 2:
|
case 2:
|
||||||
SetShutter(1);
|
// SetShutter(1);
|
||||||
|
shutter_off();
|
||||||
IS11_datastructure_avn = &IS11_datastruct_dark_up;
|
IS11_datastructure_avn = &IS11_datastruct_dark_up;
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
@ -1152,9 +1416,10 @@ void SensorIS11::advanced_mode(u_int32_t direction,u_int32_t shutter_time,u_int3
|
|||||||
{
|
{
|
||||||
|
|
||||||
// write_log(log_path,"remove_dark",10);
|
// write_log(log_path,"remove_dark",10);
|
||||||
SetShutter(1);
|
// SetShutter(1);
|
||||||
|
shutter_off();
|
||||||
GetOneDate(shutter_time);
|
GetOneDate(shutter_time);
|
||||||
SetShutter(2);
|
// SetShutter(2);
|
||||||
for (int i = 0; i < SensorInfo.BandNum;i++)
|
for (int i = 0; i < SensorInfo.BandNum;i++)
|
||||||
{
|
{
|
||||||
// if (i==1000)
|
// if (i==1000)
|
||||||
@ -1177,16 +1442,209 @@ void SensorIS11::advanced_mode(u_int32_t direction,u_int32_t shutter_time,u_int3
|
|||||||
aa--;
|
aa--;
|
||||||
caiji_times++;
|
caiji_times++;
|
||||||
}
|
}
|
||||||
|
|
||||||
for (int i = 0; i < SensorInfo.BandNum;i++)
|
for (int i = 0; i < SensorInfo.BandNum;i++)
|
||||||
{
|
{
|
||||||
IS11_datastructure_avn->data[i] = IS11_datastructure_avn->data[i] / collect_times;
|
IS11_datastructure_avn->data[i] = IS11_datastructure_avn->data[i] / collect_times;
|
||||||
}
|
}
|
||||||
SetShutter(1);
|
|
||||||
servo_off();
|
bool flag = SensorIS11::guangpu_bochang.is_valid;
|
||||||
IS11_datastruct_fanshelv.NCa == 0;
|
|
||||||
|
if(direction == 1 && flag)
|
||||||
|
{
|
||||||
|
|
||||||
|
// "a0": -1.37016491e-9,
|
||||||
|
// "a1": -0.000052,
|
||||||
|
// "a2": 0.440364,
|
||||||
|
// "a3": 348.4284,
|
||||||
|
|
||||||
|
// "b0": -1.2597071e-9,
|
||||||
|
// "b1": -0.000053,
|
||||||
|
// "b2": 0.440609,
|
||||||
|
// "b3": 348.3989
|
||||||
|
|
||||||
|
const int numValues = SensorInfo.BandNum;
|
||||||
|
float xValues[2048];
|
||||||
|
float *yValues;
|
||||||
|
|
||||||
|
double b0 = SensorIS11::guangpu_bochang.b0;
|
||||||
|
double b1 = SensorIS11::guangpu_bochang.b1;
|
||||||
|
double b2 = SensorIS11::guangpu_bochang.b2;
|
||||||
|
double b3 = SensorIS11::guangpu_bochang.b3;
|
||||||
|
write_log(log_path,"bochang:"+String(b0,4)+" "+String(b1,4)+" "+String(b2,4)+" "+String(b3,4),10);
|
||||||
|
yValues = IS11_datastructure_avn->data;
|
||||||
|
for (uint32_t i = 0; i < 2048; i++)
|
||||||
|
{
|
||||||
|
xValues[i] = b0 * i * i * i + b1 * i * i + b2 * i+ b3;
|
||||||
|
|
||||||
|
// yValues[i] = IS11_datastructure_avn->data[i];
|
||||||
|
}
|
||||||
|
vTaskDelay(1);
|
||||||
|
for (uint32_t i = 0; i < 2048;i++)
|
||||||
|
{
|
||||||
|
float x = i;
|
||||||
|
float xValue_target = SensorInfo.a1 * x * x * x + SensorInfo.a2 * x * x + SensorInfo.a3 * x+ SensorInfo.a4;
|
||||||
|
|
||||||
|
IS11_datastructure_avn->data[i] = LinearSpectrumInterp(xValues, yValues, 2048, xValue_target, i);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
IS11_datastruct_fanshelv.NCa = 0;
|
||||||
work_progress = 100;
|
work_progress = 100;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
// void SensorIS11::advanced_mode(u_int32_t direction,u_int32_t shutter_time,u_int32_t collect_times,u_int32_t remove_dark)
|
||||||
|
// {
|
||||||
|
|
||||||
|
// work_progress = 0;
|
||||||
|
// struct IS11_datastruct *IS11_datastructure_avn = nullptr;
|
||||||
|
// switch (direction)
|
||||||
|
// {
|
||||||
|
// case 0:
|
||||||
|
// // servo_direction(1);
|
||||||
|
// // SetShutter(2);
|
||||||
|
|
||||||
|
// // shutter_up();
|
||||||
|
// // IS11_datastructure_avn = &IS11_datastruct_up;
|
||||||
|
|
||||||
|
// work_progress = 100;
|
||||||
|
// return;
|
||||||
|
// // shutter_down();
|
||||||
|
// // IS11_datastructure_avn = &IS11_datastruct_up;
|
||||||
|
// break;
|
||||||
|
// case 1:
|
||||||
|
// // servo_direction(0);
|
||||||
|
// // SetShutter(2);
|
||||||
|
// shutter_down();
|
||||||
|
// IS11_datastructure_avn = &IS11_datastruct_down;
|
||||||
|
// break;
|
||||||
|
// case 2:
|
||||||
|
// // SetShutter(1);
|
||||||
|
// shutter_off();
|
||||||
|
// IS11_datastructure_avn = &IS11_datastruct_dark_up;
|
||||||
|
// break;
|
||||||
|
// default:
|
||||||
|
// break;
|
||||||
|
// }
|
||||||
|
|
||||||
|
// int aa = collect_times;
|
||||||
|
// uint32_t caiji_times = 0;
|
||||||
|
// memset(IS11_datastructure_avn->data,0,8192);
|
||||||
|
// getall_temp(IS11_datastructure_avn->temprature);
|
||||||
|
// ds1302_date.getDateTime(&sys_time);
|
||||||
|
// IS11_datastructure_avn->year = sys_time.year;
|
||||||
|
// IS11_datastructure_avn->month = sys_time.month;
|
||||||
|
// IS11_datastructure_avn->day = sys_time.day;
|
||||||
|
// IS11_datastructure_avn->hour = sys_time.hour;
|
||||||
|
// IS11_datastructure_avn->minute = sys_time.minute;
|
||||||
|
// IS11_datastructure_avn->second = sys_time.second;
|
||||||
|
|
||||||
|
// while(aa > 0)
|
||||||
|
// {
|
||||||
|
// work_progress = (caiji_times * 100) / (collect_times * 2) ;
|
||||||
|
|
||||||
|
// shutter_down();
|
||||||
|
// GetOneDate(shutter_time);
|
||||||
|
// for (int i = 0; i < SensorInfo.BandNum;i++)
|
||||||
|
// {
|
||||||
|
// IS11_datastructure_avn->data[i] += DATABUFF[i];
|
||||||
|
// IS11_datastruct_up.data[i] = DATABUFF[i];
|
||||||
|
// }
|
||||||
|
// IS11_datastructure_avn->type = 0;
|
||||||
|
// IS11_datastructure_avn->direction = direction;
|
||||||
|
// IS11_datastructure_avn->tuigan_stat = get_tuigan_status();
|
||||||
|
// IS11_datastructure_avn->shutter_time = shutter_time;
|
||||||
|
// IS11_datastructure_avn->index = index;
|
||||||
|
|
||||||
|
// if(remove_dark == 1 && direction != 2)
|
||||||
|
// {
|
||||||
|
|
||||||
|
// // write_log(log_path,"remove_dark",10);
|
||||||
|
// // SetShutter(1);
|
||||||
|
// shutter_off();
|
||||||
|
// GetOneDate(shutter_time);
|
||||||
|
// // SetShutter(2);
|
||||||
|
// for (int i = 0; i < SensorInfo.BandNum;i++)
|
||||||
|
// {
|
||||||
|
// // if (i==1000)
|
||||||
|
// // {
|
||||||
|
// // write_log(log_path,"or data:"+String(IS11_datastructure_avn->data[i])+ " darkdata:"+String(DATABUFF[i]),10);
|
||||||
|
|
||||||
|
// // /* code */
|
||||||
|
// // }
|
||||||
|
// IS11_datastructure_avn->data[i] -= DATABUFF[i];
|
||||||
|
// IS11_datastruct_up.data[i] -= DATABUFF[i];
|
||||||
|
// IS11_datastruct_dark_up.data[i] = DATABUFF[i];
|
||||||
|
// }
|
||||||
|
|
||||||
|
// IS11_datastruct_dark_up.type = 0;
|
||||||
|
// IS11_datastruct_dark_up.direction = 2;
|
||||||
|
// IS11_datastruct_dark_up.tuigan_stat = get_tuigan_status();
|
||||||
|
// IS11_datastruct_dark_up.shutter_time = shutter_time;
|
||||||
|
// IS11_datastruct_dark_up.index = index;
|
||||||
|
// // getall_temp(IS11_datastruct_dark_up.temprature);
|
||||||
|
// }
|
||||||
|
// aa--;
|
||||||
|
// caiji_times++;
|
||||||
|
// }
|
||||||
|
|
||||||
|
// for (int i = 0; i < SensorInfo.BandNum;i++)
|
||||||
|
// {
|
||||||
|
// IS11_datastructure_avn->data[i] = IS11_datastructure_avn->data[i] / collect_times;
|
||||||
|
// }
|
||||||
|
|
||||||
|
|
||||||
|
// if(direction == 1)
|
||||||
|
// {
|
||||||
|
|
||||||
|
// // "a0": -1.37016491e-9,
|
||||||
|
// // "a1": -0.000052,
|
||||||
|
// // "a2": 0.440364,
|
||||||
|
// // "a3": 348.4284,
|
||||||
|
|
||||||
|
// // "b0": -1.2597071e-9,
|
||||||
|
// // "b1": -0.000053,
|
||||||
|
// // "b2": 0.440609,
|
||||||
|
// // "b3": 348.3989
|
||||||
|
|
||||||
|
// const int numValues = SensorInfo.BandNum;
|
||||||
|
// float xValues[2048];
|
||||||
|
// float *yValues;
|
||||||
|
|
||||||
|
// double b0 = SensorIS11::guangpu_bochang.b0;
|
||||||
|
// double b1 = SensorIS11::guangpu_bochang.b1;
|
||||||
|
// double b2 = SensorIS11::guangpu_bochang.b2;
|
||||||
|
// double b3 = SensorIS11::guangpu_bochang.b3;
|
||||||
|
// write_log(log_path,"bochang:"+String(b0,4)+" "+String(b1,4)+" "+String(b2,4)+" "+String(b3,4),10);
|
||||||
|
// for (uint32_t i = 0; i < 2048; i++)
|
||||||
|
// {
|
||||||
|
// float x = i;
|
||||||
|
// xValues[i] = b0 * x * x * x + b1 * x * x + b2 * x+ b3;
|
||||||
|
|
||||||
|
// }
|
||||||
|
// yValues = IS11_datastructure_avn->data;
|
||||||
|
// vTaskDelay(1);
|
||||||
|
// for (uint32_t a = 0; a < 2048;a++)
|
||||||
|
// {
|
||||||
|
// float i = a;
|
||||||
|
// double xValue_target = SensorInfo.a1 * i * i * i + SensorInfo.a2 * i * i + SensorInfo.a3 * i+ SensorInfo.a4;
|
||||||
|
|
||||||
|
// IS11_datastructure_avn->data[a] = LinearSpectrumInterp(xValues, yValues, 2048, xValue_target, a);
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
|
||||||
|
|
||||||
|
// IS11_datastruct_fanshelv.NCa = 0;
|
||||||
|
// work_progress = 100;
|
||||||
|
// }
|
||||||
|
|
||||||
/*
|
/*
|
||||||
////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
opt
|
opt
|
||||||
@ -1199,14 +1657,17 @@ void SensorIS11::opt(u_int32_t direction)
|
|||||||
{
|
{
|
||||||
case 0:
|
case 0:
|
||||||
// servo_direction(1);
|
// servo_direction(1);
|
||||||
SetShutter(2);
|
// SetShutter(2);
|
||||||
|
shutter_up();
|
||||||
break;
|
break;
|
||||||
case 1:
|
case 1:
|
||||||
// servo_direction(0);
|
// servo_direction(0);
|
||||||
SetShutter(2);
|
// SetShutter(2);
|
||||||
|
shutter_down();
|
||||||
break;
|
break;
|
||||||
case 2:
|
case 2:
|
||||||
SetShutter(1);
|
// SetShutter(1);
|
||||||
|
shutter_off();
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
@ -1214,7 +1675,7 @@ void SensorIS11::opt(u_int32_t direction)
|
|||||||
work_progress = 50;
|
work_progress = 50;
|
||||||
dingbiao_shutter = OptSnenser(70);
|
dingbiao_shutter = OptSnenser(70);
|
||||||
work_progress = 100;
|
work_progress = 100;
|
||||||
SetShutter(1);
|
// SetShutter(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@ -22,6 +22,21 @@ extern struct IS11_datastruct IS11_datastruct_down;
|
|||||||
extern struct IS11_datastruct IS11_datastruct_dark_up;
|
extern struct IS11_datastruct IS11_datastruct_dark_up;
|
||||||
extern struct IS11_datastruct IS11_datastruct_dark_down;
|
extern struct IS11_datastruct IS11_datastruct_dark_down;
|
||||||
|
|
||||||
|
struct bochang_struct {
|
||||||
|
bool is_valid;
|
||||||
|
|
||||||
|
double a0;
|
||||||
|
double a1;
|
||||||
|
double a2;
|
||||||
|
double a3;
|
||||||
|
|
||||||
|
double b0;
|
||||||
|
double b1;
|
||||||
|
double b2;
|
||||||
|
double b3;
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
class SensorIS11 {
|
class SensorIS11 {
|
||||||
public:
|
public:
|
||||||
SensorIS11();
|
SensorIS11();
|
||||||
@ -79,7 +94,8 @@ public:
|
|||||||
|
|
||||||
u_char *DataRetrun;
|
u_char *DataRetrun;
|
||||||
|
|
||||||
|
bochang_struct guangpu_bochang;
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@ -11,7 +11,7 @@ struct STRSensorInfo
|
|||||||
//double *wavelenth;
|
//double *wavelenth;
|
||||||
bool isSensorInit;
|
bool isSensorInit;
|
||||||
String serialnumber;
|
String serialnumber;
|
||||||
float a1,a2,a3,a4;
|
double a1,a2,a3,a4;
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@ -6,34 +6,40 @@ GSMMannger *gsmmanger;
|
|||||||
PubSubClient *mqtt_client; // 修改为指针类型,避免使用未初始化的对象
|
PubSubClient *mqtt_client; // 修改为指针类型,避免使用未初始化的对象
|
||||||
const char* mqtt_server = "tower.iris-rs.cn"; // 可替换为你自己的Broker地址
|
const char* mqtt_server = "tower.iris-rs.cn"; // 可替换为你自己的Broker地址
|
||||||
const uint32_t mqtt_port = 40000;
|
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/command
|
||||||
// SpectraSenorV2/return
|
// SpectraSenorV2/return
|
||||||
String str_publish_topic ="SpectraSenorV2/command/";
|
String str_mqtt_client_id = "";
|
||||||
String str_subscribe_topic = "SpectraSenorV2/return/";
|
String str_publish_topic ="SpectraSenorV2/return/";
|
||||||
EventGroupHandle_t http_event_group;
|
String str_subscribe_topic = "SpectraSenorV2/command/";
|
||||||
|
EventGroupHandle_t http_event_group;
|
||||||
|
|
||||||
void callback(char* topic, byte* payload, unsigned int length) {
|
void callback(char* topic, byte* payload, unsigned int length) {
|
||||||
// Serial0.print("Message arrived on topic: ");
|
// Serial.print("Message arrived on topic: ");
|
||||||
// Serial0.print(topic);
|
// Serial.print(topic);
|
||||||
// Serial0.print(". Message: ");
|
// Serial.print("\nMessage: ");
|
||||||
// for (int i = 0; i < length; i++) {
|
// for (int i = 0; i < length; i++) {
|
||||||
// Serial0.print((char)payload[i]);
|
// Serial.print((char)payload[i]);
|
||||||
// }
|
// }
|
||||||
// Serial0.println();
|
// Serial.println();
|
||||||
|
|
||||||
|
|
||||||
uint8_t read_buff[1024 * 10];
|
uint8_t read_buff[1024 * 10];
|
||||||
memcpy(read_buff,payload,length);
|
memcpy(read_buff,payload,length);
|
||||||
uint32_t data_length = length;
|
uint32_t data_length = length;
|
||||||
data_length = IRIS_Cut_Befor_Header(read_buff,data_length);
|
data_length = IRIS_Cut_Befor_Header(read_buff,data_length);
|
||||||
|
|
||||||
if (data_length > 0)
|
if (data_length > 0)
|
||||||
{
|
{
|
||||||
receive_command_unpack(read_buff,length,2);
|
receive_command_unpack(read_buff,length,2);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// mqtt_write(read_buff,length);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void reconnect() {
|
void reconnect() {
|
||||||
@ -42,17 +48,17 @@ void reconnect() {
|
|||||||
// 重新连接MQTT
|
// 重新连接MQTT
|
||||||
while (!mqtt_client->connected())
|
while (!mqtt_client->connected())
|
||||||
{
|
{
|
||||||
// Serial0.print("Attempting MQTT connection...");
|
// Serial.print("Attempting MQTT connection...");
|
||||||
vTaskDelay(10);
|
vTaskDelay(10);
|
||||||
if (mqtt_client->connect(mqtt_client_id))
|
if (mqtt_client->connect(str_mqtt_client_id.c_str()))
|
||||||
{
|
{
|
||||||
// Serial0.println("connected");
|
// Serial.println("connected");
|
||||||
mqtt_client->subscribe(subscribe_topic);
|
mqtt_client->subscribe(subscribe_topic);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
// Serial0.print("failed, rc=");
|
// Serial.print("failed, rc=");
|
||||||
// Serial0.print(mqtt_client->state());
|
// Serial.print(mqtt_client->state());
|
||||||
}
|
}
|
||||||
// vTaskDelay(100);
|
// vTaskDelay(100);
|
||||||
}
|
}
|
||||||
@ -62,9 +68,7 @@ void gsmm_mqtt_loop_task(void *pvParameters)
|
|||||||
{
|
{
|
||||||
while (1)
|
while (1)
|
||||||
{
|
{
|
||||||
if (!mqtt_client->connected()) {
|
|
||||||
reconnect();
|
|
||||||
}
|
|
||||||
|
|
||||||
EventBits_t uxBits = xEventGroupGetBits(http_event_group);
|
EventBits_t uxBits = xEventGroupGetBits(http_event_group);
|
||||||
if (uxBits & mqtt_stop_bit)
|
if (uxBits & mqtt_stop_bit)
|
||||||
@ -75,6 +79,9 @@ void gsmm_mqtt_loop_task(void *pvParameters)
|
|||||||
xEventGroupClearBits(http_event_group, mqtt_stop_bit);
|
xEventGroupClearBits(http_event_group, mqtt_stop_bit);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!mqtt_client->connected()) {
|
||||||
|
reconnect();
|
||||||
|
}
|
||||||
mqtt_client->loop();
|
mqtt_client->loop();
|
||||||
gsmmanger->loop();
|
gsmmanger->loop();
|
||||||
|
|
||||||
@ -97,15 +104,22 @@ UpDateClassByme ggp_UpDate(http);
|
|||||||
// String str_subscribe_topic = "SpectraSenorV2/return/";
|
// String str_subscribe_topic = "SpectraSenorV2/return/";
|
||||||
void gsmm_mqtt_init(String sensor_id)
|
void gsmm_mqtt_init(String sensor_id)
|
||||||
{
|
{
|
||||||
|
str_mqtt_client_id = sensor_id;
|
||||||
str_publish_topic = str_publish_topic + sensor_id;
|
str_publish_topic = str_publish_topic + sensor_id;
|
||||||
str_subscribe_topic = str_subscribe_topic + sensor_id;
|
str_subscribe_topic = str_subscribe_topic + sensor_id;
|
||||||
|
|
||||||
|
Serial.println("gsmm_mqtt_init");
|
||||||
|
Serial.println("mqtt_client_id: " + str_mqtt_client_id);
|
||||||
|
Serial.println("publish_topic: " + str_publish_topic);
|
||||||
|
Serial.println("subscribe_topic: " + str_subscribe_topic);
|
||||||
http_event_group = xEventGroupCreate();
|
http_event_group = xEventGroupCreate();
|
||||||
// if(http_event_group == NULL)
|
// if(http_event_group == NULL)
|
||||||
// {
|
// {
|
||||||
// Serial0.println("Failed to create event group");
|
// //Serial.println("Failed to create event group");
|
||||||
// }
|
// }
|
||||||
gsmmanger = new GSMMannger(SIMUARTNUMER, SIMUART_RX, SIMUART_TX);
|
gsmmanger = new GSMMannger(SIMUARTNUMER, SIMUART_RX, SIMUART_TX);
|
||||||
mqtt_client = new PubSubClient(*gsmmanger->client); // 初始化 PubSubClient;
|
mqtt_client = new PubSubClient(*gsmmanger->client); // 初始化 PubSubClient;
|
||||||
|
mqtt_client->setBufferSize(1024);
|
||||||
mqtt_client->setServer(mqtt_server, mqtt_port);
|
mqtt_client->setServer(mqtt_server, mqtt_port);
|
||||||
mqtt_client->setCallback(callback);
|
mqtt_client->setCallback(callback);
|
||||||
|
|
||||||
@ -119,12 +133,22 @@ void mqtt_write(uint8_t *data , uint32_t lenth)
|
|||||||
{
|
{
|
||||||
const char *publish_topic = str_publish_topic.c_str();
|
const char *publish_topic = str_publish_topic.c_str();
|
||||||
bool messageSent = false;
|
bool messageSent = false;
|
||||||
// String str_publish_topic =publish_topic + '/' + ;
|
|
||||||
do
|
uint32_t cout = 5000;
|
||||||
|
while (cout --)
|
||||||
{
|
{
|
||||||
|
if(mqtt_client->connected())
|
||||||
|
{
|
||||||
messageSent = mqtt_client->publish(publish_topic,data,lenth);
|
messageSent = mqtt_client->publish(publish_topic,data,lenth);
|
||||||
if(!messageSent) vTaskDelay(1);
|
}
|
||||||
} while (!messageSent);
|
if(messageSent)
|
||||||
|
{
|
||||||
|
write_log(log_path,"mqtt send message successfully",10);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
vTaskDelay(1);
|
||||||
|
}
|
||||||
|
write_log(log_path,"mqtt send message failed",10);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool UpdateData(String path,uint8_t *data, size_t lenth, String Contenttype )
|
bool UpdateData(String path,uint8_t *data, size_t lenth, String Contenttype )
|
||||||
@ -149,6 +173,7 @@ bool UpdateData(String path,uint8_t *data, size_t lenth, String Contenttype )
|
|||||||
http->sendHeader(HTTP_HEADER_CONTENT_LENGTH, lenth);
|
http->sendHeader(HTTP_HEADER_CONTENT_LENGTH, lenth);
|
||||||
http->endRequest();
|
http->endRequest();
|
||||||
int err = http->write((const byte *)data, lenth);
|
int err = http->write((const byte *)data, lenth);
|
||||||
|
// int err = 0;
|
||||||
uint32_t len = lenth;
|
uint32_t len = lenth;
|
||||||
while(len)
|
while(len)
|
||||||
{
|
{
|
||||||
@ -167,14 +192,14 @@ bool UpdateData(String path,uint8_t *data, size_t lenth, String Contenttype )
|
|||||||
|
|
||||||
|
|
||||||
vTaskDelay(1000*5);
|
vTaskDelay(1000*5);
|
||||||
Serial0.print("send date size");
|
//Serial.print("send date size");
|
||||||
Serial0.println(err);
|
//Serial.println(err);
|
||||||
|
|
||||||
|
|
||||||
int status = http->responseStatusCode();
|
int status = http->responseStatusCode();
|
||||||
int length = http->contentLength();
|
int length = http->contentLength();
|
||||||
String body = http->responseBody();
|
String body = http->responseBody();
|
||||||
Serial0.println("body:"+body);
|
//Serial.println("body:"+body);
|
||||||
|
|
||||||
http->stop();
|
http->stop();
|
||||||
|
|
||||||
@ -244,6 +269,65 @@ String getnetData()
|
|||||||
xEventGroupSetBits(http_event_group, Http_stop_bit);
|
xEventGroupSetBits(http_event_group, Http_stop_bit);
|
||||||
return body;
|
return body;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
double convertDMSToDecimal(String dms) {
|
||||||
|
if (dms.length() < 2) return 0;
|
||||||
|
double val = dms.substring(0, dms.length() - 1).toDouble();
|
||||||
|
char dir = dms.charAt(dms.length() - 1);
|
||||||
|
|
||||||
|
int degrees = int(val / 100);
|
||||||
|
double minutes = val - degrees * 100;
|
||||||
|
double decimal = degrees + minutes / 60.0;
|
||||||
|
|
||||||
|
if (dir == 'S' || dir == 'W') decimal = -decimal;
|
||||||
|
return decimal;
|
||||||
|
}
|
||||||
|
|
||||||
|
gps_struct parseQGPSLOCFull(String gpsStr) {
|
||||||
|
gps_struct data;
|
||||||
|
|
||||||
|
// 1. 提取UTC时间
|
||||||
|
int idx1 = gpsStr.indexOf(":") + 2;
|
||||||
|
int idx2 = gpsStr.indexOf(",", idx1);
|
||||||
|
String timeStr = gpsStr.substring(idx1, idx2);
|
||||||
|
|
||||||
|
if (timeStr.length() >= 6) {
|
||||||
|
data.hour = timeStr.substring(0, 2).toInt();
|
||||||
|
data.minute = timeStr.substring(2, 4).toInt();
|
||||||
|
data.second = timeStr.substring(4, 6).toInt();
|
||||||
|
} else {
|
||||||
|
data.hour = data.minute = data.second = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
// 2. 提取纬度
|
||||||
|
int idx3 = idx2 + 1;
|
||||||
|
int idx4 = gpsStr.indexOf(",", idx3);
|
||||||
|
String latStr = gpsStr.substring(idx3, idx4);
|
||||||
|
|
||||||
|
// 3. 提取经度
|
||||||
|
int idx5 = idx4 + 1;
|
||||||
|
int idx6 = gpsStr.indexOf(",", idx5);
|
||||||
|
String lonStr = gpsStr.substring(idx5, idx6);
|
||||||
|
|
||||||
|
data.latitude = convertDMSToDecimal(latStr);
|
||||||
|
data.longitude = convertDMSToDecimal(lonStr);
|
||||||
|
|
||||||
|
// 4. 提取日期
|
||||||
|
int lastComma = gpsStr.lastIndexOf(",");
|
||||||
|
String dateStr = gpsStr.substring(lastComma - 6, lastComma); // 假设日期是6位 YYMMDD
|
||||||
|
|
||||||
|
if (dateStr.length() == 6) {
|
||||||
|
data.year = 2000 + dateStr.substring(0, 2).toInt(); // 转成4位年
|
||||||
|
data.month = dateStr.substring(2, 4).toInt();
|
||||||
|
data.day = dateStr.substring(4, 6).toInt();
|
||||||
|
} else {
|
||||||
|
data.year = data.month = data.day = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
return data;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
String get_GPS(gps_struct *gps_info)
|
String get_GPS(gps_struct *gps_info)
|
||||||
{
|
{
|
||||||
EventBits_t uxBits = xEventGroupGetBits(http_event_group);
|
EventBits_t uxBits = xEventGroupGetBits(http_event_group);
|
||||||
@ -268,30 +352,34 @@ String get_GPS(gps_struct *gps_info)
|
|||||||
|
|
||||||
xEventGroupSetBits(http_event_group, Http_stop_bit);
|
xEventGroupSetBits(http_event_group, Http_stop_bit);
|
||||||
|
|
||||||
if(gpsbac.indexOf("+QGPSLOC:") != -1)
|
if(gpsbac.indexOf("+QGPSLOC:") == -1)
|
||||||
{
|
{
|
||||||
return "-1";
|
return "-1";
|
||||||
}
|
}
|
||||||
|
|
||||||
const char* gps_data = gpsbac.c_str();
|
// // // +QGPSLOC: 071119.00,3905.2108N,11706.7802E,3.43,-11.6,3,,0.993,0.536,220426,06
|
||||||
// 提取时间 (063416.40 -> 06:34:16.40)
|
// const char* gps_data = gpsbac.c_str();
|
||||||
sscanf(gps_data, "%2hhd%2hhd%2hhd", &gps_info->hour, &gps_info->minute, &gps_info->second);
|
// // 提取时间 (063416.40 -> 06:34:16.40)
|
||||||
|
// sscanf(gps_data, "%2hhd%2hhd%2hhd", &gps_info->hour, &gps_info->minute, &gps_info->second);
|
||||||
|
|
||||||
// 提取日期 (110620 -> 2020-11-06)
|
// // 提取日期 (110620 -> 2020-11-06)
|
||||||
sscanf(gps_data + 36, "%2hd%2hhd%2hhd", &gps_info->year, &gps_info->month, &gps_info->day);
|
// sscanf(gps_data + 36, "%2hd%2hhd%2hhd", &gps_info->year, &gps_info->month, &gps_info->day);
|
||||||
|
|
||||||
// 提取纬度 (3143.2951N -> 31.721585)
|
// // 提取纬度 (3143.2951N -> 31.721585)
|
||||||
int lat_deg = gps_data[8] - '0'; // 获取纬度的度数 31
|
// int lat_deg = gps_data[8] - '0'; // 获取纬度的度数 31
|
||||||
int lat_min = gps_data[9] - '0'; // 获取纬度的分钟数 43
|
// int lat_min = gps_data[9] - '0'; // 获取纬度的分钟数 43
|
||||||
float lat_min_decimal = atof(&gps_data[10]); // 获取纬度的小数部分 2951
|
// float lat_min_decimal = atof(&gps_data[10]); // 获取纬度的小数部分 2951
|
||||||
gps_info->latitude = lat_deg + (lat_min + lat_min_decimal / 10000) / 60.0;
|
// gps_info->latitude = lat_deg + (lat_min + lat_min_decimal / 10000) / 60.0;
|
||||||
|
|
||||||
// 提取经度 (11713.0655E -> 117.217758)
|
// // 提取经度 (11713.0655E -> 117.217758)
|
||||||
int lon_deg = gps_data[14] - '0'; // 获取经度的度数 117
|
// int lon_deg = gps_data[14] - '0'; // 获取经度的度数 117
|
||||||
int lon_min = gps_data[15] - '0'; // 获取经度的分钟数 13
|
// int lon_min = gps_data[15] - '0'; // 获取经度的分钟数 13
|
||||||
float lon_min_decimal = atof(&gps_data[16]); // 获取经度的小数部分 0655
|
// float lon_min_decimal = atof(&gps_data[16]); // 获取经度的小数部分 0655
|
||||||
gps_info->longitude = lon_deg + (lon_min + lon_min_decimal / 10000) / 60.0;
|
// gps_info->longitude = lon_deg + (lon_min + lon_min_decimal / 10000) / 60.0;
|
||||||
|
|
||||||
|
|
||||||
|
// parse_gps(gpsbac.c_str(),gps_info);
|
||||||
|
*gps_info = parseQGPSLOCFull(gpsbac);
|
||||||
return gpsbac;
|
return gpsbac;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -299,38 +387,38 @@ void Update_firmware(Stream &updateSource, size_t updateSize)
|
|||||||
{
|
{
|
||||||
if (Update.begin(updateSize))
|
if (Update.begin(updateSize))
|
||||||
{
|
{
|
||||||
Serial0.println("Writes : ");
|
//Serial.println("Writes : ");
|
||||||
size_t written = Update.writeStream(updateSource);
|
size_t written = Update.writeStream(updateSource);
|
||||||
if (written == updateSize)
|
if (written == updateSize)
|
||||||
{
|
{
|
||||||
Serial0.println("Writes : " + String(written) + " successfully");
|
//Serial.println("Writes : " + String(written) + " successfully");
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
Serial0.println("Written only : " + String(written) + "/" + String(updateSize) + ". Retry?");
|
//Serial.println("Written only : " + String(written) + "/" + String(updateSize) + ". Retry?");
|
||||||
}
|
}
|
||||||
|
|
||||||
if (Update.end())
|
if (Update.end())
|
||||||
{
|
{
|
||||||
Serial0.println("OTA finished!");
|
//Serial.println("OTA finished!");
|
||||||
if (Update.isFinished())
|
if (Update.isFinished())
|
||||||
{
|
{
|
||||||
Serial0.println("Restart ESP device!");
|
//Serial.println("Restart ESP device!");
|
||||||
abort();
|
abort();
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
Serial0.println("OTA not fiished");
|
//Serial.println("OTA not fiished");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
Serial0.println("Error occured #: " + String(Update.getError()));
|
//Serial.println("Error occured #: " + String(Update.getError()));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
Serial0.println("Cannot beggin update");
|
//Serial.println("Cannot beggin update");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
size_t http_download(String url)
|
size_t http_download(String url)
|
||||||
@ -339,7 +427,7 @@ size_t http_download(String url)
|
|||||||
int err = http->get(url.c_str());
|
int err = http->get(url.c_str());
|
||||||
if (err != 0)
|
if (err != 0)
|
||||||
{
|
{
|
||||||
Serial0.println(F("Date failed to connect"));
|
//Serial.println(F("Date failed to connect"));
|
||||||
vTaskDelay(10000);
|
vTaskDelay(10000);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
@ -349,25 +437,25 @@ size_t http_download(String url)
|
|||||||
vTaskDelay(10000);
|
vTaskDelay(10000);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
Serial0.print(F("Response status code: "));
|
//Serial.print(F("Response status code: "));
|
||||||
Serial0.println(status);
|
//Serial.println(status);
|
||||||
// Serial0Mon.println(F("Response Headers:"));
|
// Serial0Mon.println(F("Response Headers:"));
|
||||||
size_t count=0;
|
size_t count=0;
|
||||||
while (http->headerAvailable())
|
while (http->headerAvailable())
|
||||||
{
|
{
|
||||||
String headerName = http->readHeaderName();
|
String headerName = http->readHeaderName();
|
||||||
String headerValue = http->readHeaderValue();
|
String headerValue = http->readHeaderValue();
|
||||||
Serial0.println("Date: " + headerName + " : " + headerValue);
|
//Serial.println("Date: " + headerName + " : " + headerValue);
|
||||||
if (headerName=="Content-Length")
|
if (headerName=="Content-Length")
|
||||||
{
|
{
|
||||||
count=headerValue.toInt();
|
count=headerValue.toInt();
|
||||||
/* code */
|
/* code */
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Serial0.println("lenth is "+String(count));
|
//Serial.println("lenth is "+String(count));
|
||||||
if (http->isResponseChunked())
|
if (http->isResponseChunked())
|
||||||
{
|
{
|
||||||
Serial0.println(F("Date The response is chunked"));
|
//Serial.println(F("Date The response is chunked"));
|
||||||
}
|
}
|
||||||
char *str=new char[1000];
|
char *str=new char[1000];
|
||||||
int lent=count/1000;
|
int lent=count/1000;
|
||||||
@ -379,8 +467,8 @@ size_t http_download(String url)
|
|||||||
{
|
{
|
||||||
http->readBytes(str,1000);
|
http->readBytes(str,1000);
|
||||||
file.write((const byte *)str,1000);
|
file.write((const byte *)str,1000);
|
||||||
Serial0.print("download ");
|
//Serial.print("download ");
|
||||||
Serial0.println(String(i*100/lent));
|
//Serial.println(String(i*100/lent));
|
||||||
/* code */
|
/* code */
|
||||||
}
|
}
|
||||||
http->readBytes(str,count%1000);
|
http->readBytes(str,count%1000);
|
||||||
@ -404,8 +492,8 @@ bool check_file_ota(String MD5)
|
|||||||
md5my.addStream(file,countdownload1);
|
md5my.addStream(file,countdownload1);
|
||||||
md5my.calculate();
|
md5my.calculate();
|
||||||
String md5com=md5my.toString();
|
String md5com=md5my.toString();
|
||||||
Serial0.println("md5 comput is:"+md5my.toString());
|
//Serial.println("md5 comput is:"+md5my.toString());
|
||||||
Serial0.println("md5 should is:"+MD5);
|
//Serial.println("md5 should is:"+MD5);
|
||||||
file.close();
|
file.close();
|
||||||
if (MD5 == md5com)
|
if (MD5 == md5com)
|
||||||
{
|
{
|
||||||
@ -416,7 +504,7 @@ bool check_file_ota(String MD5)
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
Serial0.println("md5 error");
|
//Serial.println("md5 error");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
25
src/log.cpp
25
src/log.cpp
@ -39,34 +39,43 @@ ab+ 读写打开一个二进制文件,允许读或在文件末追加数据。
|
|||||||
#else
|
#else
|
||||||
SoftwareSerial U0_Serial(19,20,false);
|
SoftwareSerial U0_Serial(19,20,false);
|
||||||
#endif
|
#endif
|
||||||
|
volatile bool log_running = true;
|
||||||
|
|
||||||
|
|
||||||
void log_init()
|
void log_init()
|
||||||
{
|
{
|
||||||
// U0_Serial.begin(115200);
|
// U0_Serial.begin(115200);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// void log_stop()
|
||||||
|
// {
|
||||||
|
// // U0_Serial.end();
|
||||||
|
// log_running = false;
|
||||||
|
// }
|
||||||
void write_log(String path,String write_data,unsigned char level)
|
void write_log(String path,String write_data,unsigned char level)
|
||||||
{
|
{
|
||||||
if(level <5) {
|
|
||||||
U0_Serial.println(write_data);
|
if(level <50) {
|
||||||
// Serial0.println(write_data);
|
// U0_Serial.println(write_data);
|
||||||
|
// if(log_running)
|
||||||
|
Serial.println(write_data);
|
||||||
}
|
}
|
||||||
if (level == 20)
|
if (level == 20)
|
||||||
{
|
{
|
||||||
// U0_Serial.println(write_data);
|
// U0_Serial.println(write_data);
|
||||||
|
|
||||||
File file;
|
File file;
|
||||||
file = SD_MMC.open(path,"ab+");
|
file = SD_MMC.open(path,FILE_APPEND);
|
||||||
file.println(write_data);
|
file.println(write_data);
|
||||||
file.flush();
|
file.flush();
|
||||||
file.close();
|
file.close();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void write_log(uint8_t *data,uint32_t size)
|
// void write_log(uint8_t *data,uint32_t size)
|
||||||
{
|
// {
|
||||||
// U0_Serial.write(data,size);
|
// // U0_Serial.write(data,size);
|
||||||
}
|
// }
|
||||||
|
|
||||||
void save_data(String path,String write_data)
|
void save_data(String path,String write_data)
|
||||||
{
|
{
|
||||||
|
|||||||
@ -18,9 +18,10 @@
|
|||||||
|
|
||||||
|
|
||||||
void log_init();
|
void log_init();
|
||||||
|
// void log_stop();
|
||||||
void write_log(String path,String write_data,unsigned char level);
|
void write_log(String path,String write_data,unsigned char level);
|
||||||
void save_data(String path,String write_data);
|
void save_data(String path,String write_data);
|
||||||
void write_log(uint8_t *data,uint32_t size);
|
// void write_log(uint8_t *data,uint32_t size);
|
||||||
// void my_println(String data,int level);
|
// void my_println(String data,int level);
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
480
src/main.cpp
480
src/main.cpp
@ -26,6 +26,9 @@ void Task2(void *pvParameters);
|
|||||||
任务名:task_4G_mode
|
任务名:task_4G_mode
|
||||||
任务功能:4G模式
|
任务功能:4G模式
|
||||||
*/
|
*/
|
||||||
|
TaskHandle_t A4G_Handler;
|
||||||
|
TaskHandle_t OTA_Handler;
|
||||||
|
|
||||||
void task_4G_mode(void *pvParameters);
|
void task_4G_mode(void *pvParameters);
|
||||||
void OTA_task(void *pvParameters);
|
void OTA_task(void *pvParameters);
|
||||||
//work_mode 0:手动 1:时间模式 time_mode 2:高级模式 advanced_mode 3:low_power_mode 4:4G_mode
|
//work_mode 0:手动 1:时间模式 time_mode 2:高级模式 advanced_mode 3:low_power_mode 4:4G_mode
|
||||||
@ -38,7 +41,9 @@ void OTA_task(void *pvParameters);
|
|||||||
//dingbiao_time 0自动曝光 非0使用这个时长曝光
|
//dingbiao_time 0自动曝光 非0使用这个时长曝光
|
||||||
//caiji_mode 0;停止 1:单次 2:连续 3:定标 4:高级模式 5:回传数据 6:低功耗模式
|
//caiji_mode 0;停止 1:单次 2:连续 3:定标 4:高级模式 5:回传数据 6:低功耗模式
|
||||||
volatile u_int32_t work_mode = 0,caiji_mode = 0,return_mode = 1,atuo_return = 0,return_data_type = 0x00,time_interval = 60 * 2,caiji_state = 0 ,fengbao_num=0;
|
volatile u_int32_t work_mode = 0,caiji_mode = 0,return_mode = 1,atuo_return = 0,return_data_type = 0x00,time_interval = 60 * 2,caiji_state = 0 ,fengbao_num=0;
|
||||||
volatile float start_time = 1.0,stop_time = 20.30,maximum_temperature = 10,Minimum_temperature = 0,bc_b1,bc_b2,bc_b3,bc_b4,sun_latitude,sun_longitude;
|
// volatile float start_time = 1.0,stop_time = 20.30,maximum_temperature = 10,Minimum_temperature = 0,bc_b1,bc_b2,bc_b3,bc_b4,sun_latitude,sun_longitude;
|
||||||
|
volatile float start_time = 1.0,stop_time = 20.30,maximum_temperature = 10,Minimum_temperature = 0,sun_latitude,sun_longitude;
|
||||||
|
|
||||||
volatile float calculation_bochang1,calculation_bochang2;
|
volatile float calculation_bochang1,calculation_bochang2;
|
||||||
// volatile u_int32_t http_flag = 0;
|
// volatile u_int32_t http_flag = 0;
|
||||||
|
|
||||||
@ -157,8 +162,8 @@ bool UpdateData(String path,uint8_t *data, size_t lenth, String Contenttype = ""
|
|||||||
|
|
||||||
void setup()
|
void setup()
|
||||||
{
|
{
|
||||||
sun_latitude = 39.6;
|
sun_latitude = 39.0864;
|
||||||
sun_longitude = 116.3;
|
sun_longitude = 117.113055;
|
||||||
// Serial2.begin(115200, SERIAL_8N1, SIMUART_RX, SIMUART_TX);
|
// Serial2.begin(115200, SERIAL_8N1, SIMUART_RX, SIMUART_TX);
|
||||||
//关闭光谱仪
|
//关闭光谱仪
|
||||||
pinMode(36,OUTPUT);
|
pinMode(36,OUTPUT);
|
||||||
@ -169,12 +174,8 @@ void setup()
|
|||||||
vTaskDelay(1000);
|
vTaskDelay(1000);
|
||||||
|
|
||||||
Serial0.begin(115200);
|
Serial0.begin(115200);
|
||||||
|
Serial.begin(115200);
|
||||||
|
|
||||||
// while (1)
|
|
||||||
// {
|
|
||||||
// Serial0.println("66666666666666666666666");
|
|
||||||
// vTaskDelay(1000);
|
|
||||||
// }
|
|
||||||
|
|
||||||
log_init();
|
log_init();
|
||||||
|
|
||||||
@ -185,9 +186,9 @@ void setup()
|
|||||||
//初始化SD卡
|
//初始化SD卡
|
||||||
sdcard::init_sdcard();
|
sdcard::init_sdcard();
|
||||||
sdcard::testwriet();
|
sdcard::testwriet();
|
||||||
sdcard::Mkdir("/guangpu_data");
|
sdcard::Mkdir("/data");
|
||||||
sdcard::Mkdir("/log");
|
sdcard::Mkdir("/log");
|
||||||
sdcard::Mkdir("/dingbiao");
|
sdcard::Mkdir("/calfiles");
|
||||||
sdcard::Mkdir("/system");
|
sdcard::Mkdir("/system");
|
||||||
|
|
||||||
|
|
||||||
@ -230,13 +231,22 @@ void setup()
|
|||||||
rtc.init();
|
rtc.init();
|
||||||
|
|
||||||
String time = String(now.year)+String(now.month)+String(now.day)+String(now.hour)+String(now.minute)+String(now.second);
|
String time = String(now.year)+String(now.month)+String(now.day)+String(now.hour)+String(now.minute)+String(now.second);
|
||||||
|
write_log(log_path," ",20);
|
||||||
|
write_log(log_path,"===============================================================",20);
|
||||||
write_log(log_path,time,20);
|
write_log(log_path,time,20);
|
||||||
write_log(log_path,"system start",20);
|
write_log(log_path,"system start",20);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
//初始化74hc595
|
//初始化74hc595
|
||||||
my74hc595_init();
|
my74hc595_init();
|
||||||
|
// while(1)
|
||||||
|
// {
|
||||||
|
// // shutter_off();
|
||||||
|
// shutter_on();
|
||||||
|
// vTaskDelay(1000 * 5);
|
||||||
|
// }
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@ -247,16 +257,23 @@ void setup()
|
|||||||
InitFunction(serialwrite,serialread);
|
InitFunction(serialwrite,serialread);
|
||||||
is11Sensor = new SensorIS11();
|
is11Sensor = new SensorIS11();
|
||||||
STRSensorInfos_structure = is11Sensor->initSensor();
|
STRSensorInfos_structure = is11Sensor->initSensor();
|
||||||
Serial0.println("IS_SN :" +STRSensorInfos_structure.serialnumber);
|
//Serial.println("IS_SN :" +STRSensorInfos_structure.serialnumber);
|
||||||
|
|
||||||
|
// is11Sensor->guangpu_bochang.a1 = 0.000000000000000;
|
||||||
|
// is11Sensor->guangpu_bochang.a2 = 0.000000000;
|
||||||
|
|
||||||
sys_info_init();
|
sys_info_init();
|
||||||
|
|
||||||
dingbiao_init("/dingbiao/dingbiao_up_gain.bin");
|
// dingbiao_init("/dingbiao/dingbiao_up_gain.bin");
|
||||||
dingbiao_init("/dingbiao/dingbiao_up_offset.bin");
|
// dingbiao_init("/dingbiao/dingbiao_up_offset.bin");
|
||||||
dingbiao_init("/dingbiao/dingbiao_down_gain.bin");
|
// dingbiao_init("/dingbiao/dingbiao_down_gain.bin");
|
||||||
dingbiao_init("/dingbiao/dingbiao_down_offset.bin");
|
// dingbiao_init("/dingbiao/dingbiao_down_offset.bin");
|
||||||
dingbiao_init("/dingbiao/fanshelv_gain.bin");
|
// dingbiao_init("/dingbiao/fanshelv_gain.bin");
|
||||||
|
dingbiao_init("/calfiles/upgain.bin");
|
||||||
|
dingbiao_init("/calfiles/upoffset.bin");
|
||||||
|
dingbiao_init("/calfiles/downgain.bin");
|
||||||
|
dingbiao_init("/calfiles/downoffset.bin");
|
||||||
|
dingbiao_init("/calfiles/fanshelv_gain.bin");
|
||||||
|
|
||||||
|
|
||||||
// gsmm_mqtt_init();
|
// gsmm_mqtt_init();
|
||||||
@ -276,15 +293,48 @@ void setup()
|
|||||||
|
|
||||||
Main_EventGroup = xEventGroupCreate();
|
Main_EventGroup = xEventGroupCreate();
|
||||||
xMutexInventory = xSemaphoreCreateMutex(); //创建MUTEX
|
xMutexInventory = xSemaphoreCreateMutex(); //创建MUTEX
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
if(is11Sensor->guangpu_bochang.b3 < 100)
|
||||||
|
{
|
||||||
|
// write_log(log_path,"guangpu_bochang.b3 < 100",10);
|
||||||
|
is11Sensor->guangpu_bochang.is_valid = false;
|
||||||
|
is11Sensor->guangpu_bochang.a0 = is11Sensor->SensorInfo.a1;
|
||||||
|
is11Sensor->guangpu_bochang.a1 = is11Sensor->SensorInfo.a2;
|
||||||
|
is11Sensor->guangpu_bochang.a2 = is11Sensor->SensorInfo.a3;
|
||||||
|
is11Sensor->guangpu_bochang.a3 = is11Sensor->SensorInfo.a4;
|
||||||
|
|
||||||
|
is11Sensor->guangpu_bochang.b0 = is11Sensor->SensorInfo.a1;
|
||||||
|
is11Sensor->guangpu_bochang.b1 = is11Sensor->SensorInfo.a2;
|
||||||
|
is11Sensor->guangpu_bochang.b2 = is11Sensor->SensorInfo.a3;
|
||||||
|
is11Sensor->guangpu_bochang.b3 = is11Sensor->SensorInfo.a4;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
// write_log(log_path,"guangpu_bochang.b3 >= 100",10);
|
||||||
|
is11Sensor->guangpu_bochang.is_valid = true;
|
||||||
|
is11Sensor->SensorInfo.a1 = is11Sensor->guangpu_bochang.a0;
|
||||||
|
is11Sensor->SensorInfo.a2 = is11Sensor->guangpu_bochang.a1;
|
||||||
|
is11Sensor->SensorInfo.a3 = is11Sensor->guangpu_bochang.a2;
|
||||||
|
is11Sensor->SensorInfo.a4 = is11Sensor->guangpu_bochang.a3;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
if(sys_sd_doc["status_4g"] == "open_4g")
|
if(sys_sd_doc["status_4g"] == "open_4g")
|
||||||
{
|
{
|
||||||
gsmm_mqtt_init(STRSensorInfos_structure.serialnumber);
|
gsmm_mqtt_init(STRSensorInfos_structure.serialnumber);
|
||||||
|
|
||||||
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(task_4G_mode, "task_4G_mode",1024*23,NULL, 1,&A4G_Handler, 1);
|
||||||
|
xTaskCreatePinnedToCore(OTA_task , "OTA_task",1024*10 ,NULL, 1,&OTA_Handler, 1);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
xTaskCreatePinnedToCore(Task0,"Task0",1024 * 23,NULL,2,&Task0_Handler, 0);
|
||||||
|
}
|
||||||
|
|
||||||
if (xMutexInventory == NULL)
|
if (xMutexInventory == NULL)
|
||||||
{
|
{
|
||||||
|
|
||||||
@ -292,10 +342,12 @@ void setup()
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
//创建并启动Core1的任务 xTaskCreatePinnedToCore
|
//创建并启动Core1的任务 xTaskCreatePinnedToCore
|
||||||
xTaskCreatePinnedToCore(Task0,"Task0",1024 * 10,NULL,2,&Task0_Handler,0);
|
// xTaskCreatePinnedToCore(Task0,"Task0",1024 * 23,NULL,2,&Task0_Handler, 0);
|
||||||
xTaskCreatePinnedToCore(Task1,"Task1",1024 * 5, NULL,1,&Task1_Handler, 0);
|
xTaskCreatePinnedToCore(Task1,"Task1",1024 * 5, NULL,1,&Task1_Handler, 0);
|
||||||
xTaskCreatePinnedToCore(Task2,"Task2",1024 * 30,NULL,5,&Task2_Handler, 1);
|
xTaskCreatePinnedToCore(Task2,"Task2",1024 * 30,NULL,5,&Task2_Handler, 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// write_log(log_path,"setup ok",10);
|
// write_log(log_path,"setup ok",10);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -347,8 +399,9 @@ void Task0(void *pvParameters)
|
|||||||
if(xSemaphoreTake(xMutexInventory, timeOut) == pdPASS)
|
if(xSemaphoreTake(xMutexInventory, timeOut) == pdPASS)
|
||||||
{
|
{
|
||||||
caiji_state = 2;
|
caiji_state = 2;
|
||||||
|
xSemaphoreGive(xMutexInventory);
|
||||||
}
|
}
|
||||||
xSemaphoreGive(xMutexInventory);
|
|
||||||
is11Sensor->TakeOneJob();
|
is11Sensor->TakeOneJob();
|
||||||
if (atuo_return == 1)
|
if (atuo_return == 1)
|
||||||
{
|
{
|
||||||
@ -360,8 +413,9 @@ void Task0(void *pvParameters)
|
|||||||
if(xSemaphoreTake(xMutexInventory, timeOut) == pdPASS)
|
if(xSemaphoreTake(xMutexInventory, timeOut) == pdPASS)
|
||||||
{
|
{
|
||||||
caiji_state = 2;
|
caiji_state = 2;
|
||||||
|
xSemaphoreGive(xMutexInventory);
|
||||||
}
|
}
|
||||||
xSemaphoreGive(xMutexInventory);
|
|
||||||
is11Sensor->TakeOneJob();
|
is11Sensor->TakeOneJob();
|
||||||
if (atuo_return == 1)
|
if (atuo_return == 1)
|
||||||
{
|
{
|
||||||
@ -378,8 +432,9 @@ void Task0(void *pvParameters)
|
|||||||
if(xSemaphoreTake(xMutexInventory, timeOut) == pdPASS)
|
if(xSemaphoreTake(xMutexInventory, timeOut) == pdPASS)
|
||||||
{
|
{
|
||||||
caiji_state = 2;
|
caiji_state = 2;
|
||||||
|
xSemaphoreGive(xMutexInventory);
|
||||||
}
|
}
|
||||||
xSemaphoreGive(xMutexInventory);
|
|
||||||
is11Sensor->advanced_mode(advanced_direction,advanced_shutter_time,advanced_collect_times,advanced_remove_dark);
|
is11Sensor->advanced_mode(advanced_direction,advanced_shutter_time,advanced_collect_times,advanced_remove_dark);
|
||||||
uint_work_task0 = 100;
|
uint_work_task0 = 100;
|
||||||
break;
|
break;
|
||||||
@ -388,8 +443,9 @@ void Task0(void *pvParameters)
|
|||||||
if(xSemaphoreTake(xMutexInventory, timeOut) == pdPASS)
|
if(xSemaphoreTake(xMutexInventory, timeOut) == pdPASS)
|
||||||
{
|
{
|
||||||
caiji_state = 2;
|
caiji_state = 2;
|
||||||
|
xSemaphoreGive(xMutexInventory);
|
||||||
}
|
}
|
||||||
xSemaphoreGive(xMutexInventory);
|
|
||||||
is11Sensor->opt(advanced_direction);
|
is11Sensor->opt(advanced_direction);
|
||||||
uint_work_task0 = 100;
|
uint_work_task0 = 100;
|
||||||
break;
|
break;
|
||||||
@ -398,8 +454,9 @@ void Task0(void *pvParameters)
|
|||||||
if(xSemaphoreTake(xMutexInventory, timeOut) == pdPASS)
|
if(xSemaphoreTake(xMutexInventory, timeOut) == pdPASS)
|
||||||
{
|
{
|
||||||
caiji_state = 2;
|
caiji_state = 2;
|
||||||
|
xSemaphoreGive(xMutexInventory);
|
||||||
}
|
}
|
||||||
xSemaphoreGive(xMutexInventory);
|
|
||||||
|
|
||||||
is11Sensor->calculation(calculation_bochang1,calculation_bochang2);
|
is11Sensor->calculation(calculation_bochang1,calculation_bochang2);
|
||||||
uint_work_task0 = 100;
|
uint_work_task0 = 100;
|
||||||
@ -421,100 +478,7 @@ void Task1(void *pvParameters)
|
|||||||
uint32_t count = 10;
|
uint32_t count = 10;
|
||||||
while(1)
|
while(1)
|
||||||
{
|
{
|
||||||
// vTaskDelay(1000);
|
//Serial.println("Task1 is running");
|
||||||
// //获取时间
|
|
||||||
// rtc.getDateTime(&now);
|
|
||||||
|
|
||||||
// //获取温度
|
|
||||||
// // float temp[8];
|
|
||||||
// // getall_temp(temp);
|
|
||||||
// // //平均温度
|
|
||||||
// // float temp_ave = 0;
|
|
||||||
// // for (size_t i = 0; i < 8; i++)
|
|
||||||
// // {
|
|
||||||
// // temp_ave += temp[i];
|
|
||||||
// // }
|
|
||||||
// // temp_ave = temp_ave / 8;
|
|
||||||
// // write_log(log_path,"temp_ave: " + String(temp_ave),log_level);
|
|
||||||
|
|
||||||
// //获取GPS
|
|
||||||
// gps_struct gps_structure;
|
|
||||||
|
|
||||||
// String gpsbac = get_GPS(&gps_structure);
|
|
||||||
//计算日出日落
|
|
||||||
// double transit, sunrise, sunset;
|
|
||||||
// double utc_offset = 8;
|
|
||||||
// if (gpsbac != "-1")
|
|
||||||
// {
|
|
||||||
// calcSunriseSunset(now.year+2000, now.month, now.day,gps_structure.latitude, gps_structure.longitude, transit, sunrise, sunset);
|
|
||||||
// }
|
|
||||||
// else
|
|
||||||
// {
|
|
||||||
// write_log(log_path,"no gps",10);
|
|
||||||
// }
|
|
||||||
|
|
||||||
// //日出日落控制 太阳升起前推杆缩,太阳落下后推杆伸
|
|
||||||
// write_log(log_path,"now.hour: " + String(now.hour),log_level);
|
|
||||||
// write_log(log_path,"sunrise: " + String((int)sunrise),log_level);
|
|
||||||
// write_log(log_path,"sunset: " + String((int)sunset),log_level);
|
|
||||||
// if (now.hour+1 == (int)sunrise)
|
|
||||||
// {
|
|
||||||
// tuigan(suo);
|
|
||||||
// }
|
|
||||||
// else if (now.hour+1 >= (int)sunset)
|
|
||||||
// {
|
|
||||||
// tuigan(tui);
|
|
||||||
// }
|
|
||||||
|
|
||||||
// if(sys_sd_doc["work_mode"] == "time_mode")
|
|
||||||
// {
|
|
||||||
// float now_time = now.hour + now.minute/100;
|
|
||||||
// if(now_time > start_time && now_time < stop_time)
|
|
||||||
// {
|
|
||||||
|
|
||||||
// }
|
|
||||||
// else
|
|
||||||
// {
|
|
||||||
// if(xSemaphoreTake(xMutexInventory, timeOut) == pdPASS)
|
|
||||||
// {
|
|
||||||
// caiji_mode = 0;
|
|
||||||
// }
|
|
||||||
// xSemaphoreGive(xMutexInventory);
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
|
|
||||||
// write_log(log_path,"temp_ave: " + String(temp_ave),log_level);
|
|
||||||
// if(temp_ave < Minimum_temperature)
|
|
||||||
// {
|
|
||||||
// write_log(log_path,"start jiaresi",10);
|
|
||||||
// jiaresi(5,start_jiare);
|
|
||||||
// vTaskDelay(1000 * 10);
|
|
||||||
// }
|
|
||||||
// else if (temp_ave > Minimum_temperature + 5)
|
|
||||||
// {
|
|
||||||
// write_log(log_path,"stop jiaresi",10);
|
|
||||||
// jiaresi(5,stop_jiare);
|
|
||||||
// }
|
|
||||||
// for(int ab ; ab < 10; ab++)
|
|
||||||
// {
|
|
||||||
|
|
||||||
|
|
||||||
// gps_struct gps_structure;
|
|
||||||
// String gpsbac = get_GPS(&gps_structure);
|
|
||||||
// if(gpsbac == "-1")
|
|
||||||
// {
|
|
||||||
// write_log(log_path,"no gps",10);
|
|
||||||
// }
|
|
||||||
// else
|
|
||||||
// {
|
|
||||||
// sun_latitude = gps_structure.latitude;
|
|
||||||
// sun_longitude = gps_structure.longitude;
|
|
||||||
// }
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
rtc.getDateTime(&now);
|
rtc.getDateTime(&now);
|
||||||
write_log(log_path, String(now.year) +"."+ String(now.month) +"."+ String(now.day)+" "+String(now.hour)+":"+String(now.minute)+":"+String(now.second),20);
|
write_log(log_path, String(now.year) +"."+ String(now.month) +"."+ String(now.day)+" "+String(now.hour)+":"+String(now.minute)+":"+String(now.second),20);
|
||||||
// String path = "/guangpu_data/"+ String(now.year) + "/" + String(now.month) + "/" + String(now.day);
|
// String path = "/guangpu_data/"+ String(now.year) + "/" + String(now.month) + "/" + String(now.day);
|
||||||
@ -536,7 +500,7 @@ void Task1(void *pvParameters)
|
|||||||
String path_b = "/gaugpu_data";
|
String path_b = "/gaugpu_data";
|
||||||
for(int i=24;i<255 ;i++)
|
for(int i=24;i<255 ;i++)
|
||||||
{
|
{
|
||||||
for (uint8_t j = 1; j < 13; i++)
|
for (uint8_t j = 1; j < 13; j++)
|
||||||
{
|
{
|
||||||
String path_a = path_b + "/" +String(i)+ "/" +String(j);
|
String path_a = path_b + "/" +String(i)+ "/" +String(j);
|
||||||
if(SD_MMC.exists(path_a))
|
if(SD_MMC.exists(path_a))
|
||||||
@ -550,26 +514,12 @@ 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("/data/" + String(now.year - 10) ))
|
||||||
{
|
|
||||||
String path = "/guangpu_data/" + String(now.year - 10);
|
|
||||||
rm_dir_or_file(path.c_str());
|
|
||||||
}
|
|
||||||
|
|
||||||
vTaskDelay(1000 * 1);
|
|
||||||
// write_log(log_path,"delete /guangpu_data/0 1111111111",10);
|
|
||||||
|
|
||||||
// if(SD_MMC.exists("/guangpu_data/0"))
|
|
||||||
// {
|
// {
|
||||||
// write_log(log_path,"delete /guangpu_data/0 2222222222222222",10);
|
// String path = "/data/" + String(now.year - 10);
|
||||||
// // sdcard::deleteFolderOrFile("/gaugpu_data/0");
|
// rm_dir_or_file(path.c_str());
|
||||||
// rm_dir_or_file("/guangpu_data/0");
|
|
||||||
// }
|
// }
|
||||||
///////////////////////////////////////////////////////////////////////////////////////////
|
|
||||||
|
|
||||||
//////////////////////////////////////////////时间/////////////////////////////////////////
|
|
||||||
//获取RTC时间
|
|
||||||
rtc.getDateTime(&now);
|
|
||||||
|
|
||||||
#ifdef GPS_4G
|
#ifdef GPS_4G
|
||||||
if(now.day != last_day)
|
if(now.day != last_day)
|
||||||
@ -641,8 +591,9 @@ void Task1(void *pvParameters)
|
|||||||
if(xSemaphoreTake(xMutexInventory, timeOut) == pdPASS)
|
if(xSemaphoreTake(xMutexInventory, timeOut) == pdPASS)
|
||||||
{
|
{
|
||||||
caiji_mode = 0;
|
caiji_mode = 0;
|
||||||
|
xSemaphoreGive(xMutexInventory);
|
||||||
}
|
}
|
||||||
xSemaphoreGive(xMutexInventory);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
vTaskDelay(1000 * 1);
|
vTaskDelay(1000 * 1);
|
||||||
@ -671,8 +622,9 @@ void Task1(void *pvParameters)
|
|||||||
write_log(log_path,"tuisuotime: " + String(tuisuotime),20);
|
write_log(log_path,"tuisuotime: " + String(tuisuotime),20);
|
||||||
write_log(log_path,"sunrise: " + String(sunrise),20);
|
write_log(log_path,"sunrise: " + String(sunrise),20);
|
||||||
write_log(log_path,"sunset: " + String(sunset),20);
|
write_log(log_path,"sunset: " + String(sunset),20);
|
||||||
write_log(log_path,"tui",20);
|
write_log(log_path,"suo",20);
|
||||||
tuigan(tui);
|
// tuigan(tui);
|
||||||
|
tuigan(suo);
|
||||||
jiaresi(6,start_jiare);
|
jiaresi(6,start_jiare);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@ -680,8 +632,9 @@ void Task1(void *pvParameters)
|
|||||||
write_log(log_path,"tuisuotime: " + String(tuisuotime),20);
|
write_log(log_path,"tuisuotime: " + String(tuisuotime),20);
|
||||||
write_log(log_path,"sunrise: " + String(sunrise),20);
|
write_log(log_path,"sunrise: " + String(sunrise),20);
|
||||||
write_log(log_path,"sunset: " + String(sunset),20);
|
write_log(log_path,"sunset: " + String(sunset),20);
|
||||||
write_log(log_path,"suo",20);
|
write_log(log_path,"tui",20);
|
||||||
tuigan(suo);
|
// tuigan(suo);
|
||||||
|
tuigan(tui);
|
||||||
jiaresi(6,stop_jiare);
|
jiaresi(6,stop_jiare);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -692,8 +645,9 @@ void Task1(void *pvParameters)
|
|||||||
write_log(log_path,"tuisuotime: " + String(tuisuotime),20);
|
write_log(log_path,"tuisuotime: " + String(tuisuotime),20);
|
||||||
write_log(log_path,"sunrise: " + String(sunrise),20);
|
write_log(log_path,"sunrise: " + String(sunrise),20);
|
||||||
write_log(log_path,"sunset: " + String(sunset),20);
|
write_log(log_path,"sunset: " + String(sunset),20);
|
||||||
write_log(log_path,"tui",20);
|
write_log(log_path,"suo",20);
|
||||||
tuigan(tui);
|
// tuigan(tui);
|
||||||
|
tuigan(suo);
|
||||||
jiaresi(6,start_jiare);
|
jiaresi(6,start_jiare);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@ -701,32 +655,33 @@ void Task1(void *pvParameters)
|
|||||||
write_log(log_path,"tuisuotime: " + String(tuisuotime),20);
|
write_log(log_path,"tuisuotime: " + String(tuisuotime),20);
|
||||||
write_log(log_path,"sunrise: " + String(sunrise),20);
|
write_log(log_path,"sunrise: " + String(sunrise),20);
|
||||||
write_log(log_path,"sunset: " + String(sunset),20);
|
write_log(log_path,"sunset: " + String(sunset),20);
|
||||||
write_log(log_path,"suo",20);
|
write_log(log_path,"tui",20);
|
||||||
tuigan(suo);
|
// tuigan(suo);
|
||||||
|
tuigan(tui);
|
||||||
jiaresi(6,stop_jiare);
|
jiaresi(6,stop_jiare);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
vTaskDelay(1000 * 1);
|
vTaskDelay(100);
|
||||||
|
|
||||||
|
|
||||||
float temperature[8];
|
float temperature[8];
|
||||||
getall_temp(temperature);
|
getall_temp(temperature);
|
||||||
vTaskDelay(100);
|
// vTaskDelay(100);
|
||||||
getall_temp(temperature);
|
// getall_temp(temperature);
|
||||||
vTaskDelay(100);
|
// vTaskDelay(100);
|
||||||
getall_temp(temperature);
|
// getall_temp(temperature);
|
||||||
for(uint8_t n=0; n<8 ;n++)
|
for(uint8_t n=0; n<8 ;n++)
|
||||||
{
|
{
|
||||||
if(temperature[n] < -120) write_log(log_path,"temperature " + String(n+1) +":" + String(temperature[n])+"This sensor is broken.",20);
|
if(temperature[n] < -120) write_log(log_path,"temperature " + String(n+1) +":" + String(temperature[n])+"This sensor is broken.",20);
|
||||||
if(count == 10)
|
if(count == 10)
|
||||||
{
|
{
|
||||||
write_log(log_path,"temperature " + String(n) +":" + String(temperature[n]),20);
|
write_log(log_path,"temperature " + String(n) +":" + String(temperature[n]),20);
|
||||||
count == 0;
|
count = 0;
|
||||||
}else
|
}else
|
||||||
write_log(log_path,"temperature " + String(n) +":" + String(temperature[n]),10);
|
write_log(log_path,"temperature " + String(n) +":" + String(temperature[n]),10);
|
||||||
}
|
}
|
||||||
|
|
||||||
if(temperature[2] / 2 > maximum_temperature)
|
if(temperature[2] > maximum_temperature)
|
||||||
{
|
{
|
||||||
write_log(log_path,"stop_jiare",20);
|
write_log(log_path,"stop_jiare",20);
|
||||||
jiaresi(7,stop_jiare);
|
jiaresi(7,stop_jiare);
|
||||||
@ -734,7 +689,7 @@ void Task1(void *pvParameters)
|
|||||||
|
|
||||||
if( temperature[2] < Minimum_temperature)
|
if( temperature[2] < Minimum_temperature)
|
||||||
{
|
{
|
||||||
if(temperature[2] < -120)
|
if(temperature[2] < -110)
|
||||||
{
|
{
|
||||||
write_log(log_path,"temperature 2 is broken.",20);
|
write_log(log_path,"temperature 2 is broken.",20);
|
||||||
jiaresi(7,stop_jiare);
|
jiaresi(7,stop_jiare);
|
||||||
@ -765,7 +720,7 @@ void Task1(void *pvParameters)
|
|||||||
// // jiaresi(5,stop_jiare);
|
// // jiaresi(5,stop_jiare);
|
||||||
// }
|
// }
|
||||||
count++;
|
count++;
|
||||||
vTaskDelay(1000 * 60 * 1);
|
vTaskDelay(1000 * 60 );
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
@ -822,10 +777,10 @@ void task_4G_mode(void *pvParameters)
|
|||||||
{
|
{
|
||||||
http_data_head http_head;
|
http_data_head http_head;
|
||||||
uint8_t *data = new u_char[sizeof(IS11_datastruct) + sizeof(http_head)];
|
uint8_t *data = new u_char[sizeof(IS11_datastruct) + sizeof(http_head)];
|
||||||
|
write_log(log_path,"task 4G mode",10);
|
||||||
while (1)
|
while (1)
|
||||||
{
|
{
|
||||||
Serial0.println("task_4G_mode 11");
|
Serial.println("task_4G_mode 11");
|
||||||
// vTaskDelay(1000 * 10);
|
// vTaskDelay(1000 * 10);
|
||||||
bool warn_sta = false;
|
bool warn_sta = false;
|
||||||
float temperature[8];
|
float temperature[8];
|
||||||
@ -845,7 +800,7 @@ void task_4G_mode(void *pvParameters)
|
|||||||
|
|
||||||
}
|
}
|
||||||
float Voltage = adc_read();
|
float Voltage = adc_read();
|
||||||
Serial0.println("Voltage:" + String(Voltage));
|
//Serial.println("Voltage:" + String(Voltage));
|
||||||
if(Voltage < 10)
|
if(Voltage < 10)
|
||||||
{
|
{
|
||||||
warn_sta = true;
|
warn_sta = true;
|
||||||
@ -853,9 +808,10 @@ void task_4G_mode(void *pvParameters)
|
|||||||
doc_4G["Voltage_value"] = Voltage;
|
doc_4G["Voltage_value"] = Voltage;
|
||||||
}
|
}
|
||||||
|
|
||||||
getall_temp(temperature);
|
// getall_temp(temperature);
|
||||||
for(uint8_t n=0; n<8 ;n++)
|
for(uint8_t n=0; n<8 ;n++)
|
||||||
{
|
{
|
||||||
|
temperature[n] = IS11_datastruct_fanshelv.temprature[n];
|
||||||
if((temperature[n] < -10) || (temperature[n] > 50))
|
if((temperature[n] < -10) || (temperature[n] > 50))
|
||||||
{
|
{
|
||||||
warn_sta = true;
|
warn_sta = true;
|
||||||
@ -870,6 +826,7 @@ void task_4G_mode(void *pvParameters)
|
|||||||
doc_4G["temperature 7 : "] = temperature[7];
|
doc_4G["temperature 7 : "] = temperature[7];
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
//Serial.println("uptodate temperature " + String(n) +":" + String(temperature[n]));
|
||||||
}
|
}
|
||||||
if(warn_sta)
|
if(warn_sta)
|
||||||
{
|
{
|
||||||
@ -879,13 +836,13 @@ void task_4G_mode(void *pvParameters)
|
|||||||
}
|
}
|
||||||
|
|
||||||
//获取时间
|
//获取时间
|
||||||
Serial0.println("work_mode = " + String(work_mode) );
|
//Serial.println("work_mode = " + String(work_mode) );
|
||||||
if(work_mode == 4)
|
if(work_mode == 4)
|
||||||
{
|
{
|
||||||
String time_4g = getnetData();
|
String time_4g = getnetData();
|
||||||
Serial0.println("time_4g " + time_4g);
|
//Serial.println("time_4g " + time_4g);
|
||||||
rtc.getDateTime(&now);
|
rtc.getDateTime(&now);
|
||||||
Serial0.println("rtc time :" + String(now.year) + "-" + String(now.month) + "-" + String(now.day) + " " + String(now.hour) + ":" + String(now.minute) + ":" + String(now.second));
|
//Serial.println("rtc time :" + String(now.year) + "-" + String(now.month) + "-" + String(now.day) + " " + String(now.hour) + ":" + String(now.minute) + ":" + String(now.second));
|
||||||
|
|
||||||
|
|
||||||
if(time_4g != "-1")
|
if(time_4g != "-1")
|
||||||
@ -912,12 +869,44 @@ void task_4G_mode(void *pvParameters)
|
|||||||
now.second = second;
|
now.second = second;
|
||||||
rtc.setDateTime(&now);
|
rtc.setDateTime(&now);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
////获取GPS
|
||||||
|
gps_struct gps_structure;
|
||||||
|
String gpsbac = get_GPS(&gps_structure);
|
||||||
|
if(gpsbac == "-1") write_log(log_path,"no gps",10);
|
||||||
|
else if(gpsbac != "-1")
|
||||||
|
{
|
||||||
|
|
||||||
|
if(xSemaphoreTake(xMutexInventory, timeOut) == pdPASS)
|
||||||
|
{
|
||||||
|
sun_latitude = gps_structure.latitude;
|
||||||
|
sun_longitude = gps_structure.longitude;
|
||||||
|
xSemaphoreGive(xMutexInventory);
|
||||||
|
}
|
||||||
|
|
||||||
|
//Serial.println("gps_structure.latitude " + String(gps_structure.latitude));
|
||||||
|
//Serial.println("gps_structure.longitude " + String(gps_structure.longitude));
|
||||||
|
|
||||||
|
// gps_structure.year = gps_structure.year - 2000;
|
||||||
|
// if(now.year != gps_structure.year || now.month != gps_structure.month || now.day != gps_structure.day || now.hour != gps_structure.hour || (fabs(now.minute - net_structure.minute)>5 ))
|
||||||
|
// {
|
||||||
|
// now.year = gps_structure.year;
|
||||||
|
// now.month = gps_structure.month;
|
||||||
|
// now.day = gps_structure.day;
|
||||||
|
// now.hour = gps_structure.hour;
|
||||||
|
// now.minute = gps_structure.minute;
|
||||||
|
// now.second = gps_structure.second;
|
||||||
|
// // rtc.setDateTime(&now);
|
||||||
|
// }
|
||||||
|
// last_day = now.day;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
float now_time = now.hour + now.minute/100;
|
float now_time = now.hour + now.minute/100;
|
||||||
Serial0.println("now_time " + String(now_time));
|
//Serial.println("now_time " + String(now_time));
|
||||||
Serial0.println("start_time " + String(start_time));
|
//Serial.println("start_time " + String(start_time));
|
||||||
Serial0.println("stop_time " + String(stop_time));
|
//Serial.println("stop_time " + String(stop_time));
|
||||||
|
// vTaskDelay(1000 * 1);
|
||||||
if((now_time >= start_time) && (now_time < stop_time))
|
if((now_time >= start_time) && (now_time < stop_time))
|
||||||
{
|
{
|
||||||
is11Sensor->TakeOneJob();
|
is11Sensor->TakeOneJob();
|
||||||
@ -935,15 +924,29 @@ void task_4G_mode(void *pvParameters)
|
|||||||
// doc_4G["a4"] = STRSensorInfos_structure.a4;
|
// doc_4G["a4"] = STRSensorInfos_structure.a4;
|
||||||
// http_head.sn
|
// http_head.sn
|
||||||
String sn = STRSensorInfos_structure.serialnumber;
|
String sn = STRSensorInfos_structure.serialnumber;
|
||||||
|
write_log(log_path,"task 4g sn: " + sn,10);
|
||||||
|
memset(&http_head,'\0',sizeof(http_head));
|
||||||
String version = sys_sd_doc["version"] ;
|
String version = sys_sd_doc["version"] ;
|
||||||
memcpy(http_head.sn,sn.c_str(),sn.length());
|
memcpy(http_head.sn,sn.c_str(),sn.length());
|
||||||
memcpy(http_head.version,version.c_str(),version.length());
|
memcpy(http_head.version,version.c_str(),version.length());
|
||||||
|
http_head.sn[sn.length()] = '\0';
|
||||||
|
http_head.version[version.length()] = '\0';
|
||||||
|
|
||||||
|
// http_head.sn[0] = 'i';
|
||||||
|
// http_head.sn[1] = 's';
|
||||||
|
// http_head.sn[2] = '1';
|
||||||
|
// http_head.sn[3] = '1';
|
||||||
|
// http_head.sn[4] = '0';
|
||||||
|
// http_head.sn[5] = '0';
|
||||||
|
// http_head.sn[6] = '7';
|
||||||
|
// http_head.sn[7] = '\0';
|
||||||
|
|
||||||
http_head.lat = sun_latitude;
|
http_head.lat = sun_latitude;
|
||||||
http_head.lon = sun_longitude;
|
http_head.lon = sun_longitude;
|
||||||
http_head.is3_a1 = STRSensorInfos_structure.a1;
|
http_head.is3_a1 = is11Sensor->SensorInfo.a1;
|
||||||
http_head.is3_a2 = STRSensorInfos_structure.a2;
|
http_head.is3_a2 = is11Sensor->SensorInfo.a2;
|
||||||
http_head.is3_a3 = STRSensorInfos_structure.a3;
|
http_head.is3_a3 = is11Sensor->SensorInfo.a3;
|
||||||
http_head.is3_a4 = STRSensorInfos_structure.a4;
|
http_head.is3_a4 = is11Sensor->SensorInfo.a4;
|
||||||
|
|
||||||
xSemaphoreGive(xMutexInventory);
|
xSemaphoreGive(xMutexInventory);
|
||||||
}
|
}
|
||||||
@ -951,8 +954,12 @@ void task_4G_mode(void *pvParameters)
|
|||||||
memcpy(data,&http_head,sizeof(http_head));
|
memcpy(data,&http_head,sizeof(http_head));
|
||||||
memcpy((data + sizeof(http_head)),&IS11_datastruct_fanshelv,sizeof(IS11_datastruct_fanshelv));
|
memcpy((data + sizeof(http_head)),&IS11_datastruct_fanshelv,sizeof(IS11_datastruct_fanshelv));
|
||||||
vTaskDelay(10);
|
vTaskDelay(10);
|
||||||
|
write_log(log_path,"upload data to server",10);
|
||||||
UpdateData("/HyperspectralV2/DataUpload.php",data , sizeof(http_head) + sizeof(IS11_datastruct_fanshelv),HTTP_METHOD_POST);
|
UpdateData("/HyperspectralV2/DataUpload.php",data , sizeof(http_head) + sizeof(IS11_datastruct_fanshelv),HTTP_METHOD_POST);
|
||||||
}
|
}
|
||||||
|
//Serial.println("http_head.lat " + String(http_head.lat));
|
||||||
|
//Serial.println("http_head.lon " + String(http_head.lon));
|
||||||
|
|
||||||
vTaskDelay(1000 * time_interval);
|
vTaskDelay(1000 * time_interval);
|
||||||
}
|
}
|
||||||
vTaskDelay(10);
|
vTaskDelay(10);
|
||||||
@ -981,8 +988,18 @@ void receive_command_unpack(uint8_t * read_buf,uint16_t data_length,uint8_t port
|
|||||||
uint8_t low_power_sta = 1;
|
uint8_t low_power_sta = 1;
|
||||||
u_char send_buff[300];
|
u_char send_buff[300];
|
||||||
|
|
||||||
|
|
||||||
int ret = IRIS_STM32_Protocol_Unpack(read_buf,data_length,&data_type,command_data);
|
int ret = IRIS_STM32_Protocol_Unpack(read_buf,data_length,&data_type,command_data);
|
||||||
|
|
||||||
|
// write_log(log_path,"receive port_type: " + String(port_type),10);
|
||||||
|
// write_log(log_path,"ret: " + String(ret),10);
|
||||||
|
|
||||||
|
// Serial.println("read_buf: " + String(read_buf,data_length));
|
||||||
|
for (int i = 0; i < data_length; i++)
|
||||||
|
{
|
||||||
|
Serial.printf("%02X ",read_buf[i]);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
if (ret > 0)
|
if (ret > 0)
|
||||||
{
|
{
|
||||||
@ -1013,7 +1030,7 @@ void receive_command_unpack(uint8_t * read_buf,uint16_t data_length,uint8_t port
|
|||||||
//保存到sd卡
|
//保存到sd卡
|
||||||
if(command_data[0] == 4)
|
if(command_data[0] == 4)
|
||||||
{
|
{
|
||||||
if(command_data[1] == 0) dingbiao_path = "/dingbiao/dingbiao_up_gain.bin";
|
if(command_data[1] == 0) dingbiao_path = "/dingbiao/upgain.bin";
|
||||||
else if(command_data[1] == 1) dingbiao_path = "/dingbiao/dingbiao_up_offset.bin";
|
else if(command_data[1] == 1) dingbiao_path = "/dingbiao/dingbiao_up_offset.bin";
|
||||||
}
|
}
|
||||||
else if(command_data[0] == 5)
|
else if(command_data[0] == 5)
|
||||||
@ -1080,8 +1097,9 @@ void receive_command_unpack(uint8_t * read_buf,uint16_t data_length,uint8_t port
|
|||||||
if(xSemaphoreTake(xMutexInventory, timeOut) == pdPASS)
|
if(xSemaphoreTake(xMutexInventory, timeOut) == pdPASS)
|
||||||
{
|
{
|
||||||
caiji_mode = 1;
|
caiji_mode = 1;
|
||||||
|
xSemaphoreGive(xMutexInventory);
|
||||||
}
|
}
|
||||||
xSemaphoreGive(xMutexInventory);
|
|
||||||
uint8_t a = 0x01;
|
uint8_t a = 0x01;
|
||||||
send_lenth = IRIS_Protocol_Pack(0X62,1,&a,send_buff);
|
send_lenth = IRIS_Protocol_Pack(0X62,1,&a,send_buff);
|
||||||
|
|
||||||
@ -1169,8 +1187,9 @@ void receive_command_unpack(uint8_t * read_buf,uint16_t data_length,uint8_t port
|
|||||||
calculation_bochang2 = b;
|
calculation_bochang2 = b;
|
||||||
|
|
||||||
caiji_mode = 6;
|
caiji_mode = 6;
|
||||||
|
xSemaphoreGive(xMutexInventory);
|
||||||
}
|
}
|
||||||
xSemaphoreGive(xMutexInventory);
|
|
||||||
|
|
||||||
// uint8_t dd = 0x01;
|
// uint8_t dd = 0x01;
|
||||||
is11Sensor->calculation_value = 0;
|
is11Sensor->calculation_value = 0;
|
||||||
@ -1206,6 +1225,7 @@ void receive_command_unpack(uint8_t * read_buf,uint16_t data_length,uint8_t port
|
|||||||
if(port_type == 1) wb485Serial.write(send_buff,send_lenth);
|
if(port_type == 1) wb485Serial.write(send_buff,send_lenth);
|
||||||
else if(port_type == 2) mqtt_write(send_buff,send_lenth);
|
else if(port_type == 2) mqtt_write(send_buff,send_lenth);
|
||||||
|
|
||||||
|
sys_sd_doc["GPS_mode"]== "manual";
|
||||||
sys_sd_doc["latitude"] = sun_latitude;
|
sys_sd_doc["latitude"] = sun_latitude;
|
||||||
sys_sd_doc["longitude"] = sun_longitude;
|
sys_sd_doc["longitude"] = sun_longitude;
|
||||||
String send_str = "";
|
String send_str = "";
|
||||||
@ -1272,7 +1292,6 @@ command : 1、get_sensor_info
|
|||||||
23、set_Minimum_temperature
|
23、set_Minimum_temperature
|
||||||
24、
|
24、
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/*{"command":"","name":"gaoguangpu","version":"v2.0","SN":"123456","date":"","caiji_mode":"","time_interval":"","return_data_type":"","bochangxishu":""}*/
|
/*{"command":"","name":"gaoguangpu","version":"v2.0","SN":"123456","date":"","caiji_mode":"","time_interval":"","return_data_type":"","bochangxishu":""}*/
|
||||||
void json_command(uint8_t port_type)
|
void json_command(uint8_t port_type)
|
||||||
{
|
{
|
||||||
@ -1714,7 +1733,14 @@ void json_command(uint8_t port_type)
|
|||||||
//command 10
|
//command 10
|
||||||
else if (doc["command"] == "set_bochangxishu")
|
else if (doc["command"] == "set_bochangxishu")
|
||||||
{
|
{
|
||||||
float b1=0,b2=0,b3=0,b4=0;
|
double a0=0,a1=0,a2=0,a3=0,a4=0,b1=0,b2=0,b3=0,b4=0;
|
||||||
|
|
||||||
|
a0 = doc["bochangxishu"]["a0"];
|
||||||
|
a1 = doc["bochangxishu"]["a1"];
|
||||||
|
a2 = doc["bochangxishu"]["a2"];
|
||||||
|
a3 = doc["bochangxishu"]["a3"];
|
||||||
|
|
||||||
|
|
||||||
b1 = doc["bochangxishu"]["b0"];
|
b1 = doc["bochangxishu"]["b0"];
|
||||||
b2 = doc["bochangxishu"]["b1"];
|
b2 = doc["bochangxishu"]["b1"];
|
||||||
b3 = doc["bochangxishu"]["b2"];
|
b3 = doc["bochangxishu"]["b2"];
|
||||||
@ -1723,10 +1749,30 @@ 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"];
|
||||||
bc_b4 = doc["bochangxishu"]["b3"];
|
// bc_b4 = doc["bochangxishu"]["b3"];
|
||||||
|
is11Sensor->SensorInfo.a1 = doc["bochangxishu"]["a0"];
|
||||||
|
is11Sensor->SensorInfo.a2 = doc["bochangxishu"]["a1"];
|
||||||
|
is11Sensor->SensorInfo.a3 = doc["bochangxishu"]["a2"];
|
||||||
|
is11Sensor->SensorInfo.a4 = doc["bochangxishu"]["a3"];
|
||||||
|
|
||||||
|
is11Sensor->guangpu_bochang.a0 = doc["bochangxishu"]["a0"];
|
||||||
|
is11Sensor->guangpu_bochang.a1 = doc["bochangxishu"]["a1"];
|
||||||
|
is11Sensor->guangpu_bochang.a2 = doc["bochangxishu"]["a2"];
|
||||||
|
is11Sensor->guangpu_bochang.a3 = doc["bochangxishu"]["a3"];
|
||||||
|
|
||||||
|
is11Sensor->guangpu_bochang.b0 = doc["bochangxishu"]["b0"];
|
||||||
|
is11Sensor->guangpu_bochang.b1 = doc["bochangxishu"]["b1"];
|
||||||
|
is11Sensor->guangpu_bochang.b2 = doc["bochangxishu"]["b2"];
|
||||||
|
is11Sensor->guangpu_bochang.b3 = doc["bochangxishu"]["b3"];
|
||||||
|
|
||||||
|
|
||||||
|
sys_sd_doc["bochangxishu"]["a0"] = doc["bochangxishu"]["a0"];
|
||||||
|
sys_sd_doc["bochangxishu"]["a1"] = doc["bochangxishu"]["a1"];
|
||||||
|
sys_sd_doc["bochangxishu"]["a2"] = doc["bochangxishu"]["a2"];
|
||||||
|
sys_sd_doc["bochangxishu"]["a3"] = doc["bochangxishu"]["a3"];
|
||||||
|
|
||||||
sys_sd_doc["bochangxishu"]["b0"] = doc["bochangxishu"]["b0"];
|
sys_sd_doc["bochangxishu"]["b0"] = doc["bochangxishu"]["b0"];
|
||||||
sys_sd_doc["bochangxishu"]["b1"] = doc["bochangxishu"]["b1"];
|
sys_sd_doc["bochangxishu"]["b1"] = doc["bochangxishu"]["b1"];
|
||||||
@ -2253,10 +2299,10 @@ void json_command(uint8_t port_type)
|
|||||||
// 导出定标文件
|
// 导出定标文件
|
||||||
else if(doc["command"] == "get_dingbiao")
|
else if(doc["command"] == "get_dingbiao")
|
||||||
{
|
{
|
||||||
send_dingbiao("/dingbiao/dingbiao_up_gain.bin");
|
send_dingbiao("/dingbiao/upgain.bin");
|
||||||
send_dingbiao("/dingbiao/dingbiao_up_offset.bin");
|
send_dingbiao("/dingbiao/upoffset.bin");
|
||||||
send_dingbiao("/dingbiao/dingbiao_down_gain.bin");
|
send_dingbiao("/dingbiao/downgain.bin");
|
||||||
send_dingbiao("/dingbiao/dingbiao_down_offset.bin");
|
send_dingbiao("/dingbiao/downoffset.bin");
|
||||||
}
|
}
|
||||||
//command 28
|
//command 28
|
||||||
//获取电源电压
|
//获取电源电压
|
||||||
@ -2404,12 +2450,19 @@ 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);
|
||||||
// myusb_init();
|
// myusb_init();
|
||||||
|
|
||||||
setupmsc();
|
setupmsc();
|
||||||
|
|
||||||
|
vTaskSuspend(Task0_Handler);
|
||||||
|
vTaskSuspend(Task1_Handler);
|
||||||
|
// vTaskSuspend(Task2_Handler);
|
||||||
|
vTaskSuspend(A4G_Handler);
|
||||||
|
vTaskSuspend(OTA_Handler);
|
||||||
}
|
}
|
||||||
//command 38
|
//command 38
|
||||||
else if(doc["command"] == "reboot")
|
else if(doc["command"] == "reboot")
|
||||||
{
|
{
|
||||||
// setupmsc();
|
stopmsc();
|
||||||
send_str = "";
|
send_str = "";
|
||||||
doc["state"] = "success";
|
doc["state"] = "success";
|
||||||
serializeJson(doc, send_str);
|
serializeJson(doc, send_str);
|
||||||
@ -2442,8 +2495,9 @@ void json_command(uint8_t port_type)
|
|||||||
file.close();
|
file.close();
|
||||||
save = false;
|
save = false;
|
||||||
}
|
}
|
||||||
|
xSemaphoreGive(xMutexInventory);
|
||||||
}
|
}
|
||||||
xSemaphoreGive(xMutexInventory);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -2542,23 +2596,45 @@ void sys_info_init()
|
|||||||
write_log(log_path,"servo_offset_angle_down" + String(a),10);
|
write_log(log_path,"servo_offset_angle_down" + String(a),10);
|
||||||
servo_offset(a,0);
|
servo_offset(a,0);
|
||||||
|
|
||||||
sys_sd_doc["latitude"] = doc["latitude"];
|
if(doc["GPS_mode"]== "manual")
|
||||||
sys_sd_doc["longitude"] = doc["longitude"];
|
{
|
||||||
sun_latitude = doc["latitude"];
|
sys_sd_doc["latitude"] = doc["latitude"];
|
||||||
sun_longitude = doc["longitude"];
|
sys_sd_doc["longitude"] = doc["longitude"];
|
||||||
write_log(log_path,"latitude" + String(sun_latitude),10);
|
sun_latitude = doc["latitude"];
|
||||||
write_log(log_path,"longitude" + String(sun_longitude),10);
|
sun_longitude = doc["longitude"];
|
||||||
|
write_log(log_path,"latitude" + String(sun_latitude),10);
|
||||||
|
write_log(log_path,"longitude" + String(sun_longitude),10);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
sys_sd_doc["bochangxishu"]["a0"] = STRSensorInfos_structure.a1;
|
|
||||||
sys_sd_doc["bochangxishu"]["a1"] = STRSensorInfos_structure.a2;
|
// sys_sd_doc["bochangxishu"]["a0"] = STRSensorInfos_structure.a1;
|
||||||
sys_sd_doc["bochangxishu"]["a2"] = STRSensorInfos_structure.a3;
|
// sys_sd_doc["bochangxishu"]["a1"] = STRSensorInfos_structure.a2;
|
||||||
sys_sd_doc["bochangxishu"]["a3"] = STRSensorInfos_structure.a4;
|
// sys_sd_doc["bochangxishu"]["a2"] = STRSensorInfos_structure.a3;
|
||||||
|
// sys_sd_doc["bochangxishu"]["a3"] = STRSensorInfos_structure.a4;
|
||||||
|
|
||||||
|
sys_sd_doc["bochangxishu"]["a0"] = doc["bochangxishu"]["a0"];
|
||||||
|
sys_sd_doc["bochangxishu"]["a1"] = doc["bochangxishu"]["a1"];
|
||||||
|
sys_sd_doc["bochangxishu"]["a2"] = doc["bochangxishu"]["a2"];
|
||||||
|
sys_sd_doc["bochangxishu"]["a3"] = doc["bochangxishu"]["a3"];
|
||||||
|
|
||||||
sys_sd_doc["bochangxishu"]["b0"] = doc["bochangxishu"]["b0"];
|
sys_sd_doc["bochangxishu"]["b0"] = doc["bochangxishu"]["b0"];
|
||||||
sys_sd_doc["bochangxishu"]["b1"] = doc["bochangxishu"]["b1"];
|
sys_sd_doc["bochangxishu"]["b1"] = doc["bochangxishu"]["b1"];
|
||||||
sys_sd_doc["bochangxishu"]["b2"] = doc["bochangxishu"]["b2"];
|
sys_sd_doc["bochangxishu"]["b2"] = doc["bochangxishu"]["b2"];
|
||||||
sys_sd_doc["bochangxishu"]["b3"] = doc["bochangxishu"]["b3"];
|
sys_sd_doc["bochangxishu"]["b3"] = doc["bochangxishu"]["b3"];
|
||||||
|
|
||||||
|
is11Sensor->guangpu_bochang.b0 = doc["bochangxishu"]["b0"];
|
||||||
|
is11Sensor->guangpu_bochang.b1 = doc["bochangxishu"]["b1"];
|
||||||
|
is11Sensor->guangpu_bochang.b2 = doc["bochangxishu"]["b2"];
|
||||||
|
is11Sensor->guangpu_bochang.b3 = doc["bochangxishu"]["b3"];
|
||||||
|
|
||||||
|
is11Sensor->guangpu_bochang.a0 = doc["bochangxishu"]["a0"];
|
||||||
|
is11Sensor->guangpu_bochang.a1 = doc["bochangxishu"]["a1"];
|
||||||
|
is11Sensor->guangpu_bochang.a2 = doc["bochangxishu"]["a2"];
|
||||||
|
is11Sensor->guangpu_bochang.a3 = doc["bochangxishu"]["a3"];
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
sys_sd_doc["return_data_type"] = doc["return_data_type"];
|
sys_sd_doc["return_data_type"] = doc["return_data_type"];
|
||||||
sys_sd_doc["return_mode"] = doc["return_mode"]; //暂定
|
sys_sd_doc["return_mode"] = doc["return_mode"]; //暂定
|
||||||
sys_sd_doc["atuo_return"] = doc["atuo_return"].as<String>();//一会
|
sys_sd_doc["atuo_return"] = doc["atuo_return"].as<String>();//一会
|
||||||
@ -2597,15 +2673,15 @@ void sys_info_init()
|
|||||||
sys_sd_doc["Minimum_temperature"] = Minimum_temperature;
|
sys_sd_doc["Minimum_temperature"] = Minimum_temperature;
|
||||||
sys_sd_doc["servo_offset_angle"] = 0;
|
sys_sd_doc["servo_offset_angle"] = 0;
|
||||||
|
|
||||||
sys_sd_doc["bochangxishu"]["a0"] = STRSensorInfos_structure.a1;
|
sys_sd_doc["bochangxishu"]["a0"] = is11Sensor->guangpu_bochang.a0;
|
||||||
sys_sd_doc["bochangxishu"]["a1"] = STRSensorInfos_structure.a2;
|
sys_sd_doc["bochangxishu"]["a1"] = is11Sensor->guangpu_bochang.a1;
|
||||||
sys_sd_doc["bochangxishu"]["a2"] = STRSensorInfos_structure.a3;
|
sys_sd_doc["bochangxishu"]["a2"] = is11Sensor->guangpu_bochang.a2;
|
||||||
sys_sd_doc["bochangxishu"]["a3"] = STRSensorInfos_structure.a4;
|
sys_sd_doc["bochangxishu"]["a3"] = is11Sensor->guangpu_bochang.a3;
|
||||||
|
|
||||||
sys_sd_doc["bochangxishu"]["b0"] = bc_b1;
|
sys_sd_doc["bochangxishu"]["b0"] = is11Sensor->guangpu_bochang.b0;
|
||||||
sys_sd_doc["bochangxishu"]["b1"] = bc_b2;
|
sys_sd_doc["bochangxishu"]["b1"] = is11Sensor->guangpu_bochang.b1;
|
||||||
sys_sd_doc["bochangxishu"]["b2"] = bc_b3;
|
sys_sd_doc["bochangxishu"]["b2"] = is11Sensor->guangpu_bochang.b2;
|
||||||
sys_sd_doc["bochangxishu"]["b3"] = bc_b4;
|
sys_sd_doc["bochangxishu"]["b3"] = is11Sensor->guangpu_bochang.b3;
|
||||||
sys_sd_doc["return_data_type"] = return_data_type;
|
sys_sd_doc["return_data_type"] = return_data_type;
|
||||||
sys_sd_doc["return_mode"] = ""; //暂定
|
sys_sd_doc["return_mode"] = ""; //暂定
|
||||||
sys_sd_doc["atuo_return"] = "no";
|
sys_sd_doc["atuo_return"] = "no";
|
||||||
|
|||||||
@ -98,11 +98,10 @@ void setupmsc()
|
|||||||
|
|
||||||
USB.begin();
|
USB.begin();
|
||||||
USB.onEvent(usbEventCallback);
|
USB.onEvent(usbEventCallback);
|
||||||
|
|
||||||
|
// msc.end();
|
||||||
}
|
}
|
||||||
|
|
||||||
// void loop() {
|
|
||||||
// delay(-1);
|
|
||||||
// }
|
|
||||||
|
|
||||||
void stopmsc()
|
void stopmsc()
|
||||||
{
|
{
|
||||||
|
|||||||
@ -73,22 +73,32 @@ void servo_down()
|
|||||||
|
|
||||||
void shutter_up()
|
void shutter_up()
|
||||||
{
|
{
|
||||||
digitalWrite(Shutter_pin1, HIGH);
|
digitalWrite(Shutter_pin1, LOW);
|
||||||
digitalWrite(Shutter_pin2, LOW);
|
digitalWrite(Shutter_pin2, HIGH);
|
||||||
|
vTaskDelay(200);
|
||||||
}
|
}
|
||||||
void shutter_down()
|
void shutter_down()
|
||||||
{
|
{
|
||||||
digitalWrite(Shutter_pin2, HIGH);
|
digitalWrite(Shutter_pin1, HIGH);
|
||||||
digitalWrite(Shutter_pin1, LOW);
|
digitalWrite(Shutter_pin2, LOW);
|
||||||
|
vTaskDelay(200);
|
||||||
}
|
}
|
||||||
|
|
||||||
void shutter_off()
|
void shutter_off()
|
||||||
{
|
{
|
||||||
digitalWrite(Shutter_pin1, LOW);
|
digitalWrite(Shutter_pin1, LOW);
|
||||||
digitalWrite(Shutter_pin2, LOW);
|
digitalWrite(Shutter_pin2, LOW);
|
||||||
|
vTaskDelay(200);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void shutter_on()
|
||||||
|
{
|
||||||
|
digitalWrite(Shutter_pin1, HIGH);
|
||||||
|
digitalWrite(Shutter_pin2, HIGH);
|
||||||
|
vTaskDelay(200);
|
||||||
|
}
|
||||||
|
|
||||||
/// @brief
|
/// @brief
|
||||||
/// @param dir 0 down 1 up
|
/// @param dir 0 down 1 up
|
||||||
/// @param angle
|
/// @param angle
|
||||||
|
|||||||
@ -18,4 +18,5 @@ void servo_offset(float angle,uint8_t dir);
|
|||||||
void shutter_up();
|
void shutter_up();
|
||||||
void shutter_down();
|
void shutter_down();
|
||||||
void shutter_off();
|
void shutter_off();
|
||||||
|
void shutter_on();
|
||||||
#endif
|
#endif
|
||||||
@ -35,11 +35,11 @@ bool check_tuigan()
|
|||||||
pinMode(tuigan_chek_pin, INPUT_PULLUP);
|
pinMode(tuigan_chek_pin, INPUT_PULLUP);
|
||||||
if(digitalRead(tuigan_chek_pin) == LOW)
|
if(digitalRead(tuigan_chek_pin) == LOW)
|
||||||
{
|
{
|
||||||
tuigan = tui;
|
tuigan = suo;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
tuigan = suo;
|
tuigan = tui;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(tuigan != tuigan_sta) return false;
|
if(tuigan != tuigan_sta) return false;
|
||||||
|
|||||||
@ -4,37 +4,37 @@ void UpDateClassByme::performUpdate(Stream &updateSource, size_t updateSize)
|
|||||||
{
|
{
|
||||||
if (Update.begin(updateSize))
|
if (Update.begin(updateSize))
|
||||||
{
|
{
|
||||||
Serial.println("Writes : ");
|
//Serial.println("Writes : ");
|
||||||
size_t written = Update.writeStream(updateSource);
|
size_t written = Update.writeStream(updateSource);
|
||||||
if (written == updateSize)
|
if (written == updateSize)
|
||||||
{
|
{
|
||||||
Serial.println("Writes : " + String(written) + " successfully");
|
//Serial.println("Writes : " + String(written) + " successfully");
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
Serial.println("Written only : " + String(written) + "/" + String(updateSize) + ". Retry?");
|
//Serial.println("Written only : " + String(written) + "/" + String(updateSize) + ". Retry?");
|
||||||
}
|
}
|
||||||
if (Update.end())
|
if (Update.end())
|
||||||
{
|
{
|
||||||
Serial.println("OTA finished!");
|
//Serial.println("OTA finished!");
|
||||||
if (Update.isFinished())
|
if (Update.isFinished())
|
||||||
{
|
{
|
||||||
Serial.println("Restart ESP device!");
|
//Serial.println("Restart ESP device!");
|
||||||
abort();
|
abort();
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
Serial.println("OTA not fiished");
|
//Serial.println("OTA not fiished");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
Serial.println("Error occured #: " + String(Update.getError()));
|
//Serial.println("Error occured #: " + String(Update.getError()));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
Serial.println("Cannot beggin update");
|
//Serial.println("Cannot beggin update");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -45,7 +45,7 @@ size_t UpDateClassByme::DownloadFirmwareForurl(String version)
|
|||||||
int err = http->get(url.c_str());
|
int err = http->get(url.c_str());
|
||||||
if (err != 0)
|
if (err != 0)
|
||||||
{
|
{
|
||||||
Serial.println(F("Date failed to connect"));
|
//Serial.println(F("Date failed to connect"));
|
||||||
vTaskDelay(10000);
|
vTaskDelay(10000);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
@ -55,15 +55,15 @@ size_t UpDateClassByme::DownloadFirmwareForurl(String version)
|
|||||||
vTaskDelay(10000);
|
vTaskDelay(10000);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
Serial.print(F("Response status code: "));
|
//Serial.print(F("Response status code: "));
|
||||||
Serial.println(status);
|
//Serial.println(status);
|
||||||
// SerialMon.println(F("Response Headers:"));
|
// SerialMon.println(F("Response Headers:"));
|
||||||
size_t count=0;
|
size_t count=0;
|
||||||
while (http->headerAvailable())
|
while (http->headerAvailable())
|
||||||
{
|
{
|
||||||
String headerName = http->readHeaderName();
|
String headerName = http->readHeaderName();
|
||||||
String headerValue = http->readHeaderValue();
|
String headerValue = http->readHeaderValue();
|
||||||
Serial.println("Date: " + headerName + " : " + headerValue);
|
//Serial.println("Date: " + headerName + " : " + headerValue);
|
||||||
if (headerName=="Content-Length")
|
if (headerName=="Content-Length")
|
||||||
{
|
{
|
||||||
count=headerValue.toInt();
|
count=headerValue.toInt();
|
||||||
@ -72,10 +72,10 @@ size_t UpDateClassByme::DownloadFirmwareForurl(String version)
|
|||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
Serial.println("lenth is "+String(count));
|
//Serial.println("lenth is "+String(count));
|
||||||
if (http->isResponseChunked())
|
if (http->isResponseChunked())
|
||||||
{
|
{
|
||||||
Serial.println(F("Date The response is chunked"));
|
//Serial.println(F("Date The response is chunked"));
|
||||||
}
|
}
|
||||||
char *str=new char[1000];
|
char *str=new char[1000];
|
||||||
int lent=count/1000;
|
int lent=count/1000;
|
||||||
@ -87,8 +87,8 @@ size_t UpDateClassByme::DownloadFirmwareForurl(String version)
|
|||||||
{
|
{
|
||||||
http->readBytes(str,1000);
|
http->readBytes(str,1000);
|
||||||
file.write((const byte *)str,1000);
|
file.write((const byte *)str,1000);
|
||||||
Serial.print("download ");
|
//Serial.print("download ");
|
||||||
Serial.println(String(i*100/lent));
|
//Serial.println(String(i*100/lent));
|
||||||
/* code */
|
/* code */
|
||||||
}
|
}
|
||||||
http->readBytes(str,count%1000);
|
http->readBytes(str,count%1000);
|
||||||
@ -99,7 +99,7 @@ size_t UpDateClassByme::DownloadFirmwareForurl(String version)
|
|||||||
|
|
||||||
|
|
||||||
// http->readBytes
|
// http->readBytes
|
||||||
Serial.println("adfasdfsadfsdfsd");
|
//Serial.println("adfasdfsadfsdfsd");
|
||||||
//Serial.write(str,cout);
|
//Serial.write(str,cout);
|
||||||
//Serial.println(body.length());
|
//Serial.println(body.length());
|
||||||
http->stop();
|
http->stop();
|
||||||
@ -124,7 +124,7 @@ bool UpDateClassByme::CheckAndUpdate()
|
|||||||
return true;
|
return true;
|
||||||
|
|
||||||
}
|
}
|
||||||
Serial.println("targetvesion is:"+Targetversion);
|
//Serial.println("targetvesion is:"+Targetversion);
|
||||||
|
|
||||||
//size_t countdownload1=375584;
|
//size_t countdownload1=375584;
|
||||||
size_t countdownload1=DownloadFirmwareForurl(Targetversion);
|
size_t countdownload1=DownloadFirmwareForurl(Targetversion);
|
||||||
@ -132,7 +132,7 @@ bool UpDateClassByme::CheckAndUpdate()
|
|||||||
{
|
{
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
Serial.println("count download is:"+String(countdownload1));
|
//Serial.println("count download is:"+String(countdownload1));
|
||||||
|
|
||||||
String MD5=GetValueFromNet("/weather/php/GetMD5Value.php",Targetversion);
|
String MD5=GetValueFromNet("/weather/php/GetMD5Value.php",Targetversion);
|
||||||
|
|
||||||
@ -153,8 +153,8 @@ bool UpDateClassByme::CheckAndUpdate()
|
|||||||
md5my.addStream(file,countdownload1);
|
md5my.addStream(file,countdownload1);
|
||||||
md5my.calculate();
|
md5my.calculate();
|
||||||
String md5com=md5my.toString();
|
String md5com=md5my.toString();
|
||||||
Serial.println("md5 comput is:"+md5my.toString());
|
//Serial.println("md5 comput is:"+md5my.toString());
|
||||||
Serial.println("md5 should is:"+MD5);
|
//Serial.println("md5 should is:"+MD5);
|
||||||
file.close();
|
file.close();
|
||||||
if (MD5==md5com)
|
if (MD5==md5com)
|
||||||
{
|
{
|
||||||
@ -189,8 +189,8 @@ String UpDateClassByme::GetValueFromNet(String url,String Key)
|
|||||||
http->sendHeader(HTTP_HEADER_CONTENT_LENGTH, Key.length());
|
http->sendHeader(HTTP_HEADER_CONTENT_LENGTH, Key.length());
|
||||||
http->endRequest();
|
http->endRequest();
|
||||||
int err = http->write((const byte *)Key.c_str(), Key.length());
|
int err = http->write((const byte *)Key.c_str(), Key.length());
|
||||||
Serial.print("send date size");
|
//Serial.print("send date size");
|
||||||
Serial.println(err);
|
//Serial.println(err);
|
||||||
|
|
||||||
if (err == 0)
|
if (err == 0)
|
||||||
{
|
{
|
||||||
@ -213,7 +213,7 @@ String UpDateClassByme::GetValueFromNet(String url,String Key)
|
|||||||
}
|
}
|
||||||
|
|
||||||
String body = http->responseBody();
|
String body = http->responseBody();
|
||||||
Serial.println("body:"+body);
|
//Serial.println("body:"+body);
|
||||||
|
|
||||||
http->stop();
|
http->stop();
|
||||||
return body;
|
return body;
|
||||||
|
|||||||
Reference in New Issue
Block a user