From 556ea3edf26dc177f4347ea2ff081f12132ebd3a Mon Sep 17 00:00:00 2001 From: Fabien Chouteau Date: Mon, 28 May 2018 21:15:41 +0200 Subject: [PATCH] BLE: Allow custom MAC in beacon packet definition And change the MAC for micro:bit example. --- examples/MicroBit/src/beacon.adb | 10 ++++++---- middleware/src/BLE/bluetooth_low_energy-beacon.adb | 5 +++-- middleware/src/BLE/bluetooth_low_energy-beacon.ads | 3 ++- 3 files changed, 11 insertions(+), 7 deletions(-) diff --git a/examples/MicroBit/src/beacon.adb b/examples/MicroBit/src/beacon.adb index 8a4fa8922..add1eddf5 100644 --- a/examples/MicroBit/src/beacon.adb +++ b/examples/MicroBit/src/beacon.adb @@ -54,10 +54,12 @@ package body Beacon is Make_UUID ((1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16)); begin - Beacon_Packet := Make_Beacon_Packet (UUID => Beacon_UUID, - Major => 0, - Minor => 0, - Power => 0); + Beacon_Packet := Make_Beacon_Packet + (MAC => (16#A1#, 16#AD#, 16#A1#, 16#AD#, 16#A1#, 16#AD#), + UUID => Beacon_UUID, + Major => 0, + Minor => 0, + Power => 0); -- Setup high frequency clock for BLE transmission Set_High_Freq_Source (HFCLK_RC); diff --git a/middleware/src/BLE/bluetooth_low_energy-beacon.adb b/middleware/src/BLE/bluetooth_low_energy-beacon.adb index 1384e1205..ee3c4c942 100644 --- a/middleware/src/BLE/bluetooth_low_energy-beacon.adb +++ b/middleware/src/BLE/bluetooth_low_energy-beacon.adb @@ -32,7 +32,8 @@ package body Bluetooth_Low_Energy.Beacon is - function Make_Beacon_Packet (UUID : BLE_UUID; + function Make_Beacon_Packet (MAC : UInt8_Array; + UUID : BLE_UUID; Major, Minor : UInt16; Power : Integer_8) return BLE_Packet @@ -41,7 +42,7 @@ package body Bluetooth_Low_Energy.Beacon is begin Set_Header (Pck, 16#42#); -- MAC - Push (Pck, (16#FE#, 16#CA#, 16#EF#, 16#BE#, 16#AD#, 16#DE#)); + Push (Pck, MAC); -- Flag length Push (Pck, UInt8 (2)); -- Flag type diff --git a/middleware/src/BLE/bluetooth_low_energy-beacon.ads b/middleware/src/BLE/bluetooth_low_energy-beacon.ads index c6756ddf7..01e27f5b6 100644 --- a/middleware/src/BLE/bluetooth_low_energy-beacon.ads +++ b/middleware/src/BLE/bluetooth_low_energy-beacon.ads @@ -34,7 +34,8 @@ with Interfaces; use Interfaces; package Bluetooth_Low_Energy.Beacon is - function Make_Beacon_Packet (UUID : BLE_UUID; + function Make_Beacon_Packet (MAC : UInt8_Array; + UUID : BLE_UUID; Major, Minor : UInt16; Power : Integer_8) return BLE_Packet; end Bluetooth_Low_Energy.Beacon;