Skip to content

Commit

Permalink
BLE: Allow custom MAC in beacon packet definition
Browse files Browse the repository at this point in the history
And change the MAC for micro:bit example.
  • Loading branch information
Fabien-Chouteau committed Jul 13, 2018
1 parent 6efe216 commit 556ea3e
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 7 deletions.
10 changes: 6 additions & 4 deletions examples/MicroBit/src/beacon.adb
Expand Up @@ -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);
Expand Down
5 changes: 3 additions & 2 deletions middleware/src/BLE/bluetooth_low_energy-beacon.adb
Expand Up @@ -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
Expand All @@ -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
Expand Down
3 changes: 2 additions & 1 deletion middleware/src/BLE/bluetooth_low_energy-beacon.ads
Expand Up @@ -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;

0 comments on commit 556ea3e

Please sign in to comment.