This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts

What’s BLE handle mean?

Hey, 

previously working with BLE devices I had manage them reading/writing its characteristic. To control my new device I have to write the value into its handle ( i. e. 0x1892)

what at does it mean? And how can I solve it with nrf51 and s130?

And what is the different between handle and characteristic?

google, unfortunately, hasn’t gave me what I expected, maybe my request wasn’t enough clear

Parents
  • What device are your talking about?

    Post a link to where it talks about this "handle" - so that people can see it in context.

    A "handle" is usually a software abstraction - so not specifically a BLE thing ...

  • Hi, I'm gonna communicate with my smart kettle Redmond rk-g201s (the link on the similar model)

    I successfully done it with gatttool (bluez) wrapped with pygatt, the code below shows how I've done it

    def write_handle(self, device, handle, value, increment=True):
        val = bytearray(val)
        device.char_write_handle(handle, val, True)
    ...
    adapter.start()
    device = adapter.connect(YOUR_DEVICE_ADDRESS, address_type=ADDRESS_TYPE)
    self.write_handle(device, 0x000e, [0xFF, 0xDF, 0x24, 0x0E, 0xC6, 0x94, 0xD1, 0x97, 0x43], False)
    self.write_handle(device, 0x000c, [0x01, 0x00])
    self.write_handle(device, 0x000e, [0x01])
    self.write_handle(device, 0x000e, [0x05, 0x00, 0x00, int(hex(100), 16), 0x00])
    self.write_handle(device, 0x000e, [0x03])
    ...

    pygatt's GitHub says

    Writes a value to a given characteristic handle. This can be used to
    write to the characteristic config handle for a primary characteristic.
    hande -- the handle to write to.
    value -- a bytearray to write to the characteristic.
    wait_for_response -- wait for response after writing.
    
    def char_write_handle(self, handle, value, wait_for_response=False,
                          timeout=1):
        """
        Writes a value to a given characteristic handle.
        :param handle:
        :param value:
        :param wait_for_response:
        """
        cmd = 'char-write-{0} 0x{1:02x} {2}'.format(
            'req' if wait_for_response else 'cmd',
            handle,
            ''.join("{0:02x}".format(byte) for byte in value),
        )
    
        log.debug('Sending cmd=%s', cmd)
        if wait_for_response:
            try:
                with self._receiver.event("char_written", timeout=timeout):
                    self.sendline(cmd)
            except NotificationTimeout:
                log.error("No response received", exc_info=True)
                raise
        else:
            self.sendline(cmd)
    
        log.info('Sent cmd=%s', cmd)

  • Hi,

    "handle" is not a BLE concept. It is a common software concept, used by the libraries you are using.  See for instance Handle (computing).

Reply Children
No Data
Related