-
Notifications
You must be signed in to change notification settings - Fork 119
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #963 from shankari/add_bluetooth_support
🗃️ Plumb through the BLE objects to the server
- Loading branch information
Showing
10 changed files
with
97 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
import logging | ||
import enum as enum | ||
import emission.core.wrapper.wrapperbase as ecwb | ||
|
||
class BLEEventTypes(enum.Enum): | ||
REGION_ENTER = 0 | ||
REGION_EXIT = 1 | ||
RANGE_UPDATE = 2 | ||
|
||
class Bluetoothble(ecwb.WrapperBase): | ||
props = {"eventType": ecwb.WrapperBase.Access.RO, # the type of event | ||
"uuid": ecwb.WrapperBase.Access.RO, # UUID of the beacon. Will be a constant for beacons used by e-mission, consistent with https://github.com/e-mission/e-mission-docs/issues/1062#issuecomment-2026359038 | ||
"major": ecwb.WrapperBase.Access.RO, # major value (matches deployment) | ||
"minor": ecwb.WrapperBase.Access.RO, # minor value (matches the actual vehicle) | ||
"ts": ecwb.WrapperBase.Access.RO, # timestamp (in seconds) | ||
"proximity": ecwb.WrapperBase.Access.RO, # how close the beacon is (used as the second step in the process, https://github.com/e-mission/e-mission-docs/issues/1062#issuecomment-2026359038 | ||
"local_dt": ecwb.WrapperBase.Access.RO, # searchable datetime in local time | ||
"fmt_time": ecwb.WrapperBase.Access.RO, # formatted time | ||
"accuracy": ecwb.WrapperBase.Access.RO, # only available for range updats | ||
"rssi": ecwb.WrapperBase.Access.RO, # signal strength, only available for range updates | ||
} | ||
|
||
enums = {"eventType": BLEEventTypes} | ||
geojson = [] | ||
nullable = ["major", "minor", "proximity", "accuracy", "rssi"] | ||
local_dates = ['local_dt'] | ||
|
||
def _populateDependencies(self): | ||
pass |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
26 changes: 26 additions & 0 deletions
26
emission/net/usercache/formatters/android/bluetooth_ble.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
import logging | ||
|
||
import emission.core.wrapper.bluetoothble as ecwb | ||
import emission.net.usercache.formatters.common as fc | ||
import attrdict as ad | ||
|
||
def format(entry): | ||
formatted_entry = ad.AttrDict() | ||
formatted_entry["_id"] = entry["_id"] | ||
formatted_entry.user_id = entry.user_id | ||
|
||
metadata = entry.metadata | ||
if "time_zone" not in metadata: | ||
metadata.time_zone = "America/Los_Angeles" | ||
fc.expand_metadata_times(metadata) | ||
formatted_entry.metadata = metadata | ||
|
||
#logging.info('*** Motion Data write_ts: %d' % metadata.write_ts) | ||
|
||
data = entry.data | ||
data.local_dt = formatted_entry.metadata.write_local_dt | ||
data.fmt_time = formatted_entry.metadata.write_fmt_time | ||
data.eventType = ecwb.BLEEventTypes[entry.data.eventType].value | ||
formatted_entry.data = data | ||
|
||
return formatted_entry |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
import logging | ||
|
||
import emission.core.wrapper.bluetoothble as ecwb | ||
import emission.net.usercache.formatters.common as fc | ||
import attrdict as ad | ||
import pandas as pd | ||
import numpy as np | ||
|
||
def format(entry): | ||
formatted_entry = ad.AttrDict() | ||
formatted_entry["_id"] = entry["_id"] | ||
formatted_entry.user_id = entry.user_id | ||
|
||
metadata = entry.metadata | ||
fc.expand_metadata_times(metadata) | ||
formatted_entry.metadata = metadata | ||
|
||
data = entry.data | ||
data.local_dt = formatted_entry.metadata.write_local_dt | ||
data.fmt_time = formatted_entry.metadata.write_fmt_time | ||
data.eventType = ecwb.BLEEventTypes[entry.data.eventType].value | ||
formatted_entry.data = data | ||
|
||
return formatted_entry |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters