Skip to content

Commit

Permalink
Part of 113. Begun to refactor Herald mesh services code.
Browse files Browse the repository at this point in the history
Signed-off-by: Adam Fowler <[email protected]>
  • Loading branch information
adamfowleruk committed Apr 15, 2022
1 parent f1198d9 commit 897d587
Show file tree
Hide file tree
Showing 2 changed files with 53 additions and 7 deletions.
9 changes: 5 additions & 4 deletions herald-mesh-relay/src/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -200,24 +200,23 @@ void herald_entry()

// Disable receiver / scanning mode - we're just transmitting our value
BLESensorConfiguration config = ctx.getSensorConfiguration(); // copy ctor
config.scanningEnabled = false;
config.scanningEnabled = true; // To see other nearby BLE devices
// config.advertisingEnabled = true; // default
ctx.setSensorConfiguration(config);

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

// TODO get this from configuration of the MESH element (Nav beacon model)
payload::beacon::ConcreteBeaconPayloadDataSupplierV1 pds(
erinsStakehouse.country,
erinsStakehouse.state,
erinsStakehouse.code,
extendedData);

herald::ble::nordic_uart::NordicUartSensorDelegate nus(ctx);

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

ConcreteBLESensor ble(ctx, ctx.getBluetoothStateManager(), pds, sensorDelegates);
SensorArray sa(ctx, pds, ble);
Expand Down Expand Up @@ -286,6 +285,8 @@ void main(void)
APP_DBG("Bluetooth init failed (err %d)", err);
}

// TODO don't start Herald until enrolled and configured via MESH

// Start herald entry on a new thread in case of errors, or needing to do something on the main thread
[[maybe_unused]]
k_tid_t herald_pid = k_thread_create(&herald_thread, herald_stack, stackMaxSize,
Expand Down
51 changes: 48 additions & 3 deletions herald/include/herald/mesh/location_services.h
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,12 @@
extern "C" {
#endif

/**
* Herald device and other Bluetooth LE Proximity Server.
*/

/** Bluetooth MESH Herald presence values **/
enum bt_mesh_herald_location_services_cli_presence {
enum bt_mesh_model_herald_presence_status {
BT_MESH_HERALD_PRESENCE_OBSERVED,
BT_MESH_HERALD_PRESENCE_IDENTIFIED,
BT_MESH_HERALD_PRESENCE_VANISHED
Expand All @@ -25,13 +28,55 @@ enum bt_mesh_herald_location_services_cli_presence {
/**
* \brief Herald presence message for a BLE node near a beacon
*/
struct bt_mesh_herald_location_services_presence {
struct bt_mesh_model_herald_presence {
/** \brief BLE Mac Address **/
uint8_t address[6];
/** \brief The last RSSI observed **/
int8_t rssi;
/** \brief The current derived presence status for this observer **/
enum bt_mesh_herald_location_services_cli_presence status;
enum bt_mesh_model_herald_presence_status status;
};



/**
* Herald campus navigation capabilities via MESH.
*/

/**
* \brief Herald location beacon model, adapted for MESH
* and campus navigation.
* @see herald::payload::beacon::ConcreteBeaconPayloadDataSupplierV1
*/
struct bt_mesh_model_herald_location_beacon {
/** \brief Herald Location Country **/
uint16_t country;
/** \brief Herald Location State **/
uint16_t state;
/** \brief Herald Location Code (NOT beacon identifier) **/
uint32_t code;
/**
* \brief Herald Location Beacon ID (Beacon identifier)
* \since v2.2
**/
uint16_t id;

// Note: We only supported limited extension fields
/**
* \brief Location further information URL
* \note 0x13 in Herald Extended data area. MUST be https.
**/
char* ext_url;
/** \brief Length of location URL **/
uint16_t ext_url_length; // URL GET is max 2048 thus 11 bytes for length

// char* ext_name; // 0x10 in Herald Extended data area
// size_t ext_name_length;

// char* ext_location; // 0x11 in Herald Extended data area
// size_t ext_location_length;

// TODO public security key for beacon later
};


Expand Down

0 comments on commit 897d587

Please sign in to comment.