beacon monitor bugfix

This commit is contained in:
Klaus K Wilting 2018-07-31 09:21:10 +02:00
parent 455c2c8149
commit dec9cfe703
5 changed files with 12 additions and 12 deletions

View File

@ -177,7 +177,7 @@ Hereafter described is the default *plain* format, which uses MSB bit numbering.
**Port #6:** Beacon proximity alarm
byte 1: Beacon RSSI reception level
byte 2: Beacon identifier (0..254)
byte 2: Beacon identifier (0..255)
[**plain_decoder.js**](src/TTN/plain_decoder.js)
@ -318,7 +318,7 @@ Note: all settings are stored in NVRAM and will be reloaded when device starts.
0x12 set or reset a beacon MAC for proximity alarm
byte 1 = beacon ID (0..254)
byte 1 = beacon ID (0..255)
bytes 2..7 = beacon MAC with 6 digits (e.g. MAC 80:ab:00:01:02:03 -> 0x80ab00010203)
0x80 get device configuration

View File

@ -1,9 +1,9 @@
#ifndef _BEACON_ARRAY_H
#define _BEACON_ARRAY_H
std::array<uint64_t, 0xfe>::iterator it;
std::array<uint64_t, 0xff>::iterator it;
std::array<uint64_t, 0xfe> beacons = {0x0102030405060708, 0xaaaaaaaaaaaaaaaa,
std::array<uint64_t, 0xff> beacons = {0x0102030405060708, 0xaaaaaaaaaaaaaaaa,
0xaaaaaaaaaaaaaaa1, 0x0000807abf6f522b,
0x0000807abfedb08e, 0x00005BEEB69AA8FC,
0x0000DB53A5362400};

View File

@ -48,8 +48,8 @@ extern portMUX_TYPE timerMux;
extern volatile int SendCycleTimerIRQ, HomeCycleIRQ, DisplayTimerIRQ,
ChannelTimerIRQ, ButtonPressedIRQ;
extern std::array<uint64_t, 0xfe>::iterator it;
extern std::array<uint64_t, 0xfe> beacons;
extern std::array<uint64_t, 0xff>::iterator it;
extern std::array<uint64_t, 0xff> beacons;
#ifdef HAS_GPS
#include "gps.h"

View File

@ -27,12 +27,12 @@ uint16_t reset_salt(void) {
return salt;
}
uint8_t isBeacon(uint64_t mac) {
int8_t isBeacon(uint64_t mac) {
it = std::find(beacons.begin(), beacons.end(), mac);
if (it != beacons.end())
return std::distance(beacons.begin(), it);
else
return 0xff;
return -1;
}
uint64_t macConvert(uint8_t *paddr) {
@ -45,7 +45,7 @@ bool mac_add(uint8_t *paddr, int8_t rssi, bool sniff_type) {
char buff[16]; // temporary buffer for printf
bool added = false;
uint8_t beaconID; // beacon number in test monitor mode
int8_t beaconID; // beacon number in test monitor mode
uint16_t hashedmac; // temporary buffer for generated hash value
uint32_t addr2int,
vendor2int; // temporary buffer for shortened MAC and Vendor OUI
@ -98,8 +98,8 @@ bool mac_add(uint8_t *paddr, int8_t rssi, bool sniff_type) {
// in beacon monitor mode check if seen MAC is a known beacon
if (cfg.monitormode) {
beaconID = isBeacon(macConvert(paddr));
if (beaconID != 0xff) {
ESP_LOGI(TAG, "Beacon ID#%d detected", beaconID);
if (beaconID >= 0) {
ESP_LOGI(TAG, "Beacon ID#d detected", beaconID);
#if (HAS_LED != NOT_A_PIN) || defined(HAS_RGB_LED)
blink_LED(COLOR_WHITE, 2000);
#endif

View File

@ -174,7 +174,7 @@ void set_gps(uint8_t val[]) {
};
void set_beacon(uint8_t val[]) {
if ( (sizeof(*val) / sizeof(val[0]) == 7) && (val[0] <= 0xff ) ) {
if (sizeof(*val) / sizeof(val[0]) == 7) {
uint8_t id = val[0]; // use first parameter as beacon storage id
memmove(val, val + 1, 6); // strip off storage id
beacons[id] = macConvert(val); // store beacon MAC in array