Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 11 additions & 6 deletions bluezero/peripheral.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,26 +20,31 @@ def __init__(self, adapter_address, local_name=None, appearance=None):
self.services = []
self.characteristics = []
self.descriptors = []
self.primary_services = []
self.advertised_services = []
self.dongle = adapter.Adapter(adapter_address)
self.local_name = local_name
self.appearance = appearance
self.advert = advertisement.Advertisement(1, 'peripheral')
self.ad_manager = advertisement.AdvertisingManager(adapter_address)
self.mainloop = async_tools.EventLoop()

def add_service(self, srv_id, uuid, primary):
def add_service(self, srv_id, uuid, primary, advertised=None):
"""
Add the service information required

:param srv_id: integer between 0 & 9999 as unique reference
:param uuid: The Bluetooth uuid number for this service
:param primary: boolean for if this service should be advertised
:param primary: boolean for if this service is primary
:param advertised: boolean for if this service should be advertised,
or None

"""
if advertised is None:
advertised = primary

self.services.append(localGATT.Service(srv_id, uuid, primary))
if primary:
self.primary_services.append(uuid)
if advertised:
self.advertised_services.append(uuid)

def add_characteristic(self, srv_id, chr_id, uuid, value,
notifying, flags,
Expand Down Expand Up @@ -121,7 +126,7 @@ def add_descriptor(self, srv_id, chr_id, dsc_id, uuid, value, flags):
))

def _create_advertisement(self):
self.advert.service_UUIDs = self.primary_services
self.advert.service_UUIDs = self.advertised_services
if self.local_name:
self.advert.local_name = self.local_name
if self.appearance:
Expand Down
Loading