Skip to content

Commit

Permalink
primary service can not be advertised
Browse files Browse the repository at this point in the history
  • Loading branch information
Matteo Meluzzi committed Dec 5, 2024
1 parent 90f38a0 commit bc529f5
Showing 1 changed file with 10 additions and 6 deletions.
16 changes: 10 additions & 6 deletions bluezero/peripheral.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,26 +20,30 @@ 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 +125,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

0 comments on commit bc529f5

Please sign in to comment.