subbu Subhash
subbu Subhash

Reputation: 11

Unable to read or write to BLE

I'm trying to read the characteristic value of BLE devices, in my case BLE device is Minew S1 Temperature and Humidity sensor, the attribute value I'm trying to read is "Radio Tx Power". I'm using RaspberryPi 4 and bluetoothctl version is 5.55.

Primary Service (Handle 0x0004)
        /org/bluez/hci0/dev_AC_23_3F_AB_7B_D8/service001f
        a3c87500-8ed3-4bdf-8a39-a01bebede295
        Eddystone Configuration Service
Characteristic (Handle 0x6510)
        /org/bluez/hci0/dev_AC_23_3F_AB_7B_D8/service001f/char002c
        a3c8750b-8ed3-4bdf-8a39-a01bebede295
        (Advanced) Factory reset
Characteristic (Handle 0x0d78)
        /org/bluez/hci0/dev_AC_23_3F_AB_7B_D8/service001f/char002a
        a3c8750a-8ed3-4bdf-8a39-a01bebede295
        ADV Slot Data
Characteristic (Handle 0x0d78)
        /org/bluez/hci0/dev_AC_23_3F_AB_7B_D8/service001f/char0028
        a3c87505-8ed3-4bdf-8a39-a01bebede295
        (Advanced) Advertised Tx Power
Characteristic (Handle 0x0d78)
        /org/bluez/hci0/dev_AC_23_3F_AB_7B_D8/service001f/char0026
        a3c87504-8ed3-4bdf-8a39-a01bebede295
        Radio Tx Power
Characteristic (Handle 0x0d78)
        /org/bluez/hci0/dev_AC_23_3F_AB_7B_D8/service001f/char0024
        a3c87503-8ed3-4bdf-8a39-a01bebede295
        Advertising Interval
Characteristic (Handle 0x0d78)
        /org/bluez/hci0/dev_AC_23_3F_AB_7B_D8/service001f/char0022
        a3c87502-8ed3-4bdf-8a39-a01bebede295
        Active Slot
Characteristic (Handle 0x0d78)
        /org/bluez/hci0/dev_AC_23_3F_AB_7B_D8/service001f/char0020
        a3c87501-8ed3-4bdf-8a39-a01bebede295
        Capabilities
Primary Service (Handle 0xa2d8)
        /org/bluez/hci0/dev_AC_23_3F_AB_7B_D8/service001b
        7f280001-8204-f393-e0a9-e50e24dcca9e
        Vendor specific
Characteristic (Handle 0xad98)
        /org/bluez/hci0/dev_AC_23_3F_AB_7B_D8/service001b/char001c
        7f280002-8204-f393-e0a9-e50e24dcca9e
        Vendor specific
Descriptor (Handle 0x0000)
        /org/bluez/hci0/dev_AC_23_3F_AB_7B_D8/service001b/char001c/desc001e
        00002902-0000-1000-8000-00805f9b34fb
        Client Characteristic Configuration

using bluetoothctl I tried to read the data but I got this error

[nRF5x]#  select-attribute  /org/bluez/hci0/dev_AC_23_3F_AB_7B_D8/service001f/char0026
[nRF5x:/service001f/char0026]# read
Attempting to read /org/bluez/hci0/dev_AC_23_3F_AB_7B_D8/service001f/char0026
[CHG] Device AC:23:3F:AB:7B:D8 ServicesResolved: no
[CHG] Device AC:23:3F:AB:7B:D8 Connected: no
Failed to read: org.bluez.Error.Failed
[bluetooth]#

and all these are working fine when connected to android mobile.

please help me to solve this problem.

Edited (added debug):

> HCI Event: Command Complete (0x0e) plen 4                                                                              #37 [hci0] 23.110065
      LE Set Scan Enable (0x08|0x000c) ncmd 1
        Status: Success (0x00)
< HCI Command: LE Create Connection (0x08|0x000d) plen 25                                                                #38 [hci0] 23.110095
        Scan interval: 60.000 msec (0x0060)
        Scan window: 60.000 msec (0x0060)
        Filter policy: White list is not used (0x00)
        Peer address type: Public (0x00)
        Peer address: AC:23:3F:AB:7B:D8 (Shenzhen Minew Technologies Co., Ltd.)
        Own address type: Public (0x00)
        Min connection interval: 30.00 msec (0x0018)
        Max connection interval: 50.00 msec (0x0028)
        Connection latency: 0 (0x0000)
        Supervision timeout: 420 msec (0x002a)
        Min connection length: 0.000 msec (0x0000)
        Max connection length: 0.000 msec (0x0000)
> HCI Event: Command Status (0x0f) plen 4                                                                                #39 [hci0] 23.110613
      LE Create Connection (0x08|0x000d) ncmd 1
        Status: Success (0x00)
> HCI Event: LE Meta Event (0x3e) plen 19                                                                                #40 [hci0] 23.210757
      LE Connection Complete (0x01)
        Status: Success (0x00)
        Handle: 64
        Role: Master (0x00)
        Peer address type: Public (0x00)
        Peer address: AC:23:3F:AB:7B:D8 (Shenzhen Minew Technologies Co., Ltd.)
        Connection interval: 48.75 msec (0x0027)
        Connection latency: 0 (0x0000)
        Supervision timeout: 420 msec (0x002a)
        Master clock accuracy: 0x00
@ MGMT Event: Device Connected (0x000b) plen 37                                                                     {0x0001} [hci0] 23.210785
        LE Address: AC:23:3F:AB:7B:D8 (Shenzhen Minew Technologies Co., Ltd.)
        Flags: 0x00000000
        Data length: 24
        Flags: 0x06
          LE General Discoverable Mode
          BR/EDR Not Supported
        16-bit Service UUIDs (complete): 1 entry
          Unknown (0xffe1)
        Service Data (UUID 0xffe1): a101641cfd48e6d87bab3f23ac
< HCI Command: LE Read Remote Used Features (0x08|0x0016) plen 2                                                         #41 [hci0] 23.210905
        Handle: 64
> HCI Event: Command Status (0x0f) plen 4                                                                                #42 [hci0] 23.211771
      LE Read Remote Used Features (0x08|0x0016) ncmd 1
        Status: Success (0x00)
> HCI Event: Command Complete (0x0e) plen 14                                                                             #43 [hci0] 23.211775
      LE Read Remote Used Features (0x08|0x0016) ncmd 1
        Status: Success (0x00)
        00 00 00 00 00 00 00 00 00 00                    ..........      
> HCI Event: LE Meta Event (0x3e) plen 12                                                                                #44 [hci0] 23.337233
      LE Read Remote Used Features (0x04)
        Status: Success (0x00)
        Handle: 64
        Features: 0x21 0x00 0x00 0x00 0x00 0x00 0x00 0x00
          LE Encryption
          LE Data Packet Length Extension
< ACL Data TX: Handle 64 flags 0x00 dlen 7                                                                               #45 [hci0] 23.337677
      ATT: Exchange MTU Request (0x02) len 2
        Client RX MTU: 517
> ACL Data RX: Handle 64 flags 0x02 dlen 7                                                                               #46 [hci0] 23.532018
      ATT: Exchange MTU Response (0x03) len 2
        Server RX MTU: 23
< ACL Data TX: Handle 64 flags 0x00 dlen 7                                                                               #47 [hci0] 23.532452
      ATT: Read Request (0x0a) len 2
        Handle: 0x0003
> HCI Event: Number of Completed Packets (0x13) plen 5                                                                   #48 [hci0] 23.580957
        Num handles: 1
        Handle: 64
        Count: 2
> ACL Data RX: Handle 64 flags 0x02 dlen 10                                                                              #49 [hci0] 23.629552
      ATT: Read Response (0x0b) len 5
        Value: 6e52463578
< ACL Data TX: Handle 64 flags 0x00 dlen 7                                                                               #50 [hci0] 23.629713
      ATT: Read Request (0x0a) len 2
        Handle: 0x0005
> ACL Data RX: Handle 64 flags 0x02 dlen 7                                                                               #51 [hci0] 23.727010
      ATT: Read Response (0x0b) len 2
        Value: 0000
< ACL Data TX: Handle 64 flags 0x00 dlen 7                                                                               #52 [hci0] 23.727179
      ATT: Read Request (0x0a) len 2
        Handle: 0x0027
> HCI Event: Number of Completed Packets (0x13) plen 5                                                                   #53 [hci0] 23.775948
        Num handles: 1
        Handle: 64
        Count: 2


> HCI Event: Disconnect Complete (0x05) plen 4                                                                           #54 [hci0] 32.502249
        Status: Success (0x00)
        Handle: 64
        Reason: Remote User Terminated Connection (0x13)
@ MGMT Event: Device Disconnected (0x000c) plen 8                                                                   {0x0001} [hci0] 32.502320
        LE Address: AC:23:3F:AB:7B:D8 (Shenzhen Minew Technologies Co., Ltd.)
        Reason: Connection terminated by remote host (0x03)

thank you.

Upvotes: 0

Views: 927

Answers (0)

Related Questions