コード例 #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
ファイル: fatbeacon.py プロジェクト: ukBaz/python-bluezero
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