-
-
Notifications
You must be signed in to change notification settings - Fork 644
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
Improve on random() #190
base: master
Are you sure you want to change the base?
Improve on random() #190
Changes from 3 commits
b5c6842
e9bec96
32a8d16
f36fe47
eb98ea9
00cf0a3
0a4e6ba
558d35b
1413d92
14a1ca8
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -582,7 +582,26 @@ void LoRaClass::setOCP(uint8_t mA) | |
|
||
byte LoRaClass::random() | ||
{ | ||
return readRegister(REG_RSSI_WIDEBAND); | ||
uint8_t currMode = readRegister(REG_OP_MODE); | ||
uint8_t retVal = 0; | ||
|
||
while(isTransmitting()); | ||
|
||
//We need to be listening to radio-traffic in order to generate random numbers | ||
if(currMode != (MODE_LONG_RANGE_MODE | MODE_RX_CONTINUOUS)){ | ||
#ifndef ARDUINO_SAMD_MKRWAN1300 | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'm generally oppose to these kinds of checks, since this PR was originally submit, 'support' has been added for the 1310 board(sorry this hasn't got attention...) and doesn't even begin to handle many other boards out there. Can this check instead be performed against |
||
receive(); | ||
#else | ||
explicitHeaderMode(); | ||
writeRegister(REG_OP_MODE, MODE_LONG_RANGE_MODE | MODE_RX_CONTINUOUS); | ||
#endif | ||
delay(1); | ||
} | ||
retVal = readRegister(REG_RSSI_WIDEBAND); | ||
//Put the radio in the same mode as it was | ||
if(currMode != (MODE_LONG_RANGE_MODE | MODE_RX_CONTINUOUS)) writeRegister(REG_OP_MODE, currMode); | ||
|
||
return retVal; | ||
} | ||
|
||
void LoRaClass::setPins(int ss, int reset, int dio0) | ||
|
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.
Does it need a yield() call in this loop so the WDT doesn't fire on platforms like ESP8266/32?