beacon monitor bugfix
This commit is contained in:
parent
455c2c8149
commit
dec9cfe703
@ -177,7 +177,7 @@ Hereafter described is the default *plain* format, which uses MSB bit numbering.
|
|||||||
**Port #6:** Beacon proximity alarm
|
**Port #6:** Beacon proximity alarm
|
||||||
|
|
||||||
byte 1: Beacon RSSI reception level
|
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)
|
[**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
|
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)
|
bytes 2..7 = beacon MAC with 6 digits (e.g. MAC 80:ab:00:01:02:03 -> 0x80ab00010203)
|
||||||
|
|
||||||
0x80 get device configuration
|
0x80 get device configuration
|
||||||
|
@ -1,9 +1,9 @@
|
|||||||
#ifndef _BEACON_ARRAY_H
|
#ifndef _BEACON_ARRAY_H
|
||||||
#define _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,
|
0xaaaaaaaaaaaaaaa1, 0x0000807abf6f522b,
|
||||||
0x0000807abfedb08e, 0x00005BEEB69AA8FC,
|
0x0000807abfedb08e, 0x00005BEEB69AA8FC,
|
||||||
0x0000DB53A5362400};
|
0x0000DB53A5362400};
|
||||||
|
@ -48,8 +48,8 @@ extern portMUX_TYPE timerMux;
|
|||||||
extern volatile int SendCycleTimerIRQ, HomeCycleIRQ, DisplayTimerIRQ,
|
extern volatile int SendCycleTimerIRQ, HomeCycleIRQ, DisplayTimerIRQ,
|
||||||
ChannelTimerIRQ, ButtonPressedIRQ;
|
ChannelTimerIRQ, ButtonPressedIRQ;
|
||||||
|
|
||||||
extern std::array<uint64_t, 0xfe>::iterator it;
|
extern std::array<uint64_t, 0xff>::iterator it;
|
||||||
extern std::array<uint64_t, 0xfe> beacons;
|
extern std::array<uint64_t, 0xff> beacons;
|
||||||
|
|
||||||
#ifdef HAS_GPS
|
#ifdef HAS_GPS
|
||||||
#include "gps.h"
|
#include "gps.h"
|
||||||
|
@ -27,12 +27,12 @@ uint16_t reset_salt(void) {
|
|||||||
return salt;
|
return salt;
|
||||||
}
|
}
|
||||||
|
|
||||||
uint8_t isBeacon(uint64_t mac) {
|
int8_t isBeacon(uint64_t mac) {
|
||||||
it = std::find(beacons.begin(), beacons.end(), mac);
|
it = std::find(beacons.begin(), beacons.end(), mac);
|
||||||
if (it != beacons.end())
|
if (it != beacons.end())
|
||||||
return std::distance(beacons.begin(), it);
|
return std::distance(beacons.begin(), it);
|
||||||
else
|
else
|
||||||
return 0xff;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
uint64_t macConvert(uint8_t *paddr) {
|
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
|
char buff[16]; // temporary buffer for printf
|
||||||
bool added = false;
|
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
|
uint16_t hashedmac; // temporary buffer for generated hash value
|
||||||
uint32_t addr2int,
|
uint32_t addr2int,
|
||||||
vendor2int; // temporary buffer for shortened MAC and Vendor OUI
|
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
|
// in beacon monitor mode check if seen MAC is a known beacon
|
||||||
if (cfg.monitormode) {
|
if (cfg.monitormode) {
|
||||||
beaconID = isBeacon(macConvert(paddr));
|
beaconID = isBeacon(macConvert(paddr));
|
||||||
if (beaconID != 0xff) {
|
if (beaconID >= 0) {
|
||||||
ESP_LOGI(TAG, "Beacon ID#%d detected", beaconID);
|
ESP_LOGI(TAG, "Beacon ID#d detected", beaconID);
|
||||||
#if (HAS_LED != NOT_A_PIN) || defined(HAS_RGB_LED)
|
#if (HAS_LED != NOT_A_PIN) || defined(HAS_RGB_LED)
|
||||||
blink_LED(COLOR_WHITE, 2000);
|
blink_LED(COLOR_WHITE, 2000);
|
||||||
#endif
|
#endif
|
||||||
|
@ -174,7 +174,7 @@ void set_gps(uint8_t val[]) {
|
|||||||
};
|
};
|
||||||
|
|
||||||
void set_beacon(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
|
uint8_t id = val[0]; // use first parameter as beacon storage id
|
||||||
memmove(val, val + 1, 6); // strip off storage id
|
memmove(val, val + 1, 6); // strip off storage id
|
||||||
beacons[id] = macConvert(val); // store beacon MAC in array
|
beacons[id] = macConvert(val); // store beacon MAC in array
|
||||||
|
Loading…
Reference in New Issue
Block a user