Skip to content

Commit

Permalink
Merge pull request #1 from ESPresense/master
Browse files Browse the repository at this point in the history
Sync Fork
  • Loading branch information
dxmnkd316 authored Oct 6, 2024
2 parents b33fb98 + 981f1c2 commit dc97990
Show file tree
Hide file tree
Showing 26 changed files with 3,021 additions and 4,642 deletions.
12 changes: 6 additions & 6 deletions agent.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,15 @@

export WORKSPACE_BASE=$(pwd)

docker run \
-it \
--pull=always \
--add-host host.docker.internal:host-gateway \
docker pull ghcr.io/all-hands-ai/runtime:0.9-nikolaik

docker run -it --pull=always \
-e SANDBOX_RUNTIME_CONTAINER_IMAGE=ghcr.io/all-hands-ai/runtime:0.9-nikolaik \
-e SANDBOX_USER_ID=$(id -u) \
-e LLM_OLLAMA_BASE_URL="http://host.docker.internal:11434" \
-e WORKSPACE_MOUNT_PATH=$WORKSPACE_BASE \
-v $WORKSPACE_BASE:/opt/workspace_base \
-v /var/run/docker.sock:/var/run/docker.sock \
-p 3000:3000 \
-p 3001:3000 \
--add-host host.docker.internal:host-gateway \
--name openhands-app-$(date +%Y%m%d%H%M%S) \
ghcr.io/all-hands-ai/openhands:0.9
13 changes: 12 additions & 1 deletion src/defaults.h → include/defaults.h
Original file line number Diff line number Diff line change
Expand Up @@ -47,18 +47,29 @@
#define DEFAULT_DEBOUNCE_TIMEOUT 0.5

#define DEFAULT_QUERY ""
#define DEFAULT_REQUERY_MS 300000

#define DEFAULT_INCLUDE ""
#define DEFAULT_EXCLUDE ""
#define DEFAULT_KNOWN_MACS ""
#define DEFAULT_KNOWN_IRKS ""

#define DEFAULT_RX_REF_RSSI (-65)
#define DEFAULT_TX_REF_RSSI (-59)
#define DEFAULT_ABSORPTION (3.5)
#define DEFAULT_RX_ADJ_RSSI 0

#define DEFAULT_FORGET_MS 150000 // Ms to remove fingerprint after not seeing it

#define DEFAULT_SKIP_DISTANCE 0.5 // If beacon has moved less than this skip update
#define DEFAULT_SKIP_MS 5000 // Ms to skip mqtt update if no movement

#define DEFAULT_COUNT_ENTER 2.0f
#define DEFAULT_COUNT_EXIT 4.0f
#define DEFAULT_COUNT_MS 10000
#define DEFAULT_COUNT_IDS ""



// I2C Defaults
#ifdef M5STICK
#define DEFAULT_I2C_BUS_1_SDA 32
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#include "BleFingerprint.h"

#include "../handlers/MiFloraHandler.h"
#include "../handlers/NameModelHandler.h"
#include "MiFloraHandler.h"
#include "NameModelHandler.h"
#include "BleFingerprintCollection.h"
#include "mbedtls/aes.h"
#include "rssi.h"
Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,15 +1,30 @@
#include "BleFingerprintCollection.h"

#include "defaults.h"
#include <Arduino.h>

#include <sstream>
#include <AsyncWiFiSettings.h>

