Пример #1
0
    def __init__(self):
        self.bus = dbus.SystemBus()
        self.app = localGATT.Application()
        self.srv = localGATT.Service(1, SERVICE_UUID, True)

        self.charc = localGATT.Characteristic(1, CHAR_UUID, self.srv, [0xBB],
                                              True, ['write'])

        self.charc.service = self.srv.path
        self.app.add_managed_object(self.srv)
        self.app.add_managed_object(self.charc)

        self.srv_mng = GATT.GattManager(adapter.list_adapters()[0])
        self.srv_mng.register_application(self.app, {})

        self.dongle = adapter.Adapter(adapter.list_adapters()[0])
        advert = advertisement.Advertisement(1, 'peripheral')

        advert.service_UUIDs = [SERVICE_UUID]
        eddystone_data = tools.url_to_advert(WEB_BLINKT, 0x10, TX_POWER)
        advert.service_data = {EDDYSTONE: eddystone_data}
        if not self.dongle.powered:
            self.dongle.powered = True
        ad_manager = advertisement.AdvertisingManager(self.dongle.path)
        ad_manager.register_advertisement(advert, {})
Пример #2
0
    def __init__(self):
        self.bus = dbus.SystemBus()
        self.app = localGATT.Application()
        self.srv = localGATT.Service(1, SERVICE_UUID, True)

        self.charc = localGATT.Characteristic(1,
                                              CHAR_UUID,
                                              self.srv,
                                              [0xBB],
                                              True,
                                              ['write'])

        self.charc.service = self.srv.path
        self.app.add_managed_object(self.srv)
        self.app.add_managed_object(self.charc)

        self.srv_mng = GATT.GattManager(adapter.list_adapters()[0])
        self.srv_mng.register_application(self.app, {})

        self.dongle = adapter.Adapter(adapter.list_adapters()[0])
        advert = advertisement.Advertisement(1, 'peripheral')

        advert.service_UUIDs = [SERVICE_UUID]
        eddystone_data = tools.url_to_advert(WEB_BLINKT, 0x10, TX_POWER)
        advert.service_data = {EDDYSTONE: eddystone_data}
        if not self.dongle.powered:
            self.dongle.powered = True
        ad_manager = advertisement.AdvertisingManager(self.dongle.path)
        ad_manager.register_advertisement(advert, {})
Пример #3
0
    def __init__(self, url, tx_power=0x08):
        """

        :param url: String containing URL e.g. ('http://camjam.me')
        :param tx_power: Value of Tx Power of advertisement (Not implemented)

        """
        service_data = tools.url_to_advert(url, 0x10, tx_power)
        if len(service_data) > 17:
            raise Exception('URL too long')
        url_beacon = broadcaster.Beacon()
        url_beacon.add_service_data('FEAA', service_data)
        url_beacon.start_beacon()
Пример #4
0
    def __init__(self, url, tx_power=0x08):
        """

        :param url: String containing URL e.g. ('http://camjam.me')
        :param tx_power: Value of Tx Power of advertisement (Not implemented)

        """
        service_data = tools.url_to_advert(url, 0x10, tx_power)
        if len(service_data) > 17:
            raise Exception('URL too long')
        url_beacon = broadcaster.Beacon()
        url_beacon.add_service_data('FEAA', service_data)
        url_beacon.start_beacon()
Пример #5
0
    def __init__(self, url, tx_power=0x08):
        """
        The Eddystone-URL frame broadcasts a URL using a compressed encoding
        format in order to fit more within the limited advertisement packet.
        Example:
        >>> from bluezero import eddystone
        >>> eddystone.EddystoneURL('https://github.com/ukBaz')

        :param url: String containing URL e.g. ('http://camjam.me')
        :param tx_power:
        """
        service_data = tools.url_to_advert(url, 0x10, tx_power)
        if len(service_data) > 17:
            raise Exception('URL too long')
        url_beacon = broadcaster.Beacon()
        url_beacon.add_service_data('FEAA', service_data)
        url_beacon.start_beacon()
