Make debug prints portable (#929)
This commit is contained in:
@@ -288,7 +288,8 @@ static uint8_t NRF5_ESB_readMessage(void *data)
|
||||
|
||||
// Debug message
|
||||
#ifdef MY_DEBUG_VERBOSE_NRF5_ESB
|
||||
NRF5_RADIO_DEBUG(PSTR("NRF5:RX:LEN=%d,NOACK=%d,PID=%d,RSSI=%d,RX=%d\n"),
|
||||
NRF5_RADIO_DEBUG(PSTR("NRF5:RX:LEN=%" PRIu8 ",NOACK=%" PRIu8 ",PID=%" PRIu8 ",RSSI=%" PRIi16 ",RX=%"
|
||||
PRIu32 "\n"),
|
||||
buffer->len, buffer->noack, buffer->pid, rssi_rx, buffer->rxmatch);
|
||||
#endif
|
||||
|
||||
@@ -380,7 +381,8 @@ void NRF5_ESB_endtx()
|
||||
|
||||
static bool NRF5_ESB_sendMessage(uint8_t recipient, const void *buf, uint8_t len, const bool noACK)
|
||||
{
|
||||
NRF5_RADIO_DEBUG(PSTR("NRF5:SND:TO=%d,LEN=%d,PID=%d,NOACK=%d\n"), recipient, len, tx_buffer.pid,
|
||||
NRF5_RADIO_DEBUG(PSTR("NRF5:SND:TO=%" PRIu8 ",LEN=%" PRIu8 ",PID=%" PRIu8 ",NOACK=%" PRIu8 "\n"),
|
||||
recipient, len, tx_buffer.pid,
|
||||
tx_buffer.noack); // send message
|
||||
// Check if radio is initialized
|
||||
if (NRF_RADIO->POWER == 0) {
|
||||
@@ -450,9 +452,9 @@ static bool NRF5_ESB_sendMessage(uint8_t recipient, const void *buf, uint8_t len
|
||||
// Arbitrary definition: ARC 0 == -29, ARC 15 = -104
|
||||
rssi_tx = (-29 - (8 * (tx_retries_start - tx_retries)));
|
||||
}
|
||||
|
||||
#ifdef MY_DEBUG_VERBOSE_NRF5_ESB
|
||||
NRF5_RADIO_DEBUG(PSTR("NRF5:SND:END=%d,ACK=%d,RTRY=%d,RSSI=%d,WAKE=%d\n"),
|
||||
NRF5_RADIO_DEBUG(PSTR("NRF5:SND:END=%" PRIu8 ",ACK=%" PRIu8 ",RTRY=%" PRIi8 ",RSSI=%" PRIi16
|
||||
",WAKE=%" PRIu32 "\n"),
|
||||
events_end_tx, ack_received, tx_retries_start - tx_retries, rssi_tx, wakeups);
|
||||
#endif
|
||||
|
||||
|
||||
@@ -120,14 +120,14 @@ LOCAL uint8_t RF24_spiByteTransfer(const uint8_t cmd)
|
||||
LOCAL uint8_t RF24_RAW_readByteRegister(const uint8_t cmd)
|
||||
{
|
||||
const uint8_t value = RF24_spiMultiByteTransfer(cmd, NULL, 1, true);
|
||||
RF24_DEBUG(PSTR("RF24:RBR:REG=%d,VAL=%d\n"), cmd & RF24_REGISTER_MASK, value);
|
||||
RF24_DEBUG(PSTR("RF24:RBR:REG=%" PRIu8 ",VAL=%" PRIu8 "\n"), cmd & RF24_REGISTER_MASK, value);
|
||||
return value;
|
||||
}
|
||||
|
||||
LOCAL uint8_t RF24_RAW_writeByteRegister(const uint8_t cmd, uint8_t value)
|
||||
{
|
||||
RF24_DEBUG(PSTR("RF24:WBR:REG=%d,VAL=%d\n"), cmd & RF24_REGISTER_MASK, value);
|
||||
return RF24_spiMultiByteTransfer( cmd , &value, 1, false);
|
||||
RF24_DEBUG(PSTR("RF24:WBR:REG=%" PRIu8 ",VAL=%" PRIu8 "\n"), cmd & RF24_REGISTER_MASK, value);
|
||||
return RF24_spiMultiByteTransfer( cmd, &value, 1, false);
|
||||
}
|
||||
|
||||
LOCAL void RF24_flushRX(void)
|
||||
@@ -224,7 +224,7 @@ LOCAL void RF24_enableFeatures(void)
|
||||
|
||||
LOCAL void RF24_openWritingPipe(const uint8_t recipient)
|
||||
{
|
||||
RF24_DEBUG(PSTR("RF24:OWP:RCPT=%d\n"), recipient); // open writing pipe
|
||||
RF24_DEBUG(PSTR("RF24:OWP:RCPT=%" PRIu8 "\n"), recipient); // open writing pipe
|
||||
// only write LSB of RX0 and TX pipe
|
||||
RF24_setPipeLSB(RF24_REG_RX_ADDR_P0, recipient);
|
||||
RF24_setPipeLSB(RF24_REG_TX_ADDR, recipient);
|
||||
@@ -289,7 +289,7 @@ LOCAL bool RF24_sendMessage(const uint8_t recipient, const void* buf, const uint
|
||||
uint8_t RF24_status;
|
||||
RF24_stopListening();
|
||||
RF24_openWritingPipe( recipient );
|
||||
RF24_DEBUG(PSTR("RF24:TXM:TO=%d,LEN=%d\n"),recipient,len); // send message
|
||||
RF24_DEBUG(PSTR("RF24:TXM:TO=%" PRIu8 ",LEN=%" PRIu8 "\n"),recipient,len); // send message
|
||||
// flush TX FIFO
|
||||
RF24_flushTX();
|
||||
// this command is affected in clones (e.g. Si24R1): flipped NoACK bit when using W_TX_PAYLOAD_NO_ACK / W_TX_PAYLOAD
|
||||
@@ -340,7 +340,7 @@ LOCAL bool RF24_isDataAvailable(void)
|
||||
LOCAL uint8_t RF24_readMessage(void* buf)
|
||||
{
|
||||
const uint8_t len = RF24_getDynamicPayloadSize();
|
||||
RF24_DEBUG(PSTR("RF24:RXM:LEN=%d\n"), len); // read message
|
||||
RF24_DEBUG(PSTR("RF24:RXM:LEN=%" PRIu8 "\n"), len); // read message
|
||||
RF24_spiMultiByteTransfer(RF24_CMD_READ_RX_PAYLOAD,(uint8_t*)buf,len,true);
|
||||
// clear RX interrupt
|
||||
RF24_setStatus(_BV(RF24_RX_DR));
|
||||
@@ -385,7 +385,7 @@ LOCAL bool RF24_setTxPowerLevel(const uint8_t newPowerLevel)
|
||||
{
|
||||
const uint8_t registerContent = RF24_readByteRegister(RF24_REG_RF_SETUP);
|
||||
RF24_writeByteRegister(RF24_REG_RF_SETUP, (registerContent & 0xF9) | ((newPowerLevel & 3) << 1));
|
||||
RF24_DEBUG(PSTR("RF24:STX:LEVEL=%d\n"), newPowerLevel);
|
||||
RF24_DEBUG(PSTR("RF24:STX:LEVEL=%" PRIu8 "\n"), newPowerLevel);
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -447,7 +447,7 @@ LOCAL void RF24_registerReceiveCallback(RF24_receiveCallbackType cb)
|
||||
LOCAL bool RF24_initialize(void)
|
||||
{
|
||||
RF24_DEBUG(PSTR("RF24:INIT\n"));
|
||||
RF24_DEBUG(PSTR("RF24:INIT:PIN,CE=%d,CS=%d\n"), MY_RF24_CE_PIN, MY_RF24_CS_PIN);
|
||||
RF24_DEBUG(PSTR("RF24:INIT:PIN,CE=%" PRIu8 ",CS=%" PRIu8 "\n"), MY_RF24_CE_PIN, MY_RF24_CS_PIN);
|
||||
// Initialize pins & HW
|
||||
#if defined(MY_RF24_POWER_PIN)
|
||||
hwPinMode(MY_RF24_POWER_PIN, OUTPUT);
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
/*
|
||||
/*
|
||||
* The MySensors Arduino library handles the wireless radio link and protocol
|
||||
* between your home built sensors/actuators and HA controller of choice.
|
||||
* The sensors forms a self healing radio network with optional repeaters. Each
|
||||
@@ -166,14 +166,14 @@ LOCAL uint8_t RFM69_spiMultiByteTransfer(const uint8_t cmd, uint8_t* buf, uint8_
|
||||
LOCAL uint8_t RFM69_RAW_readByteRegister(const uint8_t address)
|
||||
{
|
||||
const uint8_t value = RFM69_spiMultiByteTransfer(address, NULL, 1, true);
|
||||
//RFM69_DEBUG(PSTR("RFM69:read register, reg=0x%02x, value=%d\n"), address, value);
|
||||
//RFM69_DEBUG(PSTR("RFM69:read register, reg=0x%02" PRIx8 ", value=%" PRIu8 "\n"), address, value);
|
||||
return value;
|
||||
}
|
||||
|
||||
// low level register access
|
||||
LOCAL uint8_t RFM69_RAW_writeByteRegister(const uint8_t address, uint8_t value)
|
||||
{
|
||||
//RFM69_DEBUG(PSTR("RFM69:write register, reg=0x%02x, value=%d\n"), address & 0x7F, value);
|
||||
//RFM69_DEBUG(PSTR("RFM69:write register, reg=0x%02" PRIx8 ", value=%" PRIu8 "\n"), address & 0x7F, value);
|
||||
return RFM69_spiMultiByteTransfer(address, &value, 1, false);
|
||||
}
|
||||
|
||||
@@ -200,10 +200,12 @@ LOCAL bool RFM69_initialise(const uint32_t frequencyHz)
|
||||
hwDigitalWrite(MY_RFM69_RST_PIN, LOW);
|
||||
// wait until chip ready
|
||||
delay(5);
|
||||
RFM69_DEBUG(PSTR("RFM69:INIT:PIN,CS=%d,IQP=%d,IQN=%d,RST=%d\n"), MY_RFM69_CS_PIN,MY_RFM69_IRQ_PIN,
|
||||
RFM69_DEBUG(PSTR("RFM69:INIT:PIN,CS=%" PRIu8 ",IQP=%" PRIu8 ",IQN=%" PRIu8 ",RST=%" PRIu8 "\n"),
|
||||
MY_RFM69_CS_PIN,MY_RFM69_IRQ_PIN,
|
||||
MY_RFM69_IRQ_NUM,MY_RFM69_RST_PIN);
|
||||
#else
|
||||
RFM69_DEBUG(PSTR("RFM69:INIT:PIN,CS=%d,IQP=%d,IQN=%d\n"),MY_RFM69_CS_PIN, MY_RFM69_IRQ_PIN,
|
||||
RFM69_DEBUG(PSTR("RFM69:INIT:PIN,CS=%" PRIu8 ",IQP=%" PRIu8 ",IQN=%" PRIu8 "\n"),MY_RFM69_CS_PIN,
|
||||
MY_RFM69_IRQ_PIN,
|
||||
MY_RFM69_IRQ_NUM);
|
||||
#endif
|
||||
|
||||
@@ -479,7 +481,7 @@ LOCAL bool RFM69_setTxPowerLevel(rfm69_powerlevel_t newPowerLevel)
|
||||
}
|
||||
#endif
|
||||
RFM69_writeReg(RFM69_REG_PALEVEL, palevel);
|
||||
RFM69_DEBUG(PSTR("RFM69:PTX:LEVEL=%d dBm\n"),newPowerLevel);
|
||||
RFM69_DEBUG(PSTR("RFM69:PTX:LEVEL=%" PRIi8 " dBm\n"),newPowerLevel);
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -622,7 +624,8 @@ LOCAL bool RFM69_standBy(void)
|
||||
LOCAL void RFM69_sendACK(const uint8_t recipient, const rfm69_sequenceNumber_t sequenceNumber,
|
||||
const rfm69_RSSI_t RSSI)
|
||||
{
|
||||
RFM69_DEBUG(PSTR("RFM69:SAC:SEND ACK,TO=%d,RSSI=%d\n"),recipient, RFM69_internalToRSSI(RSSI));
|
||||
RFM69_DEBUG(PSTR("RFM69:SAC:SEND ACK,TO=%" PRIu8 ",RSSI=%" PRIi16 "\n"),recipient,
|
||||
RFM69_internalToRSSI(RSSI));
|
||||
rfm69_ack_t ACK;
|
||||
ACK.sequenceNumber = sequenceNumber;
|
||||
ACK.RSSI = RSSI;
|
||||
@@ -649,7 +652,8 @@ LOCAL bool RFM69_executeATC(const rfm69_RSSI_t currentRSSI, const rfm69_RSSI_t t
|
||||
// nothing to adjust
|
||||
return false;
|
||||
}
|
||||
RFM69_DEBUG(PSTR("RFM69:ATC:ADJ TXL,cR=%d,tR=%d,TXL=%d\n"), RFM69_internalToRSSI(currentRSSI),
|
||||
RFM69_DEBUG(PSTR("RFM69:ATC:ADJ TXL,cR=%" PRIi16 ",tR=%" PRIi16 ",TXL=%" PRIi16 "\n"),
|
||||
RFM69_internalToRSSI(currentRSSI),
|
||||
RFM69_internalToRSSI(targetRSSI), newPowerLevel);
|
||||
|
||||
return RFM69_setTxPowerLevel(newPowerLevel);
|
||||
@@ -666,7 +670,7 @@ LOCAL bool RFM69_sendWithRetry(const uint8_t recipient, const void* buffer,
|
||||
const uint8_t bufferSize, const uint8_t retries, const uint32_t retryWaitTimeMS)
|
||||
{
|
||||
for (uint8_t retry = 0; retry <= retries; retry++) {
|
||||
RFM69_DEBUG(PSTR("RFM69:SWR:SEND,TO=%d,RETRY=%d\n"), recipient, retry);
|
||||
RFM69_DEBUG(PSTR("RFM69:SWR:SEND,TO=%" PRIu8 ",RETRY=%" PRIu8 "\n"), recipient, retry);
|
||||
rfm69_controlFlags_t flags = 0x00; // reset all flags
|
||||
RFM69_setACKRequested(flags, (recipient != RFM69_BROADCAST_ADDRESS));
|
||||
RFM69_setACKRSSIReport(flags, RFM69.ATCenabled);
|
||||
@@ -688,7 +692,8 @@ LOCAL bool RFM69_sendWithRetry(const uint8_t recipient, const void* buffer,
|
||||
// packet read, back to RX
|
||||
RFM69_setRadioMode(RFM69_RADIO_MODE_RX);
|
||||
if (sender == recipient && ACKsequenceNumber == RFM69.txSequenceNumber) {
|
||||
RFM69_DEBUG(PSTR("RFM69:SWR:ACK,FROM=%d,SEQ=%d,RSSI=%d\n"),sender,ACKsequenceNumber,
|
||||
RFM69_DEBUG(PSTR("RFM69:SWR:ACK,FROM=%" PRIu8 ",SEQ=%" PRIu8 ",RSSI=%" PRIi16 "\n"),sender,
|
||||
ACKsequenceNumber,
|
||||
RFM69_internalToRSSI(RSSI));
|
||||
|
||||
// ATC
|
||||
@@ -739,7 +744,7 @@ LOCAL bool RFM69_setTxPowerPercent(uint8_t newPowerPercent)
|
||||
const rfm69_powerlevel_t newPowerLevel = static_cast<rfm69_powerlevel_t>
|
||||
(RFM69_MIN_POWER_LEVEL_DBM + (RFM69_MAX_POWER_LEVEL_DBM
|
||||
- RFM69_MIN_POWER_LEVEL_DBM) * (newPowerPercent / 100.0f));
|
||||
RFM69_DEBUG(PSTR("RFM69:SPP:PCT=%d,TX LEVEL=%d\n"), newPowerPercent,newPowerLevel);
|
||||
RFM69_DEBUG(PSTR("RFM69:SPP:PCT=%" PRIu8 ",TX LEVEL=%" PRIi8 "\n"), newPowerPercent,newPowerLevel);
|
||||
return RFM69_setTxPowerLevel(newPowerLevel);
|
||||
}
|
||||
|
||||
@@ -1465,4 +1470,4 @@ LOCAL void RFM69_readAllRegs(void)
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
||||
#endif
|
||||
|
||||
+14
-8
@@ -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);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user