How to send RegPaLevel register

Started by LukaQ, January 27, 2018, 07:24:38 AM

LukaQ

Hello,

I want to send RegPaLevel register, because I want to know what power level does it use at TX. And I can't use
radio.readReg(0x11);
since at that point it is in RX mode.

Also, why doesn't this work with HW?
radio.setPowerLevel(24);

Felix

Quote from: LukaQ on January 27, 2018, 07:24:38 AM
And I can't use
radio.readReg(0x11);
since at that point it is in RX mode.
Did you try to read it after you set power level but before transmitting?
It's just an uint8_t (unsigned byte).

Quote from: LukaQ on January 27, 2018, 07:24:38 AM
Also, why doesn't this work with HW?
radio.setPowerLevel(24);

It should, are you using the "official" RFM69 lib?

LukaQ

#2
Quote from: Felix on January 27, 2018, 08:13:15 PM
Did you try to read it after you set power level but before transmitting?
It's just an uint8_t (unsigned byte).
It should, are you using the "official" RFM69 lib?
Yes, power was set in void setup() in struct_send sketch, then Serial.print(sizeof(radio._transmitLevel)); just above if (radio.sendWithRetry(GATEWAYID,..... and it was always the same value.
I later found out, one way, but not recommended, is to uncomment in the interruptHook() last two serial.print, which I also changed to
if (_ackRSSI < _targetRSSI && _transmitLevel < 31) { _transmitLevel++; /*Serial.println(_transmitLevel);*/ }
else if (_ackRSSI > _targetRSSI && _transmitLevel > 0) { _transmitLevel--; /*Serial.println(_transmitLevel);*/ }

This works ok, gives you value 0-31. In HW, that is divided by 2, but not sure if that is correct, since only upper 16 bits of that power set register are valid for anything other then PA0, this doesn't seem to do that, or does it?

Next thing I found was, posted by no other than TomWS, the correct way of doing it, which is:
Serial.print("My TX level:"); Serial.print(radio._transmitLevel,DEC);    // prints the current transmit level used by this sender
   Serial.print(", Gateway RSSI:");   Serial.println(radio.getAckRSSI(),DEC);    // prints this sender's RSSI acked back from the receiving node (Gateway)
First line is your power level number and the other one is, returned back RSSI value (you send with XX power, and result on other side is YY RSSI).
You can put this code just about anywhere and will display your current power level.
Works great and if you use both this and above method, you can see vs. your set RSSI how everything changes.

I think you should also have some WIKI or sticky post for such things, all in one place (like: I want to see transmitter power level and answer would be like I explained above). That would help new users A LOT!

Felix

Serial.print(radio._transmitLevel);    // prints the current transmit level used by this sender

If you are searching for that field, is it not pretty simple to read/print it?
I can add any information to the guides, and there's this forum, all search-able, I think that is pretty decent. I don't plan to add yet another branch (wiki system) to my site.

LukaQ

Quote from: Felix on January 29, 2018, 05:02:23 PM
Serial.print(radio._transmitLevel);    // prints the current transmit level used by this sender

If you are searching for that field, is it not pretty simple to read/print it?
I can add any information to the guides, and there's this forum, all search-able, I think that is pretty decent. I don't plan to add yet another branch (wiki system) to my site.
That indeed works, it didn't work, because I didn't know, that radio.transmitLevel is wrong, and radio._transmitLevel is right. Such small details would be great to have in one place, forums are messy and most of the time you don't know what to search for, also all not useful posts that you need to read

Felix

I agree with you,
Maybe a library code example would be pretty illustrative and straight to the point?

LukaQ

Yes that could work, only few working example that has it all, but have small variations, like:
radio.sendWithRetry(GATEWAYID, (const void*)(&theData), sizeof(theData))
vs. what works most of the time
radio.sendWithRetry(GATEWAYID, buff, sendSize)

Far better to understand that check for payload size now or before hand is both right in the end. And how about (const void*)(&theData)? I have no idea why it needs to be like that, but almost doesn't work if it is not done this way.
It is good to keep perspective, that people that don't know or are not good at programming/writing code/understanding it, but are also potential users of this product. To make something work, to explore, to learn. One of the way is to have something working, then change things around and break it, then fix it. By far the best learning experience. Even I fall into this category.

Would be great if some of use could help with that, make a general example of sending "stuff", which can be altered for more specific use