Пример #6
0
    def __init__(self, url, tx_power=0x08):
        """The Eddystone-URL frame broadcasts a URL using a compressed encoding
        format in order to fit more within the limited advertisement packet.
        :Example:

        >>> from bluezero import eddystone
        >>> eddystone.EddystoneURL('https://github.com/ukBaz')

        :param url: String containing URL e.g. ('http://camjam.me')
        :param tx_power:

        """
        service_data = tools.url_to_advert(url, 0x10, tx_power)
        if len(service_data) > 17:
            raise Exception('URL too long')
        url_beacon = broadcaster.Beacon()
        url_beacon.add_service_data('FEAA', service_data)
        url_beacon.start_beacon()
Пример #7
0
 def test(self):
     self.assertEqual(
         tools.url_to_advert(
             'http://camjam.me/', 0x10, 0x00),
         [0x10, 0x00, 0x02, 0x63, 0x61, 0x6D, 0x6A,
          0x61, 0x6D, 0x2E, 0x6D, 0x65, 0x2F])
Пример #8
0
 def test(self):
     self.assertEqual(
         tools.url_to_advert(
             'http://www.csr.com/about', 0x10, 0x00),
         [0x10, 0x00, 0x00, 0x63, 0x73, 0x72,
          0x00, 0x61, 0x62, 0x6f, 0x75, 0x74])
Пример #9
0
 def test(self):
     self.assertEqual(
         tools.url_to_advert(
             'https://www.google.com', 0x10, 0x00),
         [0x10, 0x00, 0x01, 0x67, 0x6f,
          0x6f, 0x67, 0x6c, 0x65, 0x07])
Пример #10
0
import sys
import os

sys.path.insert(0,
                os.path.split(os.path.dirname(os.path.realpath(__file__)))[0])
from bluezero import peripheral
from bluezero import tools

# Bluetooth
# Add beacon information
ukBaz_beacon = peripheral.Service('FEAA', True, type='broadcast')
service_data = tools.url_to_advert('https://github.com/ukBaz',
                                   frame_type=0x10,
                                   tx_power=0xFF)
ukBaz_beacon.add_service_data(service_data)

# Add application
app = peripheral.Application()
app.add_service(ukBaz_beacon)

app.add_device_name('ukBazBeacon')

# Start service and advertise
try:
    app.start()
except KeyboardInterrupt:
    print('KeyboardInterrupt')
finally:
    app.stop()
    print('finally')
 def test(self):
     self.assertEqual(
         tools.url_to_advert(
             'http://camjam.me/', 0x10, 0x00),
         [0x10, 0x00, 0x02, 0x63, 0x61, 0x6D, 0x6A,
          0x61, 0x6D, 0x2E, 0x6D, 0x65, 0x2F])
 def test(self):
     self.assertEqual(
         tools.url_to_advert(
             'http://www.csr.com/about', 0x10, 0x00),
         [0x10, 0x00, 0x00, 0x63, 0x73, 0x72,
          0x00, 0x61, 0x62, 0x6f, 0x75, 0x74])
 def test(self):
     self.assertEqual(
         tools.url_to_advert(
             'https://www.google.com', 0x10, 0x00),
         [0x10, 0x00, 0x01, 0x67, 0x6f,
          0x6f, 0x67, 0x6c, 0x65, 0x07])
import sys
import os

sys.path.insert(0,
                os.path.split(os.path.dirname(os.path.realpath(__file__)))[0])
from bluezero import peripheral
from bluezero import tools

# Bluetooth
# Add beacon information
ukBaz_beacon = peripheral.Service('FEAA', True, type='broadcast')
service_data = tools.url_to_advert(
    'https://github.com/ukBaz',
    frame_type=0x10,
    tx_power=0xFF)
ukBaz_beacon.add_service_data(service_data)


# Add application
app = peripheral.Application()
app.add_service(ukBaz_beacon)

app.add_device_name('ukBazBeacon')

# Start service and advertise
try:
    app.start()
except KeyboardInterrupt:
    print('KeyboardInterrupt')
finally:
    app.stop()