Ejemplo n.º 1
0
    def test_notification_for_unexpected_handle(self):
        """Test Bluetooth notification for unexpected handle"""
        self.h = HW01('XX:XX:XX:XX:XX:XX')
        mock_char = Characteristic(self.h, UUIDS.CHARACTERISTIC_TX, 0x14,
                                   [0b00010000], 0x14)

        tx_delegate = TXDelegate(mock_char.getHandle(), self.h._log)
        self.h.setDelegate(tx_delegate)

        self.assertEqual(tx_delegate.data, None)

        # Trigger notification with expected handle
        self.h.delegate.handleNotification(0xff, 'AT+??')
        self.assertEqual(tx_delegate.data, None)
Ejemplo n.º 2
0
 def _registerCallback(self, characteristic: Characteristic, callback: Callable):
     handle = characteristic.getHandle()
     self._callbackMap[handle] = callback
     self._enableNotification(characteristic)
Ejemplo n.º 3
0
 def _removeCallback(self, characteristic: Characteristic):
     handle = characteristic.getHandle()
     del self._callbackMap[handle]
     self._disableNotification(characteristic)
Ejemplo n.º 4
0
 def _writeCharDescriptor(self, characteristic: Characteristic, data):
     notify_handle = characteristic.getHandle() + 1
     self.writeCharacteristic(notify_handle, data, withResponse=True)