1 Commits
Author SHA1 Message Date
magnum88 cab552d78c first commit 2022-08-24 08:28:06 +02:00
15 changed files with 274 additions and 427 deletions
+3 -20
View File
@@ -1,11 +1,10 @@
RadioSonde Version 0.8.7
RadioSonde Version 0.8.5
============================
<img src="http://xavier.debert.free.fr/RS/TTGO.jpg" width="50%"><img src="http://xavier.debert.free.fr/RS/TTGO2.jpg" width="50%">
<img src="http://xavier.debert.free.fr/RS/TTGO3.jpg" width="50%"><img src="http://xavier.debert.free.fr/RS/TTGO4.jpg" width="50%"><img src="http://xavier.debert.free.fr/RS/TTGO5.jpg" width="50%">
<img src="http://xavier.debert.free.fr/RS/Web4.png" width="20%"><img src="http://xavier.debert.free.fr/RS/Web.png" width="20%">
<img src="http://xavier.debert.free.fr/RS/Web3.png" width="20%"><img src="http://xavier.debert.free.fr/RS/Web2.png" width="20%">
<img src="http://xavier.debert.free.fr/RS/Web5.png" width="20%"><img src="http://xavier.debert.free.fr/RS/Web6.png" width="20%">
<img src="http://xavier.debert.free.fr/RS/Web7.png" width="20%">
<img src="http://xavier.debert.free.fr/RS/Web5.png" width="20%">
Projet basé sur le travail de DL9RDZ
@@ -19,17 +18,13 @@ vous devez modifier dans config.txt, le port de l'écran OLED
- TTGO v1: SDA=4 SCL=15, RST=16
- TTGO v2: SDA=21 SCL=22, RST=16
## Version en production 0.8.5 devel 0.8.7
## Version en production 0.8.5 et devel 0.8.7
## 0.8.0
travail de refonte et réécriture du code
## 0.8.1
modification de la partie Web
## 0.8.5
Evolution majeur du système
affichage du pourcentage de la batterie en mode scanning
création d'une fenetre Batterie, Boussole
@@ -39,18 +34,6 @@ Ajout fonction Smetre, Buzzer, QTH, Gps on off ...
mise à jour OTA
trop de modification pour toutes les expliciter!
## 0.8.7
correction bug Buzzer Off->On->Off
Add GainLNA RX SX1278FSK on Web config paramètre
Add update OTA Os + DataWeb
correction bugs sondmap.html
correction text upgrade Os et DataWeb
correction texte boussole S et N
correction bugs distance 4928Km si lat et lon =0 erroné
correction bugs fonction Vbat
Add Telemetry width export data.csv
Suppression µSD incompatible avec pin SX1278FSK et SPI
Add transfert Telemetry To µSD on put SD automatic
## Les Boutons optionnel à ajouter(souder)
sur les GPIO 1002 et 1004
+8 -127
View File
@@ -22,7 +22,6 @@
#include "geteph.h"
#include "rs92gps.h"
#include "spiffs_sd.h"
int e;
enum MainState { ST_DECODER, ST_SPECTRUM, ST_WIFISCAN, ST_UPDATE, ST_TOUCHCALIB };
@@ -42,16 +41,6 @@ String updateBinM = "/RS/radiosonde/update.ino.bin";
String updateBinD = "/RS/radiosondedevel/update.ino.bin";
String *updateBin = &updateBinM;
String updateDataWeb = "/RS/dataweb/index.html.txt";
String updateDataWeb2 = "/RS/dataweb/sondemap.html.txt";
String updateDataWeb3 = "/RS/dataweb/config.txt";
String updateDataWeb4 = "/RS/dataweb/screens.txt";
String updateDataWeb5 = "/RS/dataweb/style.css.txt";
String updateDataWeb6 = "/RS/dataweb/qrg.txt";
String updateDataWeb7 = "/RS/dataweb/networks.txt";
String updateDataWeb8 = "/RS/dataweb/fontawesome-webfont.eot.txt";
String updateDataWeb9 = "/RS/dataweb/fontawesome-webfont.woff.txt";
#define LOCALUDPPORT 9002
boolean connected = false;
@@ -446,7 +435,6 @@ struct st_configitems config_list[] = {
{"noisefloor", "Sepctrum noisefloor", 0, &sonde.config.noisefloor},
/* decoder settings */
{"", "Receiver configuration", -5, NULL},
{"gainLNA", "Gain SX1278 default 0 or -32 only negatif", 0, &sonde.config.gainLNA},
{"showafc", "Show AFC value", 0, &sonde.config.showafc},
{"freqofs", "RX frequency offset (Hz)", 0, &sonde.config.freqofs},
{"rs41.agcbw", "RS41 AGC bandwidth", 0, &sonde.config.rs41.agcbw},
@@ -497,7 +485,7 @@ struct st_configitems config_list[] = {
{"mdnsname", "mDNS name", 14, &sonde.config.mdnsname},
{"vbatmax", "VBat Max", 5, sonde.config.vbatmax},
{"vbatmin", "VBat Min", 5, sonde.config.vbatmin},
{"telemetryOn", "Telemetry (0=Disabled, 1 Enable)", 0, &sonde.config.telemetryOn},
{"sdOn", "SDCard (0=Disabled, 1 Enable)", 0, &sonde.config.sdOn},
{"buzzerOn", "Buzzer (0=Disabled, 1 Enable)", 0, &sonde.config.buzzerOn},
{"buzzerPort", "Buzzer Port (12)", 0, &sonde.config.buzzerPort},
{"buzzerFreq", "Buzzer Frequency (700)", 0, &sonde.config.buzzerFreq},
@@ -892,9 +880,7 @@ void SetupAsyncServer() {
server.on("/index.html", HTTP_GET, [](AsyncWebServerRequest * request) {
request->send(SPIFFS, "/index.html", String(), false, processor);
});
server.on("/download", HTTP_GET, [](AsyncWebServerRequest *request){
request->send(SPIFFS, "/data.csv", "text/plain", true);
});
server.on("/test.html", HTTP_GET, [](AsyncWebServerRequest * request) {
request->send(SPIFFS, "/test.html", String(), false, processor);
});
@@ -1603,7 +1589,7 @@ void setup()
#endif
//sx1278.setLNAGain(-48);
sx1278.setLNAGain(sonde.config.gainLNA);
sx1278.setLNAGain(0);
int gain = sx1278.getLNAGain();
Serial.print("RX LNA Gain is ");
@@ -1646,26 +1632,7 @@ void setup()
initGPS();
WiFi.onEvent(WiFiEvent);
// init fichie data.csv
File file = SPIFFS.open("/data.csv", "w");
// Read all the lines of the reply from server and print them to Serial
if (!file) {
Serial.println("There was an error opening the file for writing");
return;
} else {
String telemetry = "RadioSonde N; Ser ; Type ; Freq ; Lat ; Lon; Alt; QTHLat; QTHLon; QTHAlt; VSpeed ; HSpeed ; Dir ; DESIGNATION ; RSSI; SMETRE; STAT; AFC; ValidPos\n";
if (file.print(telemetry+"\n")) {
Serial.println("File was written");
} else {
Serial.println("File write failed");
}
}
file.close();
getKeyPress(); // clear key buffer
}
void enterMode(int mode) {
@@ -2246,8 +2213,7 @@ void execOTA() {
bool isValidContentType = false;
sonde.clearDisplay();
disp.rdis->setFont(FONT_SMALL);
disp.rdis->drawString(0, 0, "RadioSonde");
disp.rdis->drawString(0, 1, "Upgrade Os");
disp.rdis->drawString(0, 0, "RadioSonde Upgrade");
String dispHost = updateHost.substring(0, 14);
//disp.rdis->drawString(2, 0, dispHost.c_str());
@@ -2256,7 +2222,7 @@ void execOTA() {
if (client.connect(updateHost.c_str(), updatePort)) {
// Connection succeeded, fecthing the bin
Serial.println("Fetching bin: " + String(*updateBin));
disp.rdis->drawString(0, 2, "Fetching update");
disp.rdis->drawString(0, 1, "Fetching update");
// Get the contents of the bin file
client.print(String("GET ") + *updateBin + " HTTP/1.1\r\n" +
@@ -2297,8 +2263,6 @@ void execOTA() {
{{BIN FILE CONTENTS}}
*/
while (client.available()) {
// read line till /n
String line = client.readStringUntil('\n');
@@ -2377,29 +2341,6 @@ void execOTA() {
// execOTA();
}
//ICI Update Data
/*
// Update DATAWeb!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
//Data1 index.html
updatedataweb(updateHost,updatePort,updateDataWeb,"index.html");
//Data2 sondemap.html
updatedataweb(updateHost,updatePort,updateDataWeb2,"sondemap.html");
//Data3 config.txt
updatedataweb(updateHost,updatePort,updateDataWeb3,"config.txt");
//Data4 screens.txt
updatedataweb(updateHost,updatePort,updateDataWeb4,"screens.txt");
//Data5 styles.css
updatedataweb(updateHost,updatePort,updateDataWeb5,"style.css");
//Data6 qrg.txt
updatedataweb(updateHost,updatePort,updateDataWeb6,"qrg.txt");
//Data7 networks.txt
updatedataweb(updateHost,updatePort,updateDataWeb7,"networks.txt");
//Data8 fontawesome-webfont.eot
updatedataweb(updateHost,updatePort,updateDataWeb8,"fontawesome-webfont.eot");
//Data9 fontawesome-webfont.eot
updatedataweb(updateHost,updatePort,updateDataWeb9,"fontawesome-webfont.woff");
*/
if (Update.end()) {
Serial.println("OTA done!");
if (Update.isFinished()) {
@@ -2424,76 +2365,15 @@ void execOTA() {
Serial.println("There was no content in the response");
client.flush();
}
// Back to some normal state
enterMode(ST_DECODER);
}
void updatedataweb(String host, int port, String dataweb, String fichier){
//Data1 index.html
sonde.clearDisplay();
disp.rdis->setFont(FONT_SMALL);
disp.rdis->drawString(0, 0, "RadioSonde");
disp.rdis->drawString(0, 1, "Upgrade Data");
String *data = &dataweb;
String dispHost = host.substring(0, 14);
Serial.println("Connecting to: " + host);
// Connect to Update host
if (client.connect(host.c_str(), port)) {
// Connection succeeded, fecthing the dataweb
Serial.println("Fetching data: " + String(*data));
disp.rdis->drawString(0, 3, "Fetching data");
char buf[16];
snprintf(buf, 16, "%s", fichier);
disp.rdis->drawString(0, 4, buf);
// Get the contents of the bin file
client.print(String("GET ") + *data + " HTTP/1.1\r\n" +
"Host: " + host + "\r\n" +
"Cache-Control: no-cache\r\n" +
"Connection: close\r\n\r\n");
unsigned long timeout = millis();
while (client.available() == 0) {
if (millis() - timeout > 5000) {
Serial.println("Client Timeout !");
client.stop();
return;
}
}
File file = SPIFFS.open("/"+fichier, FILE_WRITE);
int cpt=0;
// Read all the lines of the reply from server and print them to Serial
while(client.available()){
String line = client.readStringUntil('\r');
line.trim();
Serial.print(line);
cpt += 1;
if (!file) {
Serial.println("There was an error opening the file for writing");
return;
}
if (cpt>10){
if (file.print(line+"\n")) {
Serial.println("File was written");
} else {
Serial.println("File write failed");
}
}
}
file.close();
}
client.flush();
}
void loop() {
if(sonde.config.buzzerOn==1){
ledcSetup(0, sonde.config.buzzerFreq, 8);
ledcAttachPin(sonde.config.buzzerPort, 0);
} else {
ledcSetup(0, 0, 8);
ledcAttachPin(sonde.config.buzzerPort, 0);
}
Serial.printf("\nRunning main loop in state %d. free heap: %d;\n", mainState, ESP.getFreeHeap());
Serial.printf("currentDisp:%d lastDisp:%d\n", currentDisplay, lastDisplay);
@@ -2525,7 +2405,8 @@ void loop() {
sonde.clearDisplay();
sonde.updateDisplay();
lastDisplay = currentDisplay;
}
Serial.printf("Unused stack: %d\n", uxTaskGetStackHighWaterMark(0));
//transfert_sd();
}
+4 -5
View File
@@ -52,12 +52,11 @@ display=0,1,2,3,4,5,6
norx_timeout=20
vbatmax=1.86
vbatmin=1.64
telemetryOn=0
sdOn=0
buzzerOn=0
buzzerPort=12
buzzerFreq=700
dbsmetre=1
gainLNA=0
#-------------------------------#
# Spectrum display settings
#-------------------------------#
@@ -69,8 +68,8 @@ marker=1
#-------------------------------#
# APRS settings
#-------------------------------#
call=FRS2013
passcode=26035
call=NOCALL
passcode=123456
#-------------------------------#
# Sonde specific settings: bandwidth
# valid values: 3100, 3900, 5200, 6300, 7800, 10400, 12500,
@@ -90,7 +89,7 @@ dfm.rxbw=10400
# local use only, do not feed to public services
# data not sanitized / quality checked, outliers not filtered out
axudp.active=1
axudp.host=fra1od.fr.to
axudp.host=monurl.fr
axudp.port=14580
axudp.symbol=/O
axudp.highrate=1
+13 -6
View File
@@ -27,7 +27,6 @@
<button class="tablinks fa fa-gears" onclick="selTab(event,'Config'); w3_close()"> Config</button><br>
<button class="tablinks fa fa-sliders" onclick="selTab(event,'Control'); w3_close()"> Control</button><br>
<button class="tablinks fa fa-download" onclick="selTab(event,'Update'); w3_close()"> Update</button><br>
<button class="tablinks fa fa-download" onclick="selTab(event,'Telemetry'); w3_close()"> Telemetry</button><br>
<button class="tablinks fa fa-support" onclick="selTab(event,'About'); w3_close()"> About</button><br><br><br><br>
</nav>
@@ -49,7 +48,17 @@
<div id="SondeMap" class="tabcontent" data-src="sondemap.html">
<iframe src="sondemap.html" style="border:none;" width="98%%" height="98%%"></iframe>
</div>
<!--
<div id="SondeMap" class="tabcontent" data-src="http://wx.dl2mf.de/#?">
<iframe src="http://wx.dl2mf.de/" style="border:none;" width="98%%" height="98%%"></iframe>
</div>
<div id="SondeMap2" class="tabcontent" data-src="https://radiosondy.info/">
<iframe src="https://radiosondy.info/" style="border:none;" width="98%%" height="98%%"></iframe>
</div>
<div id="SondeMap3" class="tabcontent" data-src="https://tracker.sondehub.org/?sondehub=1#!mt=osm&mz=8&qm=6_hours&mc=43.76665,6.24011&f=none&q=RS_*;*chase">
<iframe src="https://tracker.sondehub.org/?sondehub=1#!mt=osm&mz=8&qm=6_hours&mc=43.76665,6.24011&f=none&q=RS_*;*chase" style="border:none;" width="98%%" height="98%%"></iframe>
</div>
-->
<div id="Config" class="tabcontent">
<h3>Configuration</h3>
<iframe src="config.html" style="border:none;" width="100%%" height="100%%"></iframe>
@@ -64,10 +73,7 @@
<h3>Update</h3>
<iframe src="update.html" style="border:none;" width="100%%" height="100%%"></iframe>
</div>
<div id="Telemetry" class="tabcontent">
<h3>Telemetry</h3>
<button onclick="javascript:window.open('/download','_self');">Telemetry</button>
</div>
<div id="About" class="tabcontent">
<h3>About</h3>
%VERSION_NAME%<br>
@@ -178,3 +184,4 @@ showDivs(1);
</script>
</body>
</html>
+2 -4
View File
@@ -1,6 +1,4 @@
Radiosonde
Radiosonde
Terreandro
terrexavier
TERREWIFI
terrexavier
VotreSSID
votrepass
+19 -18
View File
@@ -213,6 +213,25 @@ timeaction=#,#,#
7,4=gD
7,11=gI°
############
# Boussole Oled
@BOUSSOLE
timer=-1,-1,-1
key1action=+,0,F,W
key2action=>,#,#,#
timeaction=#,#,#
0,0=g0
0,10=a
1,10=h
2,9=v
3,10=gC
3,13=gB
4,9=gD
5,11=gI°
6,9=xEl:
6,11=gE
7,9=t
############
@BatteryOLED
timer=-1,-1,-1
@@ -228,21 +247,3 @@ fonts=0,1
6,0=xPower:
6,7=bPmW
############
# Boussole Oled
@Boussole
timer=-1,0,0
key1action=D,#,F,W
key2action=#,#,#,#
timeaction=#,D,+
0,0=g0
0,10=a
1,10=h
2,9=v
3,10=gC
3,13=gB
4,9=gD
5,11=gI°
6,9=xEl:
6,11=gE
7,9=t
+3 -3
View File
@@ -3,8 +3,8 @@
<link rel=\"stylesheet\" type=\"text/css\" href=\"style.css\">
</head>
<body>
<button class="tablinks" onclick="javascript:window.open('http://wx.dl2mf.de/','_blank')"> Sonde Map</button><br><br>
<button class="tablinks" onclick="javascript:window.open('http://radiosondy.info/','_self')"> RadioSondy</button><br><br>
<button class="tablinks" onclick="javascript:window.open('http://tracker.sondehub.org/','_blank')"> SondeHub</button><br><br>
<button class="tablinks" onclick="javascript:window.open('http://wx.dl2mf.de/','_self')"> Sonde Map</button><br><br>
<button class="tablinks" onclick="javascript:window.open('https://radiosondy.info/','_self')"> RadioSony</button><br><br>
<button class="tablinks" onclick="javascript:window.open('https://tracker.sondehub.org/?sondehub=1#!mt=osm&mz=8&qm=6_hours&mc=43.76665,6.24011&f=none&q=RS_*;*chase','_self')"> SondeHub</button><br><br>
</body>
</html>
+3 -3
View File
@@ -1,4 +1,4 @@
const char *version_name = "RadioSonde";
const char *version_id = "0.8.7";
//const int SPIFFS_MAJOR=3;
//const int SPIFFS_MINOR=5;
const char *version_id = "0.8.5";
const int SPIFFS_MAJOR=2;
const int SPIFFS_MINOR=4;
+6 -50
View File
@@ -7,7 +7,6 @@
#include "Sonde.h"
#include "math.h"
int readLine(Stream &stream, char *buffer, int maxlen);
extern const char *version_name;
@@ -981,45 +980,7 @@ void Display::drawSite(DispEntry *de) {
if(de->extra[0]) strcat(buf, de->extra+1);
drawString(de, buf);
}
void Telemetry() {
if (sonde.config.telemetryOn==1) {
File file = SPIFFS.open("/data.csv", "a");
if (!file) {
Serial.println("There was an error opening the file for writing");
return;
} else {
int dbmetre=sonde.si()->rssi/2;
String smetre ="";
if (dbmetre>138) smetre="S0";
if ((dbmetre<137)&&(dbmetre>122)) smetre="S1";
if ((dbmetre<121)&&(dbmetre>116)) smetre="S2";
if ((dbmetre<115)&&(dbmetre>108)) smetre="S3";
if ((dbmetre<109)&&(dbmetre>104)) smetre="S4";
if ((dbmetre<103)&&(dbmetre>98)) smetre="S5";
if ((dbmetre<97)&&(dbmetre>92)) smetre="S6";
if ((dbmetre<91)&&(dbmetre>86)) smetre="S7";
if ((dbmetre<85)&&(dbmetre>80)) smetre="S8";
if ((dbmetre<79)&&(dbmetre>74)) smetre="S9";
if ((dbmetre<73)&&(dbmetre>64)) smetre="S9+10";
if ((dbmetre<63)&&(dbmetre>54)) smetre="S9+20";
if ((dbmetre<53)&&(dbmetre>44)) smetre="S9+30";
if ((dbmetre<43)&&(dbmetre>34)) smetre="S9+40";
if ((dbmetre<33)&&(dbmetre>24)) smetre="S9+50";
if ((dbmetre<23)&&(dbmetre>14)) smetre="S9+60";
if ((dbmetre<13)&&(dbmetre>0)) smetre="S9+70";
String telemetry = telemetry + sonde.si()->id + ";" + sonde.si()->ser + ";" + sondeTypeStr[sonde.si()->type] + ";" + sonde.si()->freq + "Mhz;" + sonde.si()->lat + "; "+ sonde.si()->lon + ";" + sonde.si()->alt + "m;" + sonde.config.gps_lat + ";" + sonde.config.gps_lon +";" + sonde.config.gps_alt + ";" + sonde.si()->vs + "m/s;" + sonde.si()->hs + "m/s;" + ";" + sonde.si()->dir + "°;" + sonde.si()->launchsite + ";" + sonde.si()->rssi/2 + ";" + smetre + ";" + *sonde.si()->rxStat + ";" + sonde.si()->afc*0.001 + ";" + sonde.si()->validPos + "\n";
if (file.print(telemetry+"\n")) {
Serial.println("File was written");
} else {
Serial.println("File write failed");
}
}
file.close();
}
void Display::drawTelemetry(DispEntry *de) {
}
void Display::drawKilltimer(DispEntry *de) {
@@ -1129,24 +1090,23 @@ static int tmpc=0;
Serial.printf("\nGPS data: valid%d GPS at %f,%f (alt=%d,cog=%d); sonde at dist=%d, dir=%d rel.bear=%d\n",gpsValid?1:0,
gpsLat, gpsLon, gpsAlt, gpsCourse, gpsDist, gpsDir, gpsBear);
}
void Display::calcVbat() {
//VBat %
float vbat,r,Dmax, Dact;
float ADC_PIN = 35;
float vbatmax=atof(sonde.config.vbatmax), vbatmin=atof(sonde.config.vbatmin);
r = analogRead(ADC_PIN);
vbat = r * (3.30 / 4094.00); //convert the value to a true voltage.
//Serial.printf("\nVbatMAX= %1.2fV",vbatmax);
//Serial.printf("\nVbatMIN= %1.2fV",vbatmin);
Serial.printf("\nVbatMAX= %1.2fV",vbatmax);
Serial.printf("\nVbatMIN= %1.2fV",vbatmin);
Dmax = vbatmax - vbatmin;
Dact = vbat - vbatmin;
vbat = (Dact / Dmax)*100;
Serial.printf("\nVbat:%3.0f\%\n",vbat);
sonde.si()->vbat=vbat;
}
void Display::drawGPS(DispEntry *de) {
//if(sonde.config.gps_rxd<0) return;
rdis->setFont(de->fmt);
switch(de->extra[0]) {
case 'W':
@@ -1184,7 +1144,7 @@ void Display::drawGPS(DispEntry *de) {
if( (sonde.si()->validPos&0x03)!=0x03 ) {
snprintf(buf, 16, "no pos ");
if(de->extra && *de->extra=='5') buf[5]=0;
} else if((!disp.gpsValid)&&(disp.gpsLat!=0)) {
} else if((!disp.gpsValid)||(disp.gpsLat!=0)&&(disp.gpsLon!=0)) {
snprintf(buf, 16, "no gps ");
if(de->extra && *de->extra=='5') buf[5]=0;
} else {
@@ -1567,7 +1527,6 @@ void Display::updateDisplayPos() {
if(di->func != disp.drawLat && di->func != disp.drawLon) continue;
di->func(di);
}
}
void Display::updateDisplayPos2() {
for(DispEntry *di=layout->de; di->func != NULL; di++) {
@@ -1623,12 +1582,9 @@ void Display::updateDisplayIP() {
void Display::updateDisplay() {
calcGPS();
calcVbat();
Telemetry();
for(DispEntry *di=layout->de; di->func != NULL; di++) {
di->func(di);
}
}
Display disp = Display();
-1
View File
@@ -85,7 +85,6 @@ private:
static void circ(int x, int y);
static int countEntries(File f);
void calcGPS();
void calcVbat();
boolean gpsValid;
float gpsLat, gpsLon;
int gpsAlt;
+17 -10
View File
@@ -10,6 +10,14 @@
#include "Display.h"
#include <Wire.h>
#define SDCARD
#ifdef SDCARD
#include "sd.h"
#endif
int snOn=0;
extern SX1278FSK sx1278;
RXTask rxtask = { -1, -1, -1, 0xFFFF, 0 };
@@ -150,13 +158,12 @@ void Sonde::defaultConfig() {
}
//
config.noisefloor = -125;
config.gainLNA=0;
strcpy(config.call,"NOCALL");
strcpy(config.passcode, "---");
strcpy(config.mdnsname, "radiosonde");
strcpy(config.vbatmax,"1.84");
strcpy(config.vbatmin,"1.64");
config.telemetryOn=0;
config.sdOn=0;
config.buzzerOn=0;
config.buzzerFreq=700;
config.buzzerPort=12;
@@ -208,8 +215,6 @@ void Sonde::setConfig(const char *cfg) {
if(strcmp(cfg,"noisefloor")==0) {
config.noisefloor = atoi(val);
if(config.noisefloor==0) config.noisefloor=-130;
} else if(strcmp(cfg,"gainLNA")==0) {
config.gainLNA = atoi(val);
} else if(strcmp(cfg,"call")==0) {
strncpy(config.call, val, 9);
config.call[9]=0;
@@ -264,8 +269,8 @@ void Sonde::setConfig(const char *cfg) {
strncpy(config.vbatmax,val,5);
} else if(strcmp(cfg,"vbatmin")==0) {
strncpy(config.vbatmin,val,5);
} else if(strcmp(cfg,"telemetryOn")==0) {
config.telemetryOn=atoi(val);
} else if(strcmp(cfg,"sdOn")==0) {
config.sdOn=atoi(val);
} else if(strcmp(cfg,"buzzerOn")==0) {
config.buzzerOn=atoi(val);
} else if(strcmp(cfg,"buzzerPort")==0) {
@@ -461,9 +466,7 @@ void Sonde::receive() {
// state information for RX_TIMER / NORX_TIMER events
if(res==0) { // RX OK
flashLed(700);
if(sonde.config.buzzerOn==1) {
buzzerLed(500);
}
if(sonde.config.buzzerOn==1) buzzerLed(500);
if(si->lastState != 1) {
si->rxStart = millis();
si->lastState = 1;
@@ -508,7 +511,11 @@ void Sonde::receive() {
Serial.printf("receive Result is %04x\n", res);
// let waitRXcomplete resume...
rxtask.receiveResult = res;
#ifdef SDCARD
if (sonde.config.sdOn==1){
sdwrite();
}
#endif
}
// return (action<<8) | (rxresult)
+3 -3
View File
@@ -178,11 +178,10 @@ typedef struct st_rdzconfig {
int maxsonde; // number of max sonde in scan (range=1-99)
int norx_timeout; // Time after which rx mode switches to scan mode (without rx signal)
int noisefloor; // for spectrum display
int gainLNA;
char mdnsname[15]; // mDNS-Name, defaults to radiosonde
char mdnsname[15]; // mDNS-Name, defaults to rdzsonde
char vbatmax[5]; // Vbat maxi when bat charged
char vbatmin[5]; // Vbat minimum discharged
int telemetryOn; // Active Save information telemetry
int sdOn; // Active SDCard
int buzzerPort; // Buzzer port
int buzzerFreq; // Buzzer Frequency
int buzzerOn; // Buzzer On
@@ -263,3 +262,4 @@ public:
extern Sonde sonde;
#endif
-124
View File
@@ -1,124 +0,0 @@
#include "FS.h"
#include <SPIFFS.h>
#include <WiFi.h>
//Write data web
//Fonction
void writedataweb(){
String updateHost = "xavier.debert.free.fr";
String updateDataWeb = "/RS/dataweb/index.html.txt";
String *updateData = &updateDataWeb;
String dispHost = updateHost.substring(0, 14);
//disp.rdis->drawString(2, 0, dispHost.c_str());
Serial.println("Connecting to: " + updateHost);
// Connect to Update host
if (client.connect(updateHost.c_str(), updatePort)) {
// Connection succeeded, fecthing the bin
Serial.println("Fetching index.html: " + String(*updateData));
// Get the contents of the bin file
client.print(String("GET ") + *updateData + " HTTP/1.1\r\n" +
"Host: " + updateHost + "\r\n" +
"Cache-Control: no-cache\r\n" +
"Connection: close\r\n\r\n");
// Check what is being sent
// Serial.print(String("GET ") + bin + " HTTP/1.1\r\n" +
// "Host: " + host + "\r\n" +
// "Cache-Control: no-cache\r\n" +
// "Connection: close\r\n\r\n");
unsigned long timeout = millis();
while (client.available() == 0) {
if (millis() - timeout > 5000) {
Serial.println("Client Timeout !");
client.stop();
return;
}
}
// Once the response is available,
// check stuff
/*
Response Structure
HTTP/1.1 200 OK
x-amz-id-2: NVKxnU1aIQMmpGKhSwpCBh8y2JPbak18QLIfE+OiUDOos+7UftZKjtCFqrwsGOZRN5Zee0jpTd0=
x-amz-request-id: 2D56B47560B764EC
Date: Wed, 14 Jun 2017 03:33:59 GMT
Last-Modified: Fri, 02 Jun 2017 14:50:11 GMT
ETag: "d2afebbaaebc38cd669ce36727152af9"
Accept-Ranges: bytes
Content-Type: application/octet-stream
Content-Length: 357280
Server: AmazonS3
{{BIN FILE CONTENTS}}
*/
while (client.available()) {
// read line till /n
String line = client.readStringUntil('\n');
// remove space, to check if the line is end of headers
line.trim();
// if the the line is empty,
// this is end of headers
// break the while and feed the
// remaining `client` to the
// Update.writeStream();
if (!line.length()) {
//headers ended
break; // and get the OTA started
}
// Check if the HTTP Response is 200
// else break and Exit Update
if (line.startsWith("HTTP/1.1")) {
if (line.indexOf("200") < 0) {
Serial.println("Got a non 200 status code from server. error.");
break;
}
}
// extract headers here
// Start with content length
if (line.startsWith("Content-Length: ")) {
contentLength = atoi((getHeaderValue(line, "Content-Length: ")).c_str());
Serial.println("Got " + String(contentLength) + " bytes from server");
}
// Next, the content type
if (line.startsWith("Content-Type: ")) {
String contentType = getHeaderValue(line, "Content-Type: ");
Serial.println("Got " + contentType + " payload.");
if (contentType == "application/text") {
isValidContentType = true;
}
}
}
} else {
// Connect to updateHost failed
// May be try?
// Probably a choppy network?
Serial.println("Connection to " + String(updateHost) + " failed. Please check your setup");
// retry??
// execOTA();
}
/*
Serial.printf("\nDataWeb On\n");
//open file for appending new blank line to EOF.
File f = SPIFFS.open("/data.html", "w");
f.println("<html><body>TEST de DATAWeb1</body></html>");
f.close();
*/
}
+179
View File
@@ -0,0 +1,179 @@
#include "FS.h"
#include "SD_MMC.h"
//Write data RadioSonde on SD
//Fonction de gestion SD
void listDir(fs::FS &fs, const char * dirname, uint8_t levels){
Serial.printf("Listing directory: %s\n", dirname);
File root = fs.open(dirname);
if(!root){
Serial.println("Failed to open directory");
return;
}
if(!root.isDirectory()){
Serial.println("Not a directory");
return;
}
File file = root.openNextFile();
while(file){
if(file.isDirectory()){
Serial.print(" DIR : ");
Serial.println(file.name());
if(levels){
listDir(fs, file.name(), levels -1);
}
} else {
Serial.print(" FILE: ");
Serial.print(file.name());
Serial.print(" SIZE: ");
Serial.println(file.size());
}
file = root.openNextFile();
}
}
void createDir(fs::FS &fs, const char * path){
Serial.printf("Creating Dir: %s\n", path);
if(fs.mkdir(path)){
Serial.println("Dir created");
} else {
Serial.println("mkdir failed");
}
}
void readFile(fs::FS &fs, const char * path){
Serial.printf("Reading file: %s\n", path);
File file = fs.open(path);
if(!file){
Serial.println("Failed to open file for reading");
return;
}
Serial.print("Read from file: ");
while(file.available()){
Serial.write(file.read());
}
}
void appendFile(fs::FS &fs, const char * path, const char * message){
Serial.printf("Appending to file: %s\n", path);
File file = fs.open(path, FILE_APPEND);
if(!file){
Serial.println("Failed to open file for appending");
return;
}
if(file.print(message)){
Serial.println("Message appended");
} else {
Serial.println("Append failed");
}
}
void writeFile(fs::FS &fs, const char * path, const char * message){
Serial.printf("Writing file: %s\n", path);
File file = fs.open(path, FILE_WRITE);
if(!file){
Serial.println("Failed to open file for writing");
return;
}
if(file.print(message)){
Serial.println("File written");
} else {
Serial.println("Write failed");
}
}
void sdwrite()
{
Serial.print("Detect SD\n");
if(SD_MMC.begin()){
uint8_t cardType = SD_MMC.cardType();
if(cardType != CARD_NONE){
Serial.print("SD_MMC Card Type: ");
if(cardType == CARD_MMC){
Serial.println("MMC");
} else if(cardType == CARD_SD){
Serial.println("SDSC");
} else if(cardType == CARD_SDHC){
Serial.println("SDHC");
} else {
Serial.println("UNKNOWN");
}
uint64_t cardSize = SD_MMC.cardSize() / (1024 * 1024);
Serial.printf("SD_MMC Card Size: %lluMB\n", cardSize);
/*
Serial.printf("Total space: %lluMB\n", SD_MMC.totalBytes() / (1024 * 1024));
Serial.printf("Used space: %lluMB\n", SD_MMC.usedBytes() / (1024 * 1024));
*/
if (sonde.si()->validPos) {
char buff[20];
char chemin[40];
//String repertoire="/radiosonde/", name=sonde.si()->ser;
//repertoire.toCharArray(chemin, 40);
//if (!SD_MMC.exists(chemin)) {
createDir(SD_MMC, "/radiosonde/");
Serial.printf("\nWrite Rep\n");
//listDir(SD_MMC, chemin, 0);
//}
//if (name.length()>8) {
//name.concat(".csv");
//repertoire.concat(name);
//repertoire.toCharArray(chemin, 40);
writeFile(SD_MMC, "/radiosonde/sonde.csv", "");
Serial.printf("\nWrite file\n");
//if (!SD_MMC.exists(chemin)) {
appendFile(SD_MMC, "/radiosonde/sonde.csv", "RadioSonde N; Ser ; Type ; Freq ; Alt ; VSpeed ; HSpeed ; Dir ; LaunchSite ; RSSI\n");
Serial.printf("\nWrite titre\n");
//}
Serial.printf("\nWrite Data\n");
snprintf(buff, 16, "%10c", sonde.si()->id);
appendFile(SD_MMC, "/radiosonde/sonde.csv", buff);
appendFile(SD_MMC, "/radiosonde/sonde.csv", ";");
snprintf(buff, 16, "%12c", sonde.si()->ser);
appendFile(SD_MMC, "/radiosonde/sonde.csv", buff);
appendFile(SD_MMC, "/radiosonde/sonde.csv", ";");
appendFile(SD_MMC, "/radiosonde/sonde.csv", sondeTypeStr[sonde.si()->type]);
appendFile(SD_MMC, "/radiosonde/sonde.csv", ";");
snprintf(buff, 16, "%3.3fMhz", sonde.si()->freq);
appendFile(SD_MMC, "/radiosonde/sonde.csv", buff);
appendFile(SD_MMC, "/radiosonde/sonde.csv", ";");
snprintf(buff, 16, sonde.si()->alt>=1000?" %5.0fm":" %3.1fm", sonde.si()->alt);
appendFile(SD_MMC, "/radiosonde/sonde.csv", buff);
appendFile(SD_MMC, "/radiosonde/sonde.csv", ";");
snprintf(buff, 16, "%2.2fm/s", sonde.si()->vs);
appendFile(SD_MMC, "/radiosonde/sonde.csv", buff);
appendFile(SD_MMC, "/radiosonde/sonde.csv", ";");
snprintf(buff, 16, "%2.2fm/s", sonde.si()->hs);
appendFile(SD_MMC, "/radiosonde/sonde.csv", buff);
appendFile(SD_MMC, "/radiosonde/sonde.csv", ";");
snprintf(buff, 16, "%3.0f°", sonde.si()->dir);
appendFile(SD_MMC, "/radiosonde/sonde.csv", buff);
appendFile(SD_MMC, "/radiosonde/sonde.csv", ";");
snprintf(buff, 16, "%18c", sonde.si()->launchsite);
appendFile(SD_MMC, "/radiosonde/sonde.csv", buff);
appendFile(SD_MMC, "/radiosonde/sonde.csv", ";");
snprintf(buff, 16, "%d", sonde.si()->rssi);
appendFile(SD_MMC, "/radiosonde/sonde.csv", buff);
appendFile(SD_MMC, "/radiosonde/sonde.csv", "\n");
}
}
}
}
-39
View File
@@ -1,39 +0,0 @@
#include <FS.h>
#include <SPIFFS.h>
#include <SD_MMC.h> // (or SD_MMC.h)
void transfert_sd() {
if (!SD_MMC.begin()) {
Serial.println("Carte SD introuvable");
return;
}
else{
Serial.println("Carte SD détectée");
sonde.clearDisplay();
disp.rdis->drawString(0, 2, "Carte SD On");
disp.rdis->drawString(0, 4, "Transfert Data");
File sourceFile = SPIFFS.open("/data.csv", "r");
File destFile = SD_MMC.open("/data.csv","w");
static uint8_t buf[512];
while( sourceFile.read( buf, 512) ) {
destFile.write( buf, 512 );
}
destFile.close();
sourceFile.close();
}
delay(1000);
//sonde.updateDisplay();
sonde.clearDisplay();
disp.rdis->drawString(0, 2, "Sortir SD");
disp.rdis->drawString(0, 4, "Reboot 5s");
delay(5000);
ESP.restart();
}