Make debug prints portable (#929)

This commit is contained in:
Olivier
2017-09-17 20:54:20 +02:00
committed by Henrik Ekblad
parent 9e5a1e32cb
commit 0ed558f1d0
18 changed files with 173 additions and 124 deletions
+14 -8
View File
@@ -144,10 +144,12 @@ LOCAL bool RFM95_initialise(const uint32_t frequencyHz)
hwDigitalWrite(MY_RFM95_RST_PIN, LOW);
// wait until chip ready
delay(5);
RFM95_DEBUG(PSTR("RFM95:INIT:PIN,CS=%d,IQP=%d,IQN=%d,RST=%d\n"), MY_RFM95_CS_PIN, MY_RFM95_IRQ_PIN,
RFM95_DEBUG(PSTR("RFM95:INIT:PIN,CS=%" PRIu8 ",IQP=%" PRIu8 ",IQN=%" PRIu8 ",RST=%" PRIu8 "\n"),
MY_RFM95_CS_PIN, MY_RFM95_IRQ_PIN,
MY_RFM95_IRQ_NUM,MY_RFM95_RST_PIN);
#else
RFM95_DEBUG(PSTR("RFM95:INIT:PIN,CS=%d,IQP=%d,IQN=%d\n"), MY_RFM95_CS_PIN, MY_RFM95_IRQ_PIN,
RFM95_DEBUG(PSTR("RFM95:INIT:PIN,CS=%" PRIu8 ",IQP=%" PRIu8 ",IQN=%" PRIu8 "\n"), MY_RFM95_CS_PIN,
MY_RFM95_IRQ_PIN,
MY_RFM95_IRQ_NUM);
#endif
@@ -357,7 +359,7 @@ LOCAL bool RFM95_setTxPowerLevel(rfm95_powerLevel_t newPowerLevel)
val = newPowerLevel - 5;
}
RFM95_writeReg(RFM95_REG_09_PA_CONFIG, RFM95_PA_SELECT | val);
RFM95_DEBUG(PSTR("RFM95:PTX:LEVEL=%d\n"), newPowerLevel);
RFM95_DEBUG(PSTR("RFM95:PTX:LEVEL=%" PRIi8 "\n"), newPowerLevel);
return true;
}
return false;
@@ -460,7 +462,8 @@ LOCAL bool RFM95_standBy(void)
LOCAL void RFM95_sendACK(const uint8_t recipient, const rfm95_sequenceNumber_t sequenceNumber,
const rfm95_RSSI_t RSSI, const rfm95_SNR_t SNR)
{
RFM95_DEBUG(PSTR("RFM95:SAC:SEND ACK,TO=%d,SEQ=%d,RSSI=%d,SNR=%d\n"),recipient,sequenceNumber,
RFM95_DEBUG(PSTR("RFM95:SAC:SEND ACK,TO=%" PRIu8 ",SEQ=%" PRIu16 ",RSSI=%" PRIi16 ",SNR=%" PRIi8
"\n"),recipient,sequenceNumber,
RFM95_internalToRSSI(RSSI),RFM95_internalToSNR(SNR));
rfm95_ack_t ACK;
ACK.sequenceNumber = sequenceNumber;
@@ -489,7 +492,8 @@ LOCAL bool RFM95_executeATC(const rfm95_RSSI_t currentRSSI, const rfm95_RSSI_t t
// nothing to adjust
return false;
}
RFM95_DEBUG(PSTR("RFM95:ATC:ADJ TXL,cR=%d,tR=%d,TXL=%d\n"), RFM95_internalToRSSI(currentRSSI),
RFM95_DEBUG(PSTR("RFM95:ATC:ADJ TXL,cR=%" PRIi16 ",tR=%" PRIi16 ",TXL=%" PRIi8 "\n"),
RFM95_internalToRSSI(currentRSSI),
RFM95_internalToRSSI(targetRSSI), RFM95.powerLevel);
return RFM95_setTxPowerLevel(newPowerLevel);
}
@@ -498,7 +502,8 @@ LOCAL bool RFM95_sendWithRetry(const uint8_t recipient, const void* buffer,
const uint8_t bufferSize, const uint8_t retries, const uint32_t retryWaitTime)
{
for (uint8_t retry = 0; retry <= retries; retry++) {
RFM95_DEBUG(PSTR("RFM95:SWR:SEND,TO=%d,SEQ=%d,RETRY=%d\n"), recipient, RFM95.txSequenceNumber,
RFM95_DEBUG(PSTR("RFM95:SWR:SEND,TO=%" PRIu8 ",SEQ=%" PRIu16 ",RETRY=%" PRIu8 "\n"), recipient,
RFM95.txSequenceNumber,
retry);
rfm95_controlFlags_t flags = 0x00;
RFM95_setACKRequested(flags, (recipient != RFM95_BROADCAST_ADDRESS));
@@ -521,7 +526,8 @@ LOCAL bool RFM95_sendWithRetry(const uint8_t recipient, const void* buffer,
RFM95_setRadioMode(RFM95_RADIO_MODE_RX);
if (sender == recipient &&
(ACKsequenceNumber == RFM95.txSequenceNumber)) {
RFM95_DEBUG(PSTR("RFM95:SWR:ACK FROM=%d,SEQ=%d,RSSI=%d\n"),sender,ACKsequenceNumber,
RFM95_DEBUG(PSTR("RFM95:SWR:ACK FROM=%" PRIu8 ",SEQ=%" PRIu16 ",RSSI=%" PRIi16 "\n"),sender,
ACKsequenceNumber,
RFM95_internalToRSSI(RSSI));
//RFM95_clearRxBuffer();
// ATC
@@ -636,7 +642,7 @@ LOCAL bool RFM95_setTxPowerPercent(const uint8_t newPowerPercent)
const rfm95_powerLevel_t newPowerLevel = static_cast<rfm95_powerLevel_t>
(RFM95_MIN_POWER_LEVEL_DBM + (RFM95_MAX_POWER_LEVEL_DBM
- RFM95_MIN_POWER_LEVEL_DBM) * (newPowerPercent / 100.0f));
RFM95_DEBUG(PSTR("RFM95:SPP:PCT=%d,TX LEVEL=%d\n"), newPowerPercent,newPowerLevel);
RFM95_DEBUG(PSTR("RFM95:SPP:PCT=%" PRIu8 ",TX LEVEL=%" PRIi8 "\n"), newPowerPercent,newPowerLevel);
return RFM95_setTxPowerLevel(newPowerLevel);
}