def advertising(name): adapter = get_provider().get_adapter() advertiser = Advertiser(adapter) advertisement = Advertisement() deviceName = updateName(name) #print("CHANGE >> "+deviceName) change(deviceName) advertisement.name = name advertiser.advertisement = advertisement color = deviceName[1] advertiser.start() #print("color >> "+color) if (color == "1"): lighting(LIGHT_GREEN) elif (color == "2"): lighting(LIGHT_YELLOW) elif (color == "3"): lighting(LIGHT_RED) elif (color == "4"): lighting(LIGHT_BLUE) sleep(1) advertiser.stop()
def advertising(deviceName): adapter = get_provider().get_adapter() advertiser = Advertiser(adapter) advertisement = Advertisement() advertisement.name = deviceName advertiser.advertisement = advertisement advertiser.start() sleep(5) advertiser.stop()
#!/usr/bin/env python3 import sys from time import sleep from bleson import get_provider, Advertiser, Advertisement # Get the wait time from the first script argument or default it to 10 seconds WAIT_TIME = int(sys.argv[1]) if len(sys.argv) > 1 else 10 with Advertiser(get_provider().get_adapter(), Advertisement(name='bleson', raw_data=bytearray([0, 1]))): sleep(WAIT_TIME)
#!/usr/bin/env python3 import sys from logging import DEBUG from time import sleep from bleson import get_provider, Advertiser, Advertisement # Get the wait time from the first script argument or default it to 10 seconds WAIT_TIME = int(sys.argv[1]) if len(sys.argv) > 1 else 10 adapter = get_provider().get_adapter() advertiser = Advertiser(adapter) advertisement = Advertisement() advertisement.name = "bleson" advertiser.advertisement = advertisement advertiser.start() sleep(WAIT_TIME) advertiser.stop()
def stopadvertising(): adapter = get_provider().get_adapter() advertiser = Advertiser(adapter) advertisement = Advertisement() advertiser.advertisement = advertisement advertiser.stop()
#!/usr/bin/env python3 import sys from time import sleep from bleson import get_provider, Advertiser, Advertisement # Get the wait time from the first script argument or default it to 10 seconds WAIT_TIME = int(sys.argv[1]) if len(sys.argv) > 1 else 10 with Advertiser(get_provider().get_adapter(), Advertisement(name='bleson')): sleep(WAIT_TIME)