-
Notifications
You must be signed in to change notification settings - Fork 5
/
main.bgs
26 lines (22 loc) · 994 Bytes
/
main.bgs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
dim nil
dim adv_data(30)
procedure load_adv_data()
# Fixed payload header
adv_data(0:3) = $060102 # 02 01 06 # Flags
adv_data(3:2) = $ff1a # 1a ff # Manufacturer data
adv_data(5:4) = $1502004c # 4c 00 02 15 # Preamble
# Read iBeacon conf from GATT file
call attributes_read(xgatt_ibeacon_uuid, 0)(nil, nil, nil, nil, adv_data(9:16))
call attributes_read(xgatt_ibeacon_major, 0)(nil, nil, nil, nil, adv_data(25:2))
call attributes_read(xgatt_ibeacon_minor, 0)(nil, nil, nil, nil, adv_data(27:2))
call attributes_read(xgatt_ibeacon_tx_pwr, 0)(nil, nil, nil, nil, adv_data(29:1))
end
event system_boot(major, minor, patch, builvar, ll_version, protocol_version, hw)
call load_adv_data()
call gap_set_adv_parameters(1600, 1600, 7)
call gap_set_adv_data(0, 30, adv_data(0:30))
call gap_set_mode(gap_user_data, gap_undirected_connectable)
end
event connection_disconnected(handle, result)
call gap_set_mode(gap_user_data, gap_undirected_connectable)
end