namespace BleFingerprintCollection {
// Public (externed)
String include{}, exclude{}, query{}, knownMacs{}, knownIrks{}, countIds{};
float skipDistance = 0.0f, maxDistance = 0.0f, absorption = 3.5f, countEnter = 2, countExit = 4;
int8_t rxRefRssi = -65, rxAdjRssi = 0, txRefRssi = -59;
int forgetMs = 0, skipMs = 0, countMs = 10000, requeryMs = 300000;
String include{DEFAULT_INCLUDE},
exclude{DEFAULT_EXCLUDE},
query{DEFAULT_QUERY},
knownMacs{DEFAULT_KNOWN_MACS},
knownIrks{DEFAULT_KNOWN_IRKS},
countIds{DEFAULT_COUNT_IDS};
float skipDistance = DEFAULT_SKIP_DISTANCE,
maxDistance = DEFAULT_MAX_DISTANCE,
absorption = DEFAULT_ABSORPTION,
countEnter = DEFAULT_COUNT_ENTER,
countExit = DEFAULT_COUNT_EXIT;
int8_t rxRefRssi = DEFAULT_RX_REF_RSSI,
rxAdjRssi = DEFAULT_RX_ADJ_RSSI,
txRefRssi = DEFAULT_TX_REF_RSSI;
int forgetMs = DEFAULT_FORGET_MS,
skipMs = DEFAULT_SKIP_MS,
countMs = DEFAULT_COUNT_MS,
requeryMs = DEFAULT_REQUERY_MS;
std::vector<DeviceConfig> deviceConfigs;
std::vector<uint8_t *> irks;
std::vector<BleFingerprint *> fingerprints;
Expand Down Expand Up @@ -117,6 +132,29 @@ bool Config(String &id, String &json) {
}

void ConnectToWifi() {
knownMacs = AsyncWiFiSettings.string("known_macs", DEFAULT_KNOWN_MACS, "Known BLE mac addresses (no colons, space seperated)");
knownIrks = AsyncWiFiSettings.string("known_irks", DEFAULT_KNOWN_IRKS, "Known BLE identity resolving keys, should be 32 hex chars space seperated");

query = AsyncWiFiSettings.string("query", DEFAULT_QUERY, "Query device ids for characteristics (eg. flora:)");
requeryMs = AsyncWiFiSettings.integer("requery_ms", 30, 3600, DEFAULT_REQUERY_MS / 1000, "Requery interval in seconds") * 1000;

countIds = AsyncWiFiSettings.string("count_ids", DEFAULT_COUNT_IDS, "Include id prefixes (space seperated)");
countEnter = AsyncWiFiSettings.floating("count_enter", 0, 100, DEFAULT_COUNT_ENTER, "Start counting devices less than distance (in meters)");
countExit = AsyncWiFiSettings.floating("count_exit", 0, 100, DEFAULT_COUNT_EXIT, "Stop counting devices greater than distance (in meters)");
countMs = AsyncWiFiSettings.integer("count_ms", 0, 3000000, DEFAULT_COUNT_MS, "Include devices with age less than (in ms)");

include = AsyncWiFiSettings.string("include", DEFAULT_INCLUDE, "Include only sending these ids to mqtt (eg. apple:iphone10-6 apple:iphone13-2)");
exclude = AsyncWiFiSettings.string("exclude", DEFAULT_EXCLUDE, "Exclude sending these ids to mqtt (eg. exp:20 apple:iphone10-6)");
maxDistance = AsyncWiFiSettings.floating("max_dist", 0, 100, DEFAULT_MAX_DISTANCE, "Maximum distance to report (in meters)");
skipDistance = AsyncWiFiSettings.floating("skip_dist", 0, 10, DEFAULT_SKIP_DISTANCE, "Report early if beacon has moved more than this distance (in meters)");
skipMs = AsyncWiFiSettings.integer("skip_ms", 0, 3000000, DEFAULT_SKIP_MS, "Skip reporting if message age is less that this (in milliseconds)");

rxRefRssi = AsyncWiFiSettings.integer("ref_rssi", -100, 100, DEFAULT_RX_REF_RSSI, "Rssi expected from a 0dBm transmitter at 1 meter (NOT used for iBeacons or Eddystone)");
rxAdjRssi = AsyncWiFiSettings.integer("rx_adj_rssi", -100, 100, DEFAULT_RX_ADJ_RSSI, "Rssi adjustment for receiver (use only if you know this device has a weak antenna)");
absorption = AsyncWiFiSettings.floating("absorption", -100, 100, DEFAULT_ABSORPTION, "Factor used to account for absorption, reflection, or diffraction");
forgetMs = AsyncWiFiSettings.integer("forget_ms", 0, 3000000, DEFAULT_FORGET_MS, "Forget beacon if not seen for (in milliseconds)");
txRefRssi = AsyncWiFiSettings.integer("tx_ref_rssi", -100, 100, DEFAULT_TX_REF_RSSI, "Rssi expected from this tx power at 1m (used for node iBeacon)");

std::istringstream iss(knownIrks.c_str());
std::string irk_hex;
while (iss >> irk_hex) {
Expand All @@ -129,44 +167,44 @@ void ConnectToWifi() {

bool Command(String &command, String &pay) {
if (command == "skip_ms") {
BleFingerprintCollection::skipMs = pay.toInt();
spurt("/skip_ms", pay);
BleFingerprintCollection::skipMs = pay.isEmpty() ? DEFAULT_SKIP_MS : pay.toInt();
spurt("/skip_ms", String(skipMs));
} else if (command == "skip_distance") {
BleFingerprintCollection::skipDistance = pay.toFloat();
spurt("/skip_dist", pay);
BleFingerprintCollection::skipDistance = pay.isEmpty() ? DEFAULT_SKIP_DISTANCE : pay.toFloat();
spurt("/skip_dist", String(skipDistance));
} else if (command == "max_distance") {
maxDistance = pay.toFloat();
spurt("/max_dist", pay);
maxDistance = pay.isEmpty() ? DEFAULT_MAX_DISTANCE : pay.toFloat();
spurt("/max_dist", String(maxDistance));
} else if (command == "absorption") {
absorption = pay.toFloat();
spurt("/absorption", pay);
absorption = pay.isEmpty() ? DEFAULT_ABSORPTION : pay.toFloat();
spurt("/absorption", String(absorption));
} else if (command == "rx_adj_rssi") {
rxAdjRssi = (int8_t)pay.toInt();
spurt("/rx_adj_rssi", pay);
rxAdjRssi = pay.isEmpty() ? DEFAULT_RX_ADJ_RSSI : (int8_t)pay.toInt();
spurt("/rx_adj_rssi", String(rxAdjRssi));
} else if (command == "ref_rssi") {
rxRefRssi = (int8_t)pay.toInt();
spurt("/ref_rssi", pay);
rxRefRssi = pay.isEmpty() ? DEFAULT_RX_REF_RSSI : (int8_t)pay.toInt();
spurt("/ref_rssi", String(rxRefRssi));
} else if (command == "tx_ref_rssi") {
txRefRssi = (int8_t)pay.toInt();
spurt("/tx_ref_rssi", pay);
txRefRssi = pay.isEmpty() ? DEFAULT_TX_REF_RSSI : (int8_t)pay.toInt();
spurt("/tx_ref_rssi", String(txRefRssi));
} else if (command == "query") {
query = pay;
spurt("/query", pay);
query = pay.isEmpty() ? DEFAULT_QUERY : pay;
spurt("/query", query);
} else if (command == "include") {
include = pay;
spurt("/include", pay);
include = pay.isEmpty() ? DEFAULT_INCLUDE : pay;
spurt("/include", include);
} else if (command == "exclude") {
exclude = pay;
spurt("/exclude", pay);
exclude = pay.isEmpty() ? DEFAULT_EXCLUDE : pay;
spurt("/exclude", exclude);
} else if (command == "known_macs") {
knownMacs = pay;
spurt("/known_macs", pay);
knownMacs = pay.isEmpty() ? DEFAULT_KNOWN_MACS : pay;
spurt("/known_macs", knownMacs);
} else if (command == "known_irks") {
knownIrks = pay;
spurt("/known_irks", pay);
knownIrks = pay.isEmpty() ? DEFAULT_KNOWN_IRKS : pay;
spurt("/known_irks", knownIrks);
} else if (command == "count_ids") {
countIds = pay;
spurt("/count_ids", pay);
countIds = pay.isEmpty() ? DEFAULT_COUNT_IDS : pay;
spurt("/count_ids", countIds);
} else
return false;
return true;
Expand Down
File renamed without changes.
File renamed without changes.
2 changes: 1 addition & 1 deletion lib/handlers/MiFloraHandler.h → src/MiFloraHandler.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
#include <ArduinoJson.h>
#include <AsyncMqttClient.h>
#include <AsyncWiFiSettings.h>
#include <BleFingerprint.h>
#include "BleFingerprint.h"
#include <NimBLEClient.h>
#include <NimBLEDevice.h>

Expand Down
File renamed without changes.
4 changes: 2 additions & 2 deletions lib/handlers/NameModelHandler.h → src/NameModelHandler.h
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
#pragma once
#include<NimBLEClient.h>
#include <NimBLEClient.h>
#include <NimBLEDevice.h>
#include <ArduinoJson.h>
#include <sstream>
#include <AsyncMqttClient.h>
#include <BleFingerprint.h>
#include "BleFingerprint.h"
#include <AsyncWiFiSettings.h>

namespace NameModelHandler {
Expand Down
File renamed without changes.
2 changes: 1 addition & 1 deletion src/globals.h
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
#include <AsyncMqttClient.h>
#include <ESPAsyncWebServer.h>
#include <ArduinoJson.h>
#include <BleFingerprintCollection.h>
#include "BleFingerprintCollection.h"

/*----------------------------------------------------------------------------
globals.h
Expand Down
22 changes: 0 additions & 22 deletions src/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -159,28 +159,6 @@ void setupNetwork() {

AsyncWiFiSettings.markExtra();

BleFingerprintCollection::knownMacs = AsyncWiFiSettings.string("known_macs", "", "Known BLE mac addresses (no colons, space seperated)");
BleFingerprintCollection::knownIrks = AsyncWiFiSettings.string("known_irks", "", "Known BLE identity resolving keys, should be 32 hex chars space seperated");

BleFingerprintCollection::query = AsyncWiFiSettings.string("query", DEFAULT_QUERY, "Query device ids for characteristics (eg. flora:)");
BleFingerprintCollection::requeryMs = AsyncWiFiSettings.integer("requery_ms", 30, 3600, 300, "Requery interval in seconds") * 1000;

BleFingerprintCollection::countIds = AsyncWiFiSettings.string("count_ids", "", "Include id prefixes (space seperated)");
BleFingerprintCollection::countEnter = AsyncWiFiSettings.floating("count_enter", 0, 100, 2, "Start counting devices less than distance (in meters)");
BleFingerprintCollection::countExit = AsyncWiFiSettings.floating("count_exit", 0, 100, 4, "Stop counting devices greater than distance (in meters)");
BleFingerprintCollection::countMs = AsyncWiFiSettings.integer("count_ms", 0, 3000000, 30000, "Include devices with age less than (in ms)");

BleFingerprintCollection::include = AsyncWiFiSettings.string("include", DEFAULT_INCLUDE, "Include only sending these ids to mqtt (eg. apple:iphone10-6 apple:iphone13-2)");
BleFingerprintCollection::exclude = AsyncWiFiSettings.string("exclude", DEFAULT_EXCLUDE, "Exclude sending these ids to mqtt (eg. exp:20 apple:iphone10-6)");
BleFingerprintCollection::maxDistance = AsyncWiFiSettings.floating("max_dist", 0, 100, DEFAULT_MAX_DISTANCE, "Maximum distance to report (in meters)");
BleFingerprintCollection::skipDistance = AsyncWiFiSettings.floating("skip_dist", 0, 10, DEFAULT_SKIP_DISTANCE, "Report early if beacon has moved more than this distance (in meters)");
BleFingerprintCollection::skipMs = AsyncWiFiSettings.integer("skip_ms", 0, 3000000, DEFAULT_SKIP_MS, "Skip reporting if message age is less that this (in milliseconds)");

BleFingerprintCollection::rxRefRssi = AsyncWiFiSettings.integer("ref_rssi", -100, 100, DEFAULT_RX_REF_RSSI, "Rssi expected from a 0dBm transmitter at 1 meter (NOT used for iBeacons or Eddystone)");
BleFingerprintCollection::rxAdjRssi = AsyncWiFiSettings.integer("rx_adj_rssi", -100, 100, 0, "Rssi adjustment for receiver (use only if you know this device has a weak antenna)");
BleFingerprintCollection::absorption = AsyncWiFiSettings.floating("absorption", -100, 100, DEFAULT_ABSORPTION, "Factor used to account for absorption, reflection, or diffraction");
BleFingerprintCollection::forgetMs = AsyncWiFiSettings.integer("forget_ms", 0, 3000000, DEFAULT_FORGET_MS, "Forget beacon if not seen for (in milliseconds)");
BleFingerprintCollection::txRefRssi = AsyncWiFiSettings.integer("tx_ref_rssi", -100, 100, DEFAULT_TX_REF_RSSI, "Rssi expected from this tx power at 1m (used for node iBeacon)");

GUI::ConnectToWifi();

Expand Down
File renamed without changes.
Loading

0 comments on commit dc97990

Please sign in to comment.