Skip to content

Commit

Permalink
Part of theheraldproject#113. Can now programme and run beacon and me…
Browse files Browse the repository at this point in the history
…sh on dongle.

Working samples on dongle
- Use nrf52840dongle_nrf52840 BOARD type
- Can programme Venue Beacon to Maker Diary nRF52840 MDK USB Dongle
- Venue Beacon works fine
- Can programme MESH Relay to same dongle
- Fails within 1 second of provisioning - likely a dk_prov incompatibility
- Need to create new, dummy (no OOB) provisioner for now as a placeholder
Signed off by: Adam Fowler <[email protected]>
  • Loading branch information
adamfowleruk committed Apr 23, 2022
1 parent 77b3d28 commit bea25c1
Show file tree
Hide file tree
Showing 4 changed files with 97 additions and 89 deletions.
3 changes: 2 additions & 1 deletion herald-mesh-relay/.vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,8 @@
"cmake.configureEnvironment": {
// "BOARD": "nrf52dk_nrf52832"
// "BOARD": "nrf52833dk_nrf52833"
"BOARD": "nrf52840dk_nrf52840"
// "BOARD": "nrf52840dk_nrf52840"
"BOARD": "nrf52840dongle_nrf52840" // Maker Diary nrf52840mdk-dongle
// "BOARD": "nrf5340dk_nrf5340_cpuapp"
// ,"HERALD_ANALYSIS_ENABLED":"y"
},
Expand Down
165 changes: 83 additions & 82 deletions herald-mesh-relay/src/herald_handler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -56,87 +56,88 @@ constexpr int stackMaxSize =
K_THREAD_STACK_DEFINE(herald_stack,
stackMaxSize); // Was 9192 for nRF5340 (10 conns), 2048
// for nRF52832 (3 conns)

class AppLoggingDelegate {
public:
AppLoggingDelegate() = default;
~AppLoggingDelegate() = default;

void sensor(SensorType sensor, const TargetIdentifier& didDetect) {
// LOG_DBG("sensor didDetect");
APP_DBG("sensor didDetect: %s",
str(didDetect)); // May want to disable this - logs A LOT of info
}

/// Read payload data from target, e.g. encrypted device identifier from BLE
/// peripheral after successful connection.
void sensor(SensorType sensor, const PayloadData& didRead,
const TargetIdentifier& fromTarget) {
// LOG_DBG("sensor didRead");
APP_DBG("sensor didRead: %s with payload: %s", str(fromTarget),
log_strdup(didRead.hexEncodedString().c_str()));
}

/// Receive written immediate send data from target, e.g. important timing
/// signal.
void sensor(SensorType sensor, const ImmediateSendData& didReceive,
const TargetIdentifier& fromTarget) {
// LOG_DBG("sensor didReceive");
APP_DBG("sensor didReceive: %s with immediate send data: %s",
str(fromTarget), log_strdup(didReceive.hexEncodedString().c_str()));
}

/// Read payload data of other targets recently acquired by a target, e.g.
/// Android peripheral sharing payload data acquired from nearby iOS
/// peripherals.
void sensor(SensorType sensor, const std::vector<PayloadData>& didShare,
const TargetIdentifier& fromTarget) {
APP_DBG("sensor didShare");
// LOG_DBG("sensor didShare: %s", str(fromTarget) );
// for (auto& p : didShare) {
// LOG_DBG(" - %s", log_strdup(p.hexEncodedString().c_str()));
// }
}

/// Measure proximity to target, e.g. a sample of RSSI values from BLE
/// peripheral.
void sensor(SensorType sensor, const Proximity& didMeasure,
const TargetIdentifier& fromTarget) {
APP_DBG(
"didMeasure: %s, fromTarget: %s",
log_strdup(didMeasure.description().c_str()),
log_strdup(
((std::string)BLEMacAddress(fromTarget.underlyingData())).c_str()));
// LOG_DBG("sensor didMeasure: %s with proximity: %d", str(fromTarget),
// didMeasure.value);
}

/// Detection of time spent at location, e.g. at specific restaurant between
/// 02/06/2020 19:00 and 02/06/2020 21:00
template <typename LocationT>
void sensor(SensorType sensor, const Location<LocationT>& didVisit) {
APP_DBG("sensor didVisit");
}

/// Measure proximity to target with payload data. Combines didMeasure and
/// didRead into a single convenient delegate method
void sensor(SensorType sensor, const Proximity& didMeasure,
const TargetIdentifier& fromTarget,
const PayloadData& withPayload) {
// ERR so it stands out in the logging!
APP_ERR(
"didMeasure=%s, fromTarget=%s, withPayload=%s",
log_strdup(didMeasure.description().c_str()),
log_strdup(
((std::string)BLEMacAddress(fromTarget.underlyingData())).c_str()),
log_strdup(withPayload.hexEncodedString().c_str()));
}

/// Sensor state update
void sensor(SensorType sensor, const SensorState& didUpdateState) {
APP_DBG("sensor didUpdateState");
}
};
struct DummyDelegate{};
// using namespace herald::datatype;
// class AppLoggingDelegate {
// public:
// AppLoggingDelegate() = default;
// ~AppLoggingDelegate() = default;

