-
-
Notifications
You must be signed in to change notification settings - Fork 641
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix Random function #395
base: master
Are you sure you want to change the base?
Fix Random function #395
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just add some minor changes, to allow the example to compile in any board
Thanks @wero1414 , I have made the changes |
@morganrallen @sandeepmistry this seems to fix the problems with getting random numbers with the radio, could you check it out? |
I will do some tests, but we need to remember that the LoRa chip must be set in a specific state (continuous receive, SF 7, BW 125 KHz, C/R 4/5) before reading register 0x2c. We need to warn the user, and possibly provide a way to switch ti the proper settings, and then switch back to the user's preferred settings. |
See https://github.com/Kongduino/ESP32_Random_Test for an example. This version of LoRandom.h seamlessly sets up LoRa for rng, and resets LoRa to the previous settings when done. |
There was a reason (not that important but still) to put the settings in binary: these registers have several settings within a byte, so the binary representation helps seeing what is set up. Example: writeRegister(RegOpMode, 0b10001101);
// MODE_LONG_RANGE_MODE 0b1xxxxxxx || LowFrequencyModeOn 0bxxxx1xxx || MODE_RX_CONTINUOUS 0bxxxxx101 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hi @sabas1080, thanks for opening this pull request!
I've made some comments to start some discussions. @wero1414 @Kongduino @tobozo feel free to participate in the discussion as well.
Speculation : Use a double buffer random pool with implicit update, when the first buffer is consumed it is marked as such and updated on next opportunity. Both buffers are filled when LoRa.begin() is called, and can be separately re-filled by the driver when marked as consumed. Benefits:
|
This is specific to a board, BastWAN, that I used originally to create LoRandom. This should definitely be removed from the example code... |
I'm coming back to finish this task |
@sabas1080 any thoughts on @IoTThinks comment in #395 (comment)? |
@IoTThinks comment in #395 (comment)
There is an description how to generate random numbers in Application Note AN1200.24 from Semtech. Datasheet says: REGOpMode Bit 3 LowFrequencyModeOn, after Reset it is set to 1. But the setting is only important for access to some registers for FSK/OOK Mode. Is it not much more clear what is going on by writing
|
Hi, Why not start by adding just a function For later on this function can be used to fill some buffer or double buffer of random bytes, ...(see #395 (comment)). |
Hi everyone
I am doing this pull request based in the work of @Kongduino in the issue #394
Welcome feedback
Thanks