remove string in trace call

so as to decrease sketch size
This commit is contained in:
Florian committed 2018-05-16 21:56:29 +02:00
1 parent 645c733910
commit c0fca71619
15 files changed
+91 -72

No files matched your search

+30 -11
View File
@@ -191,7 +191,7 @@ boolean reconnect() {
} else {
failure_number ++; // we count the failure
trc(F("failed, rc="));
trc(String(client.state()));
trc(client.state());
trc(F("try again in 5s"));
// Wait 5 seconds before retrying
delay(5000);
@@ -300,7 +300,7 @@ void setup()
#else
long port;
port = strtol(mqtt_port,NULL,10);
trc(String(port));
trc(port);
#ifdef mqtt_server_name // if name is defined we define the mqtt server by its name
trc(F("Connecting to MQTT with mqtt hostname"));
IPAddress mqtt_server_ip;
@@ -310,7 +310,7 @@ void setup()
#else // if not by its IP adress
trc(F("Connecting to MQTT by IP adress"));
client.setServer(mqtt_server, port);
trc(String(mqtt_server));
trc(mqtt_server);
#endif
#endif
@@ -525,14 +525,14 @@ void setup_ethernet() {
if (n == 0) {
trc(F("no services found"));
}else {
trc(String(n));
trc(n);
trc(" service(s) found");
for (int i=0; i < n; ++i) {
// Print details for each service found
trc(String(i + 1));
trc(String(MDNS.hostname(i)));
trc(i + 1);
trc(MDNS.hostname(i));
trc(MDNS.IP(i).toString());
trc(String(MDNS.port(i)));
trc(MDNS.port(i));
}
if (n==1) {
trc(F("One MQTT server found setting parameters"));
@@ -647,7 +647,7 @@ void loop()
trc("Remaining memory");
uint32_t freeMem;
freeMem = ESP.getFreeHeap();
trc(String(freeMem));
trc(freeMem);
}
#endif
}
@@ -658,12 +658,12 @@ void storeValue(long MQTTvalue){
// find oldest value of the buffer
int o = getMin();
trc(F("Min ind: "));
trc(String(o));
trc(o);
// replace it by the new one
ReceivedSignal[o][0] = MQTTvalue;
ReceivedSignal[o][1] = now;
trc(F("store code :"));
trc(String(ReceivedSignal[o][0])+"/"+String(ReceivedSignal[o][1]));
trc(ReceivedSignal[o][0]+"/"+ReceivedSignal[o][1]);
trc(F("Col: val/timestamp"));
for (int i = 0; i < array_size; i++)
{
@@ -783,7 +783,26 @@ void trc(int msg){
}
}
void trc(uint32_t msg){
void trc(unsigned int msg){
if (TRACE) {
Serial.println(msg);
}
}
void trc(long msg){
if (TRACE) {
Serial.println(msg);
}
}
void trc(unsigned long msg){
if (TRACE) {
Serial.println(msg);
}
}
void trc(double msg){
if (TRACE) {
Serial.println(msg);
}
+3 -3
View File
@@ -30,7 +30,7 @@
void setupONOFF(){
trc(F("ACTUATOR_ONOFF_PIN"));
trc(String(ACTUATOR_ONOFF_PIN));
trc(ACTUATOR_ONOFF_PIN);
//init
pinMode(ACTUATOR_ONOFF_PIN, OUTPUT);
trc(F("Set to OFF"));
@@ -46,12 +46,12 @@ void MQTTtoONOFF(char * topicOri, char * datacallback){
if ((topic == subjectMQTTtoONOFF)){
trc(F("MQTTtoONOFF"));
trc(String(boolSWITCHTYPE));
trc(boolSWITCHTYPE);
digitalWrite(ACTUATOR_ONOFF_PIN, boolSWITCHTYPE);
boolean result = client.publish(subjectGTWONOFFtoMQTT, datacallback);// we acknowledge the sending by publishing the value to an acknowledgement topic
if (result){
trc(F("MQTTtoONOFF ack pub."));
trc(String(datacallback));
trc(datacallback);
}
}
}
+3 -3
View File
@@ -39,9 +39,9 @@ SMSmessage sms;
void setup2G(){
trc(F("_2G_TX_PIN "));
trc(String(_2G_TX_PIN));
trc(_2G_TX_PIN);
trc(F("_2G_RX_PIN "));
trc(String(_2G_RX_PIN));
trc(_2G_RX_PIN);
setupGSM(false);
trc(F("Zgateway2G setup done "));
}
@@ -125,7 +125,7 @@ void MQTTto2G(char * topicOri, char * datacallback) {
boolean result = client.publish(subjectGTW2GtoMQTT, datacallback);// we acknowledge the sending by publishing the value to an acknowledgement topic, for the moment even if it is a signal repetition we acknowledge also
if (result){
trc(F("MQTTto2G ack pub."));
trc(String(data));
trc(data);
}
}
+4 -4
View File
@@ -76,7 +76,7 @@ Thanks to wolass https://github.com/wolass for suggesting me HM 10 and dinosd ht
if (advertisedDevice.haveTXPower()){
trc(F("Get TXPower "));
int8_t TXPower = advertisedDevice.getTXPower();
trc(String(TXPower));
trc(TXPower);
char cTXPower[5];
sprintf(cTXPower, "%d", TXPower);
client.publish((char *)(mactopic + "/tx").c_str(),cTXPower);
@@ -334,7 +334,7 @@ boolean process_data(int offset, char * rest_data, char * mac_adress){
case '3' :
case '4' :
data_length = ((rest_data[51 + offset] - '0') * 2)+1;
trc(String(data_length));
trc(data_length);
break;
default:
trc("can't read data_length");
@@ -349,7 +349,7 @@ boolean process_data(int offset, char * rest_data, char * mac_adress){
// reverse data order
revert_hex_data(rev_data, data, data_length);
double value = strtol(data, NULL, 16);
trc(String(value));
trc(value);
char val[12];
String mactopic(mac_adress);
mactopic = subjectBTtoMQTT + mactopic;
@@ -383,7 +383,7 @@ boolean process_data(int offset, char * rest_data, char * mac_adress){
return false;
}
client.publish((char *)mactopic.c_str(),val);;
trc(String(val));
trc(val);
return true;
}
+5 -5
View File
@@ -50,9 +50,9 @@ void setupIR()
irrecv.enableIRIn(); // Start the receiver
trc(F("IR_EMITTER_PIN "));
trc(String(IR_EMITTER_PIN));
trc(IR_EMITTER_PIN);
trc(F("IR_RECEIVER_PIN "));
trc(String(IR_RECEIVER_PIN));
trc(IR_RECEIVER_PIN);
trc(F("ZgatewayIR setup done "));
}
@@ -129,7 +129,7 @@ void MQTTtoIR(char * topicOri, char * datacallback) {
boolean signalSent = false;
uint64_t data = 0;
String strcallback = String(datacallback);
trc(String(datacallback));
trc(datacallback);
int s = strcallback.length();
//number of "," value count
int count = 0;
@@ -201,7 +201,7 @@ void MQTTtoIR(char * topicOri, char * datacallback) {
pos = pos + +strlen(IRbitsKey);
valueBITS = (topic.substring(pos,pos + 2)).toInt();
trc(F("Bits nb:"));
trc(String(valueBITS));
trc(valueBITS);
}
//We look into the subject to see if a special repeat number is defined
int valueRPT = 0;
@@ -210,7 +210,7 @@ void MQTTtoIR(char * topicOri, char * datacallback) {
pos2 = pos2 + strlen(IRRptKey);
valueRPT = (topic.substring(pos2,pos2 + 1)).toInt();
trc(F("IR repeat:"));
trc(String(valueRPT));
trc(valueRPT);
}
#ifdef ESP8266 // send coolix not available for arduino IRRemote library
+10 -10
View File
@@ -36,11 +36,11 @@ void setupRF(){
//RF init parameters
mySwitch.enableTransmit(RF_EMITTER_PIN);
trc(F("RF_EMITTER_PIN "));
trc(String(RF_EMITTER_PIN));
trc(RF_EMITTER_PIN);
mySwitch.setRepeatTransmit(RF_EMITTER_REPEAT);
mySwitch.enableReceive(RF_RECEIVER_PIN);
trc(F("RF_RECEIVER_PIN "));
trc(String(RF_RECEIVER_PIN));
trc(RF_RECEIVER_PIN);
trc(F("ZgatewayRF setup done "));
}
@@ -96,7 +96,7 @@ void MQTTtoRF(char * topicOri, char * datacallback) {
pos = pos + +strlen(RFprotocolKey);
valuePRT = (topic.substring(pos,pos + 1)).toInt();
trc(F("RF Protocol:"));
trc(String(valuePRT));
trc(valuePRT);
}
//We look into the subject to see if a special RF pulselength is defined
int pos2 = topic.lastIndexOf(RFpulselengthKey);
@@ -104,14 +104,14 @@ void MQTTtoRF(char * topicOri, char * datacallback) {
pos2 = pos2 + strlen(RFpulselengthKey);
valuePLSL = (topic.substring(pos2,pos2 + 3)).toInt();
trc(F("RF Pulse Lgth:"));
trc(String(valuePLSL));
trc(valuePLSL);
}
int pos3 = topic.lastIndexOf(RFbitsKey);
if (pos3 != -1){
pos3 = pos3 + strlen(RFbitsKey);
valueBITS = (topic.substring(pos3,pos3 + 2)).toInt();
trc(F("Bits nb:"));
trc(String(valueBITS));
trc(valueBITS);
}
if ((topic == subjectMQTTtoRF) && (valuePRT == 0) && (valuePLSL == 0) && (valueBITS == 0)){
@@ -127,17 +127,17 @@ void MQTTtoRF(char * topicOri, char * datacallback) {
if (valuePRT == 0) valuePRT = 1;
if (valuePLSL == 0) valuePLSL = 350;
if (valueBITS == 0) valueBITS = 24;
trc(String(valuePRT));
trc(String(valuePLSL));
trc(String(valueBITS));
trc(valuePRT);
trc(valuePLSL);
trc(valueBITS);
mySwitch.setProtocol(valuePRT,valuePLSL);
mySwitch.send(data, valueBITS);
// Acknowledgement to the GTWRF topic
boolean result = client.publish(subjectGTWRFtoMQTT, datacallback);// we acknowledge the sending by publishing the value to an acknowledgement topic, for the moment even if it is a signal repetition we acknowledge also
if (result){
trc(F("MQTTtoRF ack pub."));
trc(String(data));
};
trc(data);
}
}
}
+13 -13
View File
@@ -53,9 +53,9 @@ void setupRF2(){
#ifndef ZgatewayRF //receiving with RF2 is not compatible with ZgatewayRF
NewRemoteReceiver::init(RF_RECEIVER_PIN, 2, rf2Callback);
trc(F("RF_EMITTER_PIN "));
trc(String(RF_EMITTER_PIN));
trc(RF_EMITTER_PIN);
trc(F("RF_RECEIVER_PIN "));
trc(String(RF_RECEIVER_PIN));
trc(RF_RECEIVER_PIN);
trc(F("ZgatewayRF2 setup done "));
#endif
pinMode(RF_EMITTER_PIN, OUTPUT);
@@ -120,35 +120,35 @@ void MQTTtoRF2(char * topicOri, char * datacallback) {
pos = pos + +strlen(RF2codeKey);
valueCODE = (topic.substring(pos,pos + 8)).toInt();
trc(F("RF2 code:"));
trc(String(valueCODE));
trc(valueCODE);
}
int pos2 = topic.lastIndexOf(RF2periodKey);
if (pos2 != -1) {
pos2 = pos2 + strlen(RF2periodKey);
valuePERIOD = (topic.substring(pos2,pos2 + 3)).toInt();
trc(F("RF2 Period:"));
trc(String(valuePERIOD));
trc(valuePERIOD);
}
int pos3 = topic.lastIndexOf(RF2unitKey);
if (pos3 != -1){
pos3 = pos3 + strlen(RF2unitKey);
valueUNIT = (topic.substring(pos3, topic.indexOf("/", pos3))).toInt();
trc(F("Unit:"));
trc(String(valueUNIT));
trc(valueUNIT);
}
int pos4 = topic.lastIndexOf(RF2groupKey);
if (pos4 != -1) {
pos4 = pos4 + strlen(RF2groupKey);
valueGROUP = (topic.substring(pos4,pos4 + 1)).toInt();
trc(F("RF2 Group:"));
trc(String(valueGROUP));
trc(valueGROUP);
}
int pos5 = topic.lastIndexOf(RF2dimKey);
if (pos5 != -1) {
isDimCommand = true;
valueDIM = atoi(datacallback);
trc(F("RF2 Dim:"));
trc(String(valueDIM));
trc(valueDIM);
}
if ((topic == subjectMQTTtoRF2) || (valueCODE != 0) || (valueUNIT != -1)|| (valuePERIOD != 0)){
@@ -156,12 +156,12 @@ void MQTTtoRF2(char * topicOri, char * datacallback) {
if (valueCODE == 0) valueCODE = 8233378;
if (valueUNIT == -1) valueUNIT = 0;
if (valuePERIOD == 0) valuePERIOD = 272;
trc(String(valueCODE));
trc(String(valueUNIT));
trc(String(valuePERIOD));
trc(String(valueGROUP));
trc(String(boolSWITCHTYPE));
trc(String(valueDIM));
trc(valueCODE);
trc(valueUNIT);
trc(valuePERIOD);
trc(valueGROUP);
trc(boolSWITCHTYPE);
trc(valueDIM);
NewRemoteReceiver::disable();
trc(F("Creating transmitter"));
NewRemoteTransmitter transmitter(valueCODE, RF_EMITTER_PIN, valuePERIOD);
+2 -2
View File
@@ -129,7 +129,7 @@ void setupRFM69(void) {
freq = -1;
break;
}
trc(String(freq));
trc(freq);
size_t len = snprintf_P(RadioConfig, sizeof(RadioConfig), JSONtemplate,
freq, GC_IS_RFM69HCW, pGC->networkid, GC_POWER_LEVEL);
@@ -216,7 +216,7 @@ boolean MQTTtoRFM69(char * topicOri, char * datacallback) {
pos = pos + +strlen(RFM69receiverKey);
valueRCV = (topic.substring(pos,pos + 3)).toInt();
trc(F("RFM69 receiver ID:"));
trc(String(valueRCV));
trc(valueRCV);
}
loops = 10;
startMillis = millis();
+5 -5
View File
@@ -56,7 +56,7 @@ void MQTTtoSRFB(char * topicOri, char * datacallback) {
pos = pos + +strlen(SRFBRptKey);
valueRPT = (topic.substring(pos,pos + 1)).toInt();
trc(F("SRFB Repeat:"));
trc(String(valueRPT));
trc(valueRPT);
}
int pos2 = topic.lastIndexOf(SRFBminipulselengthKey);
@@ -64,7 +64,7 @@ void MQTTtoSRFB(char * topicOri, char * datacallback) {
pos2 = pos2 + strlen(SRFBminipulselengthKey);
valueMiniPLSL = (topic.substring(pos2,pos2 + 3)).toInt();
trc(F("RF Mini Pulse Lgth:"));
trc(String(valueMiniPLSL));
trc(valueMiniPLSL);
}
int pos3 = topic.lastIndexOf(SRFBmaxipulselengthKey);
@@ -72,7 +72,7 @@ void MQTTtoSRFB(char * topicOri, char * datacallback) {
pos3 = pos3 + strlen(SRFBmaxipulselengthKey);
valueMaxiPLSL = (topic.substring(pos3,pos3 + 2)).toInt();
trc(F("RF Maxi Pulse Lgth:"));
trc(String(valueMaxiPLSL));
trc(valueMaxiPLSL);
}
int pos4 = topic.lastIndexOf(SRFBsyncKey);
@@ -80,7 +80,7 @@ void MQTTtoSRFB(char * topicOri, char * datacallback) {
pos4 = pos4 + strlen(SRFBsyncKey);
valueSYNC = (topic.substring(pos4,pos4 + 2)).toInt();
trc(F("RF sync:"));
trc(String(valueSYNC));
trc(valueSYNC);
}
trc(F("MQTTtoSRFB prts"));
@@ -126,7 +126,7 @@ void MQTTtoSRFB(char * topicOri, char * datacallback) {
pos = pos + +strlen(SRFBRptKey);
valueRPT = (topic.substring(pos,pos + 1)).toInt();
trc(F("SRFB Repeat:"));
trc(String(valueRPT));
trc(valueRPT);
}
if (valueRPT == 0) valueRPT = 1;
+1 -1
View File
@@ -48,7 +48,7 @@ void MeasureADC(){
}else{
if(val >= persistedadc + ThresholdReadingADC || val <= persistedadc - ThresholdReadingADC){
trc(F("Sending analog value to MQTT"));
trc(String(val));
trc(val);
client.publish(ADC,String(val).c_str());
persistedadc = val;
}
+3 -3
View File
@@ -95,7 +95,7 @@ void MeasureLightIntensity()
// Generate Lux
if(Lux != persistedll || bh1750_always){
trc(F("Sending Lux to MQTT"));
trc(String(Lux));
trc(Lux);
client.publish(LUX,String(Lux).c_str());
}else{
trc(F("Same lux don't send it"));
@@ -104,7 +104,7 @@ void MeasureLightIntensity()
// Generate FtCd
if(FtCd != persistedlf || bh1750_always){
trc(F("Sending FtCd to MQTT"));
trc(String(FtCd));
trc(FtCd);
client.publish(FTCD,String(FtCd).c_str());
}else{
trc(F("Same ftcd don't send it"));
@@ -113,7 +113,7 @@ void MeasureLightIntensity()
// Generate Watts/m2
if(Wattsm2 != persistedlw || bh1750_always){
trc(F("Sending Wattsm2 to MQTT"));
trc(String(Wattsm2));
trc(Wattsm2);
client.publish(WATTSM2,String(Wattsm2).c_str());
}else{
trc(F("Same wattsm2 don't send it"));
+6 -6
View File
@@ -130,7 +130,7 @@ void MeasureTempHumAndPressure()
// Generate Temperature in degrees C
if(BmeTempC != persisted_bme_tempc || bme280_always){
trc(F("Sending Degrees C to MQTT"));
trc(String(BmeTempC));
trc(BmeTempC);
client.publish(TEMPBMEC, String(BmeTempC).c_str());
}else{
trc(F("Same Degrees C don't send it"));
@@ -139,7 +139,7 @@ void MeasureTempHumAndPressure()
// Generate Temperature in degrees F
if(BmeTempF != persisted_bme_tempf || bme280_always){
trc(F("Sending Degrees F to MQTT"));
trc(String(BmeTempF));
trc(BmeTempF);
client.publish(TEMPBMEF,String(BmeTempF).c_str());
}else{
trc(F("Same Degrees F don't send it"));
@@ -148,7 +148,7 @@ void MeasureTempHumAndPressure()
// Generate Humidity in percent
if(BmeHum != persisted_bme_hum || bme280_always){
trc(F("Sending Humidity to MQTT"));
trc(String(BmeHum));
trc(BmeHum);
client.publish(HUMBME, String(BmeHum).c_str());
}else{
trc(F("Same Humidity don't send it"));
@@ -157,7 +157,7 @@ void MeasureTempHumAndPressure()
// Generate Pressure in Pa
if(BmePa != persisted_bme_pa || bme280_always){
trc(F("Sending Pressure to MQTT"));
trc(String(BmePa));
trc(BmePa);
client.publish(PRESSBME, String(BmePa).c_str());
}else{
trc(F("Same Pressure don't send it"));
@@ -166,7 +166,7 @@ void MeasureTempHumAndPressure()
// Generate Altitude in Meter
if(BmeAltiM != persisted_bme_altim || bme280_always){
trc(F("Sending Altitude Meter to MQTT"));
trc(String(BmeAltiM));
trc(BmeAltiM);
client.publish(ALTIBMEM, String(BmeAltiM).c_str());
}else{
trc(F("Same Altitude Meter don't send it"));
@@ -175,7 +175,7 @@ void MeasureTempHumAndPressure()
// Generate Altitude in Feet
if(BmeAltiFt != persisted_bme_altift || bme280_always){
trc(F("Sending Altitude Feet to MQTT"));
trc(String(BmeAltiFt));
trc(BmeAltiFt);
client.publish(ALTIBMEFT, String(BmeAltiFt).c_str());
}else{
trc(F("Same Altitude Feet don't send it"));
+2 -2
View File
@@ -50,14 +50,14 @@ void MeasureTempAndHum(){
}else{
if(h != persistedh || dht_always){
trc(F("Sending Hum to MQTT"));
trc(String(h));
trc(h);
client.publish(HUM1,String(h).c_str());
}else{
trc(F("Same hum don't send it"));
}
if(t != persistedt || dht_always){
trc(F("Sending Temp to MQTT"));
trc(String(t));
trc(t);
client.publish(TEMP1, String(t).c_str());
}else{
trc(F("Same temp don't send it"));
+3 -3
View File
@@ -56,7 +56,7 @@ void MeasureINA226(){
// Bus Spannung, read-only, 16Bit, 0...40.96V max., LSB 1.25mV
trc(F(" Volt: "));
float volt = readRegister(0x02) * 0.00125;
trc(String(volt));
trc(volt);
trc(F(" V, Current: "));
// Seite 24: Shunt Spannung +- 81,92mV mit 16 Bit, LSB 2,5uV
int shuntvolt = readRegister(0x01);
@@ -66,10 +66,10 @@ void MeasureINA226(){
shuntvolt *= -1 ; // negativ machen
}
float current = shuntvolt * 0.0000025 / rShunt; // * LSB / R
trc(String(current));
trc(current);
trc(F(" A, Power: "));
float power=abs(volt*current);
trc(String(power));
trc(power);
trc(F(" W"));
char volt_c[7];
+1 -1
View File
@@ -33,6 +33,6 @@
#if defined(ESP8266) || defined(ESP32)
#define HCSR501_PIN D5
#else
#define HCSR501_PIN D7
#define HCSR501_PIN 7
#endif