openbeacon: add extra random

This commit is contained in:
schneider 2011-12-21 19:52:30 +01:00
parent 328e2b1163
commit f94b33963a
2 changed files with 10 additions and 6 deletions

View File

@ -82,6 +82,10 @@ static uint8_t openbeaconSendPacket(uint32_t id, uint32_t seq,
{ {
uint8_t buf[32]; uint8_t buf[32];
volatile uint8_t i;
i = getRandom()&0xff;
while(i--);
buf[0]=0x10; // Length: 16 bytes buf[0]=0x10; // Length: 16 bytes
buf[1]=0x17; // Proto - fixed at 0x17? buf[1]=0x17; // Proto - fixed at 0x17?
buf[2]=flags; buf[2]=flags;
@ -100,9 +104,9 @@ static uint8_t openbeaconSendPacket(uint32_t id, uint32_t seq,
#endif #endif
} }
uint8_t openbeaconSend(void) void openbeaconSend(void)
{ {
uint8_t status; //uint8_t status;
nrf_config_get(&oldconfig); nrf_config_get(&oldconfig);
@ -110,14 +114,14 @@ uint8_t openbeaconSend(void)
nrf_set_strength(strength); nrf_set_strength(strength);
nrf_set_tx_mac(sizeof(mac), mac); nrf_set_tx_mac(sizeof(mac), mac);
status = openbeaconSendPacket(oid, seq++, 0xFF, strength++); openbeaconSendPacket(oid, seq++, 0xFF, strength++);
if( strength == 4 ) if( strength == 4 )
strength = 0; strength = 0;
#if SAVE_OPENBEACON #if SAVE_OPENBEACON
if( (seq & OPENBEACON_SAVE) == OPENBEACON_SAVE ) if( (seq & OPENBEACON_SAVE) == OPENBEACON_SAVE )
push_queue(&openbeaconSaveBlock); openbeaconSaveBlock();
#endif #endif
nrf_config_set(&oldconfig); nrf_config_set(&oldconfig);
return status; //return status;
} }

View File

@ -9,6 +9,6 @@
#define OPENBEACON_CHANNEL 81 #define OPENBEACON_CHANNEL 81
void openbeaconSetup(void); void openbeaconSetup(void);
uint8_t openbeaconSend(void); void openbeaconSend(void);
#endif #endif