class MyAdvertising(object): '''Beacon advertising class''' def __init__(self, sec=5): self.my_uuid = "11111111-2222-3333-4444-555555555555" self.my_major = 1 self.my_minor = 1 self.my_txpower = 1 self.my_interval = 200 self.service = BeaconService("hci0") self.advertise(sec) def advertise(self, sec=5): print("start Advertising.") self.service.start_advertising(self.my_uuid, self.my_major, self.my_minor, self.my_txpower, self.my_interval) #service.start_advertising("11111111-2222-3333-4444-555555555555",1,1,1,200) time.sleep(sec) self.service.stop_advertising() print("Done Advertising.")
#!/usr/bin/python # -*- mode: python; coding: utf-8 -*- # Copyright (C) 2014, Oscar Acena <*****@*****.**> # This software is under the terms of Apache License v2 or later. from gattlib import BeaconService import time service = BeaconService("hci0") service.start_advertising("11111111-2222-3333-4444-555555555555", 1, 1, 1, 200) time.sleep(5) service.stop_advertising() print("Done.")
#!/usr/bin/python3 # -*- mode: python; coding: utf-8 -*- # Copyright (C) 2014, Oscar Acena <*****@*****.**> # This software is under the terms of Apache License v2 or later. from gattlib import BeaconService import time service = BeaconService("hci0") service.start_advertising("11111111-2222-3333-4444-555555555555", 1, 1, 1, 200) time.sleep(5) service.stop_advertising() print("Done.")