예제 #1
0
    def start_beacon(self):
        """
        Start beacon advertising
        """
        if not self.dongle.powered:
            self.dongle.powered = True
        ad_manager = advertisement.AdvertisingManager(self.dongle.path)
        ad_manager.register_advertisement(self.broadcaster, {})

        try:
            tools.start_mainloop()
        except KeyboardInterrupt:
            tools.stop_mainloop()
            ad_manager.unregister_advertisement(self.broadcaster)
        finally:
            pass
예제 #2
0
    def start_beacon(self):
        """
        Start beacon advertising
        """
        if not self.dongle.powered:
            self.dongle.powered = True
        ad_manager = advertisement.AdvertisingManager(self.dongle.path)
        ad_manager.register_advertisement(self.broadcaster, {})

        try:
            tools.start_mainloop()
        except KeyboardInterrupt:
            tools.stop_mainloop()
            ad_manager.unregister_advertisement(self.broadcaster)
        finally:
            pass
예제 #3
0
to load a web page from it actually hosts the web page on the
device and services it up from the BLE characteristic
</p> </body> </html>"""
    html_ord = []
    for char in html_string:
        html_ord.append(ord(char))

    app = localGATT.Application()
    srv = localGATT.Service(1, FAT_SERVICE, True)
    fat_html = localGATT.Characteristic(1, HTML_CHRC, srv, html_ord, False, ["read"])
    fat_html.service = srv.path
    app.add_managed_object(srv)
    app.add_managed_object(fat_html)
    srv_mng = GATT.GattManager("/org/bluez/hci0")
    srv_mng.register_application(app, {})


if __name__ == "__main__":

    ad_manager, advertiser = advertise_beacon()

    build_fat_service()

    try:
        tools.start_mainloop()
    except KeyboardInterrupt:
        tools.stop_mainloop()
        ad_manager.unregister_advertisement(advertiser)
    finally:
        pass
예제 #4
0
device and services it up from the BLE characteristic
</p> </body> </html>"""
    html_ord = []
    for char in html_string:
        html_ord.append(ord(char))

    app = localGATT.Application()
    srv = localGATT.Service(1, FAT_SERVICE, True)
    fat_html = localGATT.Characteristic(1, HTML_CHRC, srv, html_ord, False,
                                        ['read'])
    fat_html.service = srv.path
    app.add_managed_object(srv)
    app.add_managed_object(fat_html)
    srv_mng = GATT.GattManager('/org/bluez/hci0')
    srv_mng.register_application(app, {})


if __name__ == '__main__':

    ad_manager, advertiser = advertise_beacon()

    build_fat_service()

    try:
        tools.start_mainloop()
    except KeyboardInterrupt:
        tools.stop_mainloop()
        ad_manager.unregister_advertisement(advertiser)
    finally:
        pass