diff --git a/include/main.h b/include/main.h index 9881f8a..a6ff8bf 100644 --- a/include/main.h +++ b/include/main.h @@ -14,7 +14,7 @@ extern char aprs_msg[128]; extern char after_tx_lock; extern unsigned char BcnInterval, WXInterval, BcnI, WXI, TelemInterval, TelemI; -extern unsigned short rx10m, tx10m, digi10m; +extern unsigned short rx10m, tx10m, digi10m, kiss10m; extern int t; extern float temperature; diff --git a/src/main.cpp b/src/main.cpp index c2a0af8..3c09231 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -39,6 +39,10 @@ #include "aprs/wx.h" #endif +#ifdef _DALLAS_AS_TELEM +#include "drivers/dallas.h" +#endif + #include "KissCommunication.h" @@ -66,7 +70,7 @@ char aprs_msg[128]; char after_tx_lock; unsigned char BcnInterval, WXInterval, BcnI = _BCN_INTERVAL - 2, WXI = _WX_INTERVAL - 1, TelemInterval, TelemI = 1; -unsigned short rx10m = 0, tx10m = 0, digi10m = 0; +unsigned short rx10m = 0, tx10m = 0, digi10m = 0, kiss10m = 0; int t = 0; float temperature; @@ -104,6 +108,9 @@ main(int argc, char* argv[]) #ifdef _METEO DallasInit(GPIOC, GPIO_Pin_6, GPIO_PinSource6); TX20Init(); +#endif +#ifdef _DALLAS_AS_TELEM + DallasInit(GPIOC, GPIO_Pin_6, GPIO_PinSource6); #endif SrlConfig(); @@ -139,10 +146,13 @@ main(int argc, char* argv[]) #ifdef _METEO temperature = SensorBringTemperature(); td = DallasQuery(); +#ifdef _DBG_TRACE trace_printf("temperatura DS: %d\r\n", (int)td); +#endif pressure = (float)SensorBringPressure(); +#ifdef _DBG_TRACE trace_printf("cisnienie MS: %d\r\n", (int)pressure); - +#endif #endif GPIO_ResetBits(GPIOC, GPIO_Pin_8 | GPIO_Pin_9); @@ -176,7 +186,10 @@ main(int argc, char* argv[]) } if (srlIdle == 1) { - ParseReceivedKISS(srlRXData, &ax25, &a); + short res = ParseReceivedKISS(srlRXData, &ax25, &a); + if (res == 0) + kiss10m++; + SrlReceiveData(120, FEND, FEND, 0, 0, 0); } diff --git a/system/src/aprs/telemetry.c b/system/src/aprs/telemetry.c index a17cb72..80f0f74 100644 --- a/system/src/aprs/telemetry.c +++ b/system/src/aprs/telemetry.c @@ -10,13 +10,50 @@ #include "station_config.h" #include "TimerConfig.h" +#ifdef _DALLAS_AS_TELEM +#include "drivers/dallas.h" +#endif + volatile int jj = 0; extern volatile int delay_5us; void SendSimpleTelemetry(char num) { - aprs_msg_len = sprintf(aprs_msg, "T#%03d,%03d,%03d,%03d,000,000,00000000", t++, rx10m, tx10m, digi10m); + float temperature = 0.0f; + uint8_t scaledTemperature = 0; +#ifdef _DALLAS_AS_TELEM + char qf = '1', degr = '0', nav = '0'; + + temperature = DallasQuery(); + + if (temperature == -128.0f) { + qf = '0'; + nav = '1'; + } + else if (temperature < -25.0f) { + temperature = -25.0f; + qf = '0'; + degr = '1'; + } + else if (temperature > 38.75f) { + temperature = 38.75f; + qf = '0'; + degr = '1'; + } + else { + ; + } + + scaledTemperature = (uint8_t)((temperature + 25.0f) * 4.0f); +#endif + +#ifdef _DALLAS_AS_TELEM + aprs_msg_len = sprintf(aprs_msg, "T#%03d,%03d,%03d,%03d,%03d,%03d,%c%c%c00000", t++, rx10m, tx10m, digi10m, kiss10m, scaledTemperature, qf, degr, nav); +#else + aprs_msg_len = sprintf(aprs_msg, "T#%03d,%03d,%03d,%03d,%03d,%03d,00100000", t++, rx10m, tx10m, digi10m, kiss10m, scaledTemperature); +#endif + if (t > 999) t = 0; aprs_msg[aprs_msg_len] = 0; @@ -31,19 +68,19 @@ void SendSimpleTelemetry(char num) { // .. end delay afsk_txStart(&a); - rx10m = 0, tx10m = 0, digi10m = 0; + rx10m = 0, tx10m = 0, digi10m = 0, kiss10m = 0; if (num > 0) { while (a.sending == 1); for(jj = 0; jj <= 0x1F5FFF; jj++); #if (_SSID == 0) - aprs_msg_len = sprintf(aprs_msg, ":%s :PARM.Rx10min,Tx10min,Digi10min,N,N,N,N,N,N,N,N", _CALL); + aprs_msg_len = sprintf(aprs_msg, ":%s :PARM.Rx10min,Tx10min,Digi10min,HostTx10m,Tempre,DS_QF_FULL,DS_QF_DEGRAD,DS_QF_NAVBLE,N,N,N", _CALL); #endif #if (_SSID > 0 && _SSID <= 9) - aprs_msg_len = sprintf(aprs_msg, ":%s-%d :PARM.Rx10min,Tx10min,Digi10min,N,N,N,N,N,N,N,N", _CALL, _SSID); + aprs_msg_len = sprintf(aprs_msg, ":%s-%d :PARM.Rx10min,Tx10min,Digi10min,HostTx10m,Tempre,DS_QF_FULL,DS_QF_DEGRAD,DS_QF_NAVBLE,N,N,N", _CALL, _SSID); #endif #if (_SSID > 9 && _SSID <= 15) - aprs_msg_len = sprintf(aprs_msg, ":%s-%d:PARM.Rx10min,Tx10min,Digi10min,N,N,N,N,N,N,N,N", _CALL, _SSID); + aprs_msg_len = sprintf(aprs_msg, ":%s-%d:PARM.Rx10min,Tx10min,Digi10min,HostTx10m,Tempre,DS_QF_FULL,DS_QF_DEGRADA,DS_QF_NAVBLE,N,N,N", _CALL, _SSID); #endif aprs_msg[aprs_msg_len] = 0; ax25_sendVia(&ax25, path, path_len, aprs_msg, aprs_msg_len); @@ -54,13 +91,13 @@ void SendSimpleTelemetry(char num) { for(jj = 0; jj <= 0x1F5FFF; jj++); #if (_SSID == 0) - aprs_msg_len = sprintf(aprs_msg, ":%s :EQNS.0,1,0,0,1,0,0,1,0,0,1,0,0,1,0", _CALL); + aprs_msg_len = sprintf(aprs_msg, ":%s :EQNS.0,1,0,0,1,0,0,1,0,0,1,0,0,0.25,-25", _CALL); #endif #if (_SSID > 0 && _SSID <= 9) - aprs_msg_len = sprintf(aprs_msg, ":%s-%d :EQNS.0,1,0,0,1,0,0,1,0,0,1,0,0,1,0", _CALL, _SSID); + aprs_msg_len = sprintf(aprs_msg, ":%s-%d :EQNS.0,1,0,0,1,0,0,1,0,0,1,0,0,0.25,-25", _CALL, _SSID); #endif #if (_SSID > 9 && _SSID <= 15) - aprs_msg_len = sprintf(aprs_msg, ":%s-%d:EQNS.0,1,0,0,1,0,0,1,0,0,1,0,0,1,0", _CALL, _SSID); + aprs_msg_len = sprintf(aprs_msg, ":%s-%d:EQNS.0,1,0,0,1,0,0,1,0,0,1,0,0,0.25,-25", _CALL, _SSID); #endif aprs_msg[aprs_msg_len] = 0; ax25_sendVia(&ax25, path, path_len, aprs_msg, aprs_msg_len); @@ -71,13 +108,13 @@ void SendSimpleTelemetry(char num) { for(jj = 0; jj <= 0x1F5FFF; jj++); #if (_SSID == 0) - aprs_msg_len = sprintf(aprs_msg, ":%s :UNIT.Pkt,Pkt,Pkt,N,N,N,N,N,N,N,N", _CALL); + aprs_msg_len = sprintf(aprs_msg, ":%s :UNIT.Pkt,Pkt,Pkt,Pkt,DegC,Hi,Hi,Hi,N,N,N", _CALL); #endif #if (_SSID > 0 && _SSID <= 9) - aprs_msg_len = sprintf(aprs_msg, ":%s-%d :UNIT.Pkt,Pkt,Pkt,N,N,N,N,N,N,N,N", _CALL, _SSID); + aprs_msg_len = sprintf(aprs_msg, ":%s-%d :UNIT.Pkt,Pkt,Pkt,Pkt,DegC,Hi,Hi,Hi,N,N,N", _CALL, _SSID); #endif #if (_SSID > 9 && _SSID <= 15) - aprs_msg_len = sprintf(aprs_msg, ":%s-%d:UNIT.Pkt,Pkt,Pkt,N,N,N,N,N,N,N,N", _CALL, _SSID); + aprs_msg_len = sprintf(aprs_msg, ":%s-%d:UNIT.Pkt,Pkt,Pkt,Pkt,DegC,Hi,Hi,Hi,N,N,N", _CALL, _SSID); #endif aprs_msg[aprs_msg_len] = 0; ax25_sendVia(&ax25, path, path_len, aprs_msg, aprs_msg_len); diff --git a/system/src/drivers/dallas.c b/system/src/drivers/dallas.c index b682656..1a41cfa 100644 --- a/system/src/drivers/dallas.c +++ b/system/src/drivers/dallas.c @@ -193,7 +193,7 @@ float __attribute__((optimize("O0"))) DallasQuery(void) { temperature = -1.0f * (128.0f - (float)temp1 - (float)temp2 * 0.0625f); } else { - return 0.0f; + return -128.0f; } return temperature;