// void sensor(SensorType sensor, const TargetIdentifier& didDetect) {
// // LOG_DBG("sensor didDetect");
// APP_DBG("sensor didDetect: %s",
// str(didDetect)); // May want to disable this - logs A LOT of info
// }

// /// Read payload data from target, e.g. encrypted device identifier from BLE
// /// peripheral after successful connection.
// void sensor(SensorType sensor, const PayloadData& didRead,
// const TargetIdentifier& fromTarget) {
// // LOG_DBG("sensor didRead");
// APP_DBG("sensor didRead: %s with payload: %s", str(fromTarget),
// log_strdup(didRead.hexEncodedString().c_str()));
// }

// /// Receive written immediate send data from target, e.g. important timing
// /// signal.
// void sensor(SensorType sensor, const ImmediateSendData& didReceive,
// const TargetIdentifier& fromTarget) {
// // LOG_DBG("sensor didReceive");
// APP_DBG("sensor didReceive: %s with immediate send data: %s",
// str(fromTarget), log_strdup(didReceive.hexEncodedString().c_str()));
// }

// /// Read payload data of other targets recently acquired by a target, e.g.
// /// Android peripheral sharing payload data acquired from nearby iOS
// /// peripherals.
// void sensor(SensorType sensor, const std::vector<PayloadData>& didShare,
// const TargetIdentifier& fromTarget) {
// APP_DBG("sensor didShare");
// // LOG_DBG("sensor didShare: %s", str(fromTarget) );
// // for (auto& p : didShare) {
// // LOG_DBG(" - %s", log_strdup(p.hexEncodedString().c_str()));
// // }
// }

// /// Measure proximity to target, e.g. a sample of RSSI values from BLE
// /// peripheral.
// void sensor(SensorType sensor, const Proximity& didMeasure,
// const TargetIdentifier& fromTarget) {
// APP_DBG(
// "didMeasure: %s, fromTarget: %s",
// log_strdup(didMeasure.description().c_str()),
// log_strdup(
// ((std::string)BLEMacAddress(fromTarget.underlyingData())).c_str()));
// // LOG_DBG("sensor didMeasure: %s with proximity: %d", str(fromTarget),
// // didMeasure.value);
// }

// /// Detection of time spent at location, e.g. at specific restaurant between
// /// 02/06/2020 19:00 and 02/06/2020 21:00
// template <typename LocationT>
// void sensor(SensorType sensor, const Location<LocationT>& didVisit) {
// APP_DBG("sensor didVisit");
// }

// /// Measure proximity to target with payload data. Combines didMeasure and
// /// didRead into a single convenient delegate method
// void sensor(SensorType sensor, const Proximity& didMeasure,
// const TargetIdentifier& fromTarget,
// const PayloadData& withPayload) {
// // ERR so it stands out in the logging!
// APP_ERR(
// "didMeasure=%s, fromTarget=%s, withPayload=%s",
// log_strdup(didMeasure.description().c_str()),
// log_strdup(
// ((std::string)BLEMacAddress(fromTarget.underlyingData())).c_str()),
// log_strdup(withPayload.hexEncodedString().c_str()));
// }

// /// Sensor state update
// void sensor(SensorType sensor, const SensorState& didUpdateState) {
// APP_DBG("sensor didUpdateState");
// }
// };

using MYUINT32 = unsigned long;

Expand Down Expand Up @@ -208,7 +209,7 @@ void herald_entry() {

// this is unusual, but required. Really we should log activity to serial BLE
// or similar
AppLoggingDelegate appDelegate;
DummyDelegate appDelegate;
SensorDelegateSet sensorDelegates(appDelegate);

ConcreteBLESensor ble(ctx, ctx.getBluetoothStateManager(), pds,
Expand Down
10 changes: 8 additions & 2 deletions herald-venue-beacon/.vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,13 @@
"cmake.configureEnvironment": {
// "BOARD": "nrf52dk_nrf52832"
// "BOARD": "nrf52833dk_nrf52833"
"BOARD": "nrf52840dk_nrf52840"
// "BOARD": "nrf52840dk_nrf52840"
"BOARD": "nrf52840dongle_nrf52840" // Maker Diary nrf52840mdk-dongle
// "BOARD": "nrf5340dk_nrf5340_cpuapp"
}
},
"nrf-connect.topdir": "${nrf-connect.sdk:1.9.1}",
"nrf-connect.toolchain.path": "${nrf-connect.toolchain:1.9.1}",
"nrf-connect.applications": [
"${workspaceFolder}"
]
}
8 changes: 4 additions & 4 deletions herald-venue-beacon/src/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -196,12 +196,12 @@ void herald_entry() {
ctx.setSensorConfiguration(config);

ConcreteExtendedDataV1 extendedData;
extendedData.addSection(ExtendedDataSegmentCodesV1::TextPremises, erinsStakehouse.name);
extendedData.addSection(ExtendedDataSegmentCodesV1::TextPremises, adamsOffice.name);

payload::beacon::ConcreteBeaconPayloadDataSupplierV1 pds(
erinsStakehouse.country,
erinsStakehouse.state,
erinsStakehouse.code,
adamsOffice.country,
adamsOffice.state,
adamsOffice.code,
extendedData
);

Expand Down

0 comments on commit bea25c1

Please sign in to comment.