openbeacon: saving seq number again

This commit is contained in:
schneider 2011-12-20 02:43:11 +01:00
parent 6697274019
commit aa5a53716a
1 changed files with 8 additions and 6 deletions

View File

@ -8,18 +8,20 @@
#include "SECRETS" #include "SECRETS"
#define SAVE_OPENBEACON 1
const uint8_t mac[5] = {1,2,3,2,1}; const uint8_t mac[5] = {1,2,3,2,1};
volatile uint32_t oid = 0; volatile uint32_t oid = 0;
volatile uint32_t seq = 0; volatile uint32_t seq = 0;
volatile uint8_t strength = 0; volatile uint8_t strength = 0;
#if ENCRYPT_OPENBEACON
#if SAVE_OPENBEACON
static void openbeaconSave(uint32_t s); static void openbeaconSave(uint32_t s);
#endif #endif
static struct NRF_CFG oldconfig; static struct NRF_CFG oldconfig;
#if ENCRYPT_OPENBEACON #if SAVE_OPENBEACON
static void openbeaconShutdown(void) static void openbeaconShutdown(void)
{ {
openbeaconSave(seq); openbeaconSave(seq);
@ -69,7 +71,7 @@ void openbeaconSetup(void)
{ {
oid = GetUUID32(); oid = GetUUID32();
strength = 0; strength = 0;
#if ENCRYPT_OPENBEACON #if SAVE_OPENBEACON
openbeaconRead(); openbeaconRead();
openbeaconSaveBlock(); openbeaconSaveBlock();
#endif #endif
@ -108,11 +110,11 @@ 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++); status = openbeaconSendPacket(oid, seq++, 0xFF, strength++);
if( strength == 4 ) if( strength == 4 )
strength = 0; strength = 0;
#if ENCRYPT_OPENBEACON #if SAVE_OPENBEACON
if( (seq++ & OPENBEACON_SAVE) == OPENBEACON_SAVE ) if( (seq & OPENBEACON_SAVE) == OPENBEACON_SAVE )
openbeaconSaveBlock(); openbeaconSaveBlock();
#endif #endif
nrf_config_set(&oldconfig); nrf_config_set(&oldconfig);