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

BLE Driver Unable to write to a characteristic

Hi ,

I am unable to write to discover all services and write to a characteristic too.

On discovering services:

Discovering primary services

Received service discovery response

UUID: 0xA100, start handle: 0x000C, end handle: 0x0015

Discovering characteristics

Received characteristic discovery response, characteristics count: 3

Handle: 0x000D, UUID: 0xA101

Handle: 0x0010, UUID: 0xA102

Handle: 0x0012, UUID: 0x2A38

Discovering descriptors

Received descriptor discovery response, descriptor count: 5

Handle: 0x000D, UUID: 0x2803

Handle: 0x000E, UUID: 0xA101

Handle: 0x000F, UUID: 0x2902

Handle: 0x0010, UUID: 0x2803

Handle: 0x0011, UUID: 0xA102

it is missing a fourth service with UUID 0xA103 and I actually want to write the characteristic with UUID 0xA102. I have tried to write to the handle 0x011(15) using the code given here by Stian.

devzone.nordicsemi.com/.../

Could someone let me know where I am going wrong please? I am just not able to discover the fourth service or write to the characteristic 0xA102 with handle 0x0011

Thanks and Regards, Neil

  • You haven't discovered all the characteristics. The service discovery shows handles all the way up to 0x0015. You've only discovered up to 0x0011. You need to do another discover descriptors starting at 0x0012 until you've exhausted the service. The payload for the underlying ATT find information request is of max size MTU-2, which is 21 bytes, which is 5 {Handle,value} pairs.

  • Hi rk

    Thanks for your response

    I had issued a second char discovery but that did not work

    For the writing to a characteristic part, I have written to the correct handle which is 11 in this scenario but It still doesnt write properly

    I m able to write to a descriptor but not to a characteristic , I m confused why

    Could you please help?

    Thanks and Regards Neil

  • Why didn't it work? Error message? What? If you can't discover the descriptors then there's something wrong. The service says descriptors go to 0x15, you need to work out how to get them all, perhaps you will then find your error.

  • Ok I have done created a new method and manually specified the start handle for the descriptor discovery service.

    Received descriptor discovery response, descriptor count: 5

    on Discovery response Handle: 0x000D, UUID: 0x2803

    on Discovery response Handle: 0x000E, UUID: 0xA101

    on Discovery response Handle: 0x000F, UUID: 0x2902

    on Discovery response Handle: 0x0010, UUID: 0x2803

    on Discovery response Handle: 0x0011, UUID: 0x2A38

    Press enter to toggle notifications 1

    Discovering descriptorsvjhghgjh

    Received descriptor discovery response, descriptor count: 5

    on Discovery response Handle: 0x0011, UUID: 0x2A38

    on Discovery response Handle: 0x0012, UUID: 0x2803

    on Discovery response Handle: 0x0013, UUID: 0xA103

    on Discovery response Handle: 0x0014, UUID: 0x2803

    on Discovery response Handle: 0x0015, UUID: 0xA102

  • The handle appears different as I have changed the order of the characteristics in the code.

    It appears the handle for Characteristic A102 is 0x0015 . I am still unable to write to it with the do_write function specified here devzone.nordicsemi.com/.../ .

    hrm_ctl_handle is 0x0015

    def do_write(self,value):
    
     global hrm_ctl_handle
    
        print "do_write",type(value),value,"-",hrm_ctl_handle
    
        led_value = [value]
    
        led_array = util.list_to_uint8_array(led_value)
    
        write_params = ble_driver.ble_gattc_write_params_t()
    
        write_params.handle = hrm_ctl_handle
    
        write_params.len = 1
    
        write_params.p_value = led_array.cast()
    
        write_params.write_op = ble_driver.BLE_GATT_OP_WRITE_REQ
    
        write_params.offset = 0
    

    Could you please help me?

    Thanks and Regards, Neil

Related