Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
ADVERTISED = [Attrs.CradleService]
# SERVICES = [Attrs.DeviceService]
SERVICES = [Attrs.CradleService]
CHARACTERISTICS = [Attrs.AuthenticationCode, Attrs.Command, Attrs.Response, Attrs.ShareMessageReceiver, Attrs.ShareMessageResponse, Attrs.HeartBeat, Attrs.DeviceService, Attrs.PowerLevel]
UART_SERVICE_UUID = Attrs.CradleService
TX_CHAR_UUID = Attrs.Command
RX_CHAR_UUID = Attrs.Response
pass
class Share2UART (OriginalUART):
# ADVERTISED = [Attrs.CradleService2]
# ADVERTISED = [Attrs.VENDOR_UUID]
ADVERTISED = [Attrs.VENDOR_UUID]
# SERVICES = [Attrs.DeviceService]
# SERVICES = [Attrs.CradleService2, Attrs.VENDOR_UUID]
SERVICES = [Attrs.VENDOR_UUID, Attrs.DeviceService]
# CHARACTERISTICS = [Attrs.AuthenticationCode2, Attrs.Command2, Attrs.Response2, Attrs.ShareMessageReceiver2, Attrs.ShareMessageResponse2, Attrs.HeartBeat2, Attrs.DeviceService, Attrs.PowerLevel]
CHARACTERISTICS = [ ]
HEARTBEAT_UUID = Attrs.HeartBeat2
# UART_SERVICE_UUID = Attrs.CradleService2
UART_SERVICE_UUID = Attrs.VENDOR_UUID
TX_CHAR_UUID = Attrs.ShareMessageReceiver2
RX_CHAR_UUID = Attrs.ShareMessageResponse2
SendDataUUID = Attrs.ShareMessageReceiver2
RcveDataUUID = Attrs.ShareMessageResponse2
CommandUUID = Attrs.Command2
ResponseUUID = Attrs.Response2
AUTH_UUID = Attrs.AuthenticationCode2
def __init__(self, device, **kwds):
"""Initialize UART from provided bluez device."""
# Find the UART service and characteristics associated with the device.
import Adafruit_BluefruitLE
from Adafruit_BluefruitLE.services import UART as OriginalUART
import Queue
import uuid
import time
from attrs import Attrs
import logging
log = logging.getLogger(__name__)
class ShareUART (OriginalUART):
ADVERTISED = [Attrs.CradleService]
# SERVICES = [Attrs.DeviceService]
SERVICES = [Attrs.CradleService]
CHARACTERISTICS = [Attrs.AuthenticationCode, Attrs.Command, Attrs.Response, Attrs.ShareMessageReceiver, Attrs.ShareMessageResponse, Attrs.HeartBeat, Attrs.DeviceService, Attrs.PowerLevel]
UART_SERVICE_UUID = Attrs.CradleService
TX_CHAR_UUID = Attrs.Command
RX_CHAR_UUID = Attrs.Response
pass
class Share2UART (OriginalUART):
# ADVERTISED = [Attrs.CradleService2]
# ADVERTISED = [Attrs.VENDOR_UUID]
ADVERTISED = [Attrs.VENDOR_UUID]
# SERVICES = [Attrs.DeviceService]
# SERVICES = [Attrs.CradleService2, Attrs.VENDOR_UUID]
SERVICES = [Attrs.VENDOR_UUID, Attrs.DeviceService]
# CHARACTERISTICS = [Attrs.AuthenticationCode2, Attrs.Command2, Attrs.Response2, Attrs.ShareMessageReceiver2, Attrs.ShareMessageResponse2, Attrs.HeartBeat2, Attrs.DeviceService, Attrs.PowerLevel]
UART_SERVICE_UUID = Attrs.CradleService
TX_CHAR_UUID = Attrs.Command
RX_CHAR_UUID = Attrs.Response
pass
class Share2UART (OriginalUART):
# ADVERTISED = [Attrs.CradleService2]
# ADVERTISED = [Attrs.VENDOR_UUID]
ADVERTISED = [Attrs.VENDOR_UUID]
# SERVICES = [Attrs.DeviceService]
# SERVICES = [Attrs.CradleService2, Attrs.VENDOR_UUID]
SERVICES = [Attrs.VENDOR_UUID, Attrs.DeviceService]
# CHARACTERISTICS = [Attrs.AuthenticationCode2, Attrs.Command2, Attrs.Response2, Attrs.ShareMessageReceiver2, Attrs.ShareMessageResponse2, Attrs.HeartBeat2, Attrs.DeviceService, Attrs.PowerLevel]
CHARACTERISTICS = [ ]
HEARTBEAT_UUID = Attrs.HeartBeat2
# UART_SERVICE_UUID = Attrs.CradleService2
UART_SERVICE_UUID = Attrs.VENDOR_UUID
TX_CHAR_UUID = Attrs.ShareMessageReceiver2
RX_CHAR_UUID = Attrs.ShareMessageResponse2
SendDataUUID = Attrs.ShareMessageReceiver2
RcveDataUUID = Attrs.ShareMessageResponse2
CommandUUID = Attrs.Command2
ResponseUUID = Attrs.Response2
AUTH_UUID = Attrs.AuthenticationCode2
def __init__(self, device, **kwds):
"""Initialize UART from provided bluez device."""
# Find the UART service and characteristics associated with the device.
log = logging.getLogger(__name__)
self.log = log.getChild('uart')
self._uart = device.find_service(self.UART_SERVICE_UUID)
log.info("UART %s", self._uart)