Skip to content

Commit 77f2539

Browse files
committed
Double blink if epoch time is invalid.
Plus minor modifications.
1 parent d3c512f commit 77f2539

File tree

4 files changed

+16
-6
lines changed

4 files changed

+16
-6
lines changed

firmware/nRF51/tag-proximity/inc/radio.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,9 @@
2727

2828
#include <openbeacon-proto.h>
2929

30+
/* arbitrary epoch time threshold, used to check to epoch time validity */
31+
#define VALID_EPOCH_THRES 1411633853
32+
3033
extern void radio_init(uint32_t uid);
3134
extern uint32_t get_time(void);
3235

firmware/nRF51/tag-proximity/src/acc.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,7 @@ void acc_sample(void)
9898
}
9999

100100

101-
int16_t tag_acc(uint8_t axis)
101+
inline int16_t tag_acc(uint8_t axis)
102102
{
103103
return acc[axis];
104104
}

firmware/nRF51/tag-proximity/src/main.c

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -186,6 +186,15 @@ void main_entry(void)
186186
nrf_gpio_pin_set(CONFIG_LED_PIN);
187187
timer_wait(MILLISECONDS(1));
188188
nrf_gpio_pin_clear(CONFIG_LED_PIN);
189+
190+
/* double blink if epoch time is invalid */
191+
if (get_time() < VALID_EPOCH_THRES) {
192+
timer_wait(MILLISECONDS(100));
193+
194+
nrf_gpio_pin_set(CONFIG_LED_PIN);
195+
timer_wait(MILLISECONDS(1));
196+
nrf_gpio_pin_clear(CONFIG_LED_PIN);
197+
}
189198
}
190199
}
191200
}

firmware/nRF51/tag-proximity/src/radio.c

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -61,8 +61,6 @@ static uint8_t g_nrf_state;
6161
static int8_t g_rssi;
6262
static uint8_t prox_txpower_index;
6363

64-
#define VALID_EPOCH_THRES 1411633853
65-
6664
static uint32_t g_time_status_reported, g_time_status_logged;
6765
#define STATUS_FORCE_REPORT_PERIOD 300
6866
#define STATUS_FORCE_LOG_PERIOD 900
@@ -109,7 +107,7 @@ static uint8_t g_pkt_tracker_enc[sizeof(g_pkt_tracker)] ALIGN4;
109107
(NRF_PROX_SIZE << RADIO_PCNF1_MAXLEN_Pos)
110108

111109

112-
uint32_t get_time(void)
110+
inline uint32_t get_time(void)
113111
{
114112
return g_time;
115113
}
@@ -369,7 +367,7 @@ void RADIO_IRQ_Handler(void)
369367
or if we have not reported status for too long,
370368
prepare a status packet */
371369
if( (!g_pkt_tracker.p.sighting[0].uid) ||
372-
(g_time - g_time_status_reported > STATUS_FORCE_REPORT_PERIOD) )
370+
(g_time - g_time_status_reported >= STATUS_FORCE_REPORT_PERIOD) )
373371
{
374372
g_pkt_tracker.proto = RFBPROTO_BEACON_NG_STATUS;
375373
g_pkt_tracker.p.status.rx_loss = (int16_t)((RX_LOSS*100)+0.5);
@@ -398,7 +396,7 @@ void RADIO_IRQ_Handler(void)
398396
and log status if long enough time has elapsed */
399397
if ( (g_pkt_tracker.proto == RFBPROTO_BEACON_NG_SIGHTING) ||
400398
(g_pkt_tracker.proto == RFBPROTO_BEACON_NG_STATUS &&
401-
g_time - g_time_status_logged > STATUS_FORCE_LOG_PERIOD) )
399+
g_time - g_time_status_logged >= STATUS_FORCE_LOG_PERIOD) )
402400
{
403401
flash_log(sizeof(g_pkt_tracker) - CONFIG_SIGNATURE_SIZE, (uint8_t *) &g_pkt_tracker);
404402

0 commit comments

Comments
 (0)