How to use the attrs.Attrs.Response2 function in attrs

To help you get started, we’ve selected a few attrs examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github openaps / openxshareble / openxshareble / ble / uart.py View on Github external
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)
      self._queue = Queue.Queue()
      r = device.is_paired
      self.serial = kwds.pop('SERIAL', None)
      log.info("paired? %s", r)
      if not r:
        log.info("pairing...")
        # help(device._device)
        # help(device._device.Pair)
github openaps / openxshareble / openxshareble / ble / uart.py View on Github external
time.sleep(.100)
    self.remainder.extend(spool[size:])
    return str(spool[:size])
  def pop (self, timeout_sec=None):
    return super(Share2UART, self).read(timeout_sec=timeout_sec)

class BothShare (ShareUART):
  ADVERTISED = ShareUART.ADVERTISED + Share2UART.ADVERTISED
  # SERVICES = [Attrs.DeviceService]
  SERVICES =  ShareUART.SERVICES + Share2UART.SERVICES
  CHARACTERISTICS =  ShareUART.SERVICES + Share2UART.SERVICES
  

  UART_SERVICE_UUID = Attrs.CradleService2
  TX_CHAR_UUID = Attrs.Command2
  RX_CHAR_UUID = Attrs.Response2
  pass

class UART (Share2UART):
  pass