File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -43,11 +43,19 @@ void resetLoRa() {
4343}
4444
4545uint8_t getLoRandomByte () {
46+ uint8_t x = (readRegister (RegRssiWideband ) & 0b00000001 );
47+ for (uint8_t j = 0 ; j < 7 ; j ++ ) {
48+ x = (x << 1 ) | (readRegister (RegRssiWideband ) & 0b00000001 );
49+ }
50+ return x ;
51+ }
52+
53+ uint8_t getLoRandomByteLMIC () {
4654 uint8_t x = 0 ;
4755 for (uint8_t j = 0 ; j < 8 ; j ++ ) {
48- x += ( readRegister ( RegRssiWideband ) & 0b00000001 ) ;
49- x = x << 1 ;
50- //delay(1) ;
56+ uint8_t b ;
57+ while (( b = readRegister ( RegRssiWideband ) & 0x01 ) == ( readRegister ( RegRssiWideband ) & 0x01 )) ;
58+ x = ( x << 1 ) | b ;
5159 }
5260 return x ;
5361}
@@ -75,6 +83,15 @@ void fillRandom(unsigned char *x, size_t len) {
7583 resetLoRa ();
7684}
7785
86+ void fillRandomLMIC (unsigned char * x , size_t len ) {
87+ setupLoRandom ();
88+ size_t i ;
89+ for (i = 0 ; i < len ; i ++ ) {
90+ x [i ] = getLoRandomByteLMIC ();
91+ }
92+ resetLoRa ();
93+ }
94+
7895void fillRandom (unsigned char * x , size_t len , uint8_t except ) {
7996 // used, for instance, when you want a non-zero value.
8097 // fillRandom(UUID, 16, 0);
You can’t perform that action at this time.
0 commit comments