add bluetooth and UWB parameters to RangingBeacon model
This commit is contained in:
parent
0fd789173a
commit
372db50224
5 changed files with 41 additions and 13 deletions
|
@ -17,7 +17,7 @@ class Command(BaseCommand):
|
||||||
found_beacons.setdefault(measurement["bssid"], []).append((wifi_measurement, measurement))
|
found_beacons.setdefault(measurement["bssid"], []).append((wifi_measurement, measurement))
|
||||||
|
|
||||||
# put in the ones we know
|
# put in the ones we know
|
||||||
known = {r.bssid: r for r in RangingBeacon.objects.all()}
|
known = {r.wifi_bssid: r for r in RangingBeacon.objects.all()}
|
||||||
|
|
||||||
# lets go through them
|
# lets go through them
|
||||||
for bssid, measurements in found_beacons.items():
|
for bssid, measurements in found_beacons.items():
|
||||||
|
|
|
@ -482,12 +482,40 @@ class RangingBeacon(SpaceGeometryMixin, models.Model):
|
||||||
A ranging beacon
|
A ranging beacon
|
||||||
"""
|
"""
|
||||||
geometry = GeometryField('point')
|
geometry = GeometryField('point')
|
||||||
bssid = models.CharField(_('BSSID'), max_length=17, unique=True,
|
|
||||||
validators=[RegexValidator(
|
node_number = models.PositiveSmallIntegerField(_('Node Number'), unique=True, null=True, blank=True)
|
||||||
regex='^([a-f0-9]{2}:){5}[a-f0-9]{2}$',
|
|
||||||
message='Must be a lower-case bssid',
|
wifi_bssid = models.CharField(_('WiFi BSSID'), unique=True, null=True, blank=True,
|
||||||
code='invalid_bssid'
|
max_length=17,
|
||||||
)])
|
validators=[RegexValidator(
|
||||||
|
regex='^([a-f0-9]{2}:){5}[a-f0-9]{2}$',
|
||||||
|
message='Must be a lower-case bssid',
|
||||||
|
code='invalid_bssid'
|
||||||
|
)],
|
||||||
|
help_text=_("uses node's value if not set"))
|
||||||
|
bluetooth_address = models.CharField(_('Bluetooth Address'), unique=True, null=True, blank=True,
|
||||||
|
max_length=17,
|
||||||
|
validators=[RegexValidator(
|
||||||
|
regex='^([a-f0-9]{2}:){5}[a-f0-9]{2}$',
|
||||||
|
message='Must be a lower-case mac address',
|
||||||
|
code='invalid_bluetooth_address'
|
||||||
|
)],
|
||||||
|
help_text=_("uses node's value if not set"))
|
||||||
|
ibeacon_uuid = models.UUIDField(_('iBeacon UUID'), null=True, blank=True,
|
||||||
|
help_text=_("uses node's value if not set"))
|
||||||
|
ibeacon_major = models.PositiveIntegerField(_('iBeacon major value'), null=True, blank=True,
|
||||||
|
help_text=_("uses node's value if not set"))
|
||||||
|
ibeacon_minor = models.PositiveIntegerField(_('iBeacon minor value'), null=True, blank=True,
|
||||||
|
help_text=_("uses node's value if not set"))
|
||||||
|
uwb_address = models.CharField(_('UWB Address'), unique=True, null=True, blank=True,
|
||||||
|
max_length=23,
|
||||||
|
validators=[RegexValidator(
|
||||||
|
regex='^([a-f0-9]{2}:){7}[a-f0-9]{2}$',
|
||||||
|
message='Must be a lower-case 8-byte UWB address',
|
||||||
|
code='invalid_uwb_address'
|
||||||
|
)],
|
||||||
|
help_text=_("uses node's value if not set"))
|
||||||
|
|
||||||
altitude = models.DecimalField(_('altitude above ground'), max_digits=6, decimal_places=2, default=0,
|
altitude = models.DecimalField(_('altitude above ground'), max_digits=6, decimal_places=2, default=0,
|
||||||
validators=[MinValueValidator(Decimal('0'))])
|
validators=[MinValueValidator(Decimal('0'))])
|
||||||
comment = models.TextField(null=True, blank=True, verbose_name=_('comment'))
|
comment = models.TextField(null=True, blank=True, verbose_name=_('comment'))
|
||||||
|
@ -508,5 +536,5 @@ class RangingBeacon(SpaceGeometryMixin, models.Model):
|
||||||
@property
|
@property
|
||||||
def title(self):
|
def title(self):
|
||||||
if self.comment:
|
if self.comment:
|
||||||
return f'{self.bssid} ({self.comment})'
|
return f'{self.wifi_bssid} ({self.comment})'
|
||||||
return self.bssid
|
return self.wifi_bssid
|
||||||
|
|
|
@ -189,7 +189,7 @@ def firmware_upload(request, firmware_data: UploadFirmwareSchema, binary_files:
|
||||||
|
|
||||||
build = version.builds.create(
|
build = version.builds.create(
|
||||||
variant=build_data.variant,
|
variant=build_data.variant,
|
||||||
chip=image.ext_header.chip,
|
chip=image.ext_header.chip.c_value,
|
||||||
sha256_hash=image.app_desc.app_elf_sha256,
|
sha256_hash=image.app_desc.app_elf_sha256,
|
||||||
project_description=build_data.project_description,
|
project_description=build_data.project_description,
|
||||||
binary=binary_files_by_name[build_data.uploaded_filename],
|
binary=binary_files_by_name[build_data.uploaded_filename],
|
||||||
|
|
|
@ -186,7 +186,7 @@ class MeshNodeQuerySet(models.QuerySet):
|
||||||
try:
|
try:
|
||||||
for ranging_beacon in RangingBeacon.objects.filter(bssid__in=nodes.keys()).select_related('space'):
|
for ranging_beacon in RangingBeacon.objects.filter(bssid__in=nodes.keys()).select_related('space'):
|
||||||
# noinspection PyUnresolvedReferences
|
# noinspection PyUnresolvedReferences
|
||||||
nodes[ranging_beacon.bssid]._ranging_beacon = ranging_beacon
|
nodes[ranging_beacon.wifi_bssid]._ranging_beacon = ranging_beacon
|
||||||
for node in nodes.values():
|
for node in nodes.values():
|
||||||
if not hasattr(node, "_ranging_beacon"):
|
if not hasattr(node, "_ranging_beacon"):
|
||||||
node._ranging_beacon = None
|
node._ranging_beacon = None
|
||||||
|
@ -415,7 +415,7 @@ def firmware_upload_path(instance, filename):
|
||||||
|
|
||||||
|
|
||||||
class FirmwareBuild(models.Model):
|
class FirmwareBuild(models.Model):
|
||||||
CHIPS = [(chiptype.value, chiptype.pretty_name) for chiptype in ChipType]
|
CHIPS = [(chiptype.c_value, chiptype.pretty_name) for chiptype in ChipType]
|
||||||
|
|
||||||
version = models.ForeignKey(FirmwareVersion, related_name='builds', on_delete=models.CASCADE)
|
version = models.ForeignKey(FirmwareVersion, related_name='builds', on_delete=models.CASCADE)
|
||||||
variant = models.CharField(_('variant name'), max_length=64)
|
variant = models.CharField(_('variant name'), max_length=64)
|
||||||
|
|
|
@ -70,7 +70,7 @@ class Locator:
|
||||||
|
|
||||||
def _rebuild(self, router):
|
def _rebuild(self, router):
|
||||||
for beacon in RangingBeacon.objects.all():
|
for beacon in RangingBeacon.objects.all():
|
||||||
peer_id = self.get_peer_id(beacon.bssid, create=True)
|
peer_id = self.get_peer_id(beacon.wifi_bssid, create=True)
|
||||||
self.peers[peer_id].xyz = (
|
self.peers[peer_id].xyz = (
|
||||||
int(beacon.geometry.x * 100),
|
int(beacon.geometry.x * 100),
|
||||||
int(beacon.geometry.y * 100),
|
int(beacon.geometry.y * 100),
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue