raspberry pi 4
2台(raspberry0、raspberry1)で、7/24現在で以下の方法でrasbianとbluezを両RPiにInstallしています。

```

    sudo apt-get update
    sudo apt purge --auto-remove wolfram*
    sudo apt-get upgrade -y
    sudo apt-get dist-upgrade -y
    sudo rpi-update
    sudo apt-get install -y pi-bluetooth raspberrypi-sys-mods
    sudo apt-get install bluetooth
    sudo apt install -y libusb-dev libdbus-1-dev libglib2.0-dev libudev-dev libical-dev libreadline-dev libdbus-glib-1-dev libbluetooth-dev
    sudo apt install bluez
    sudo usermod -aG bluetooth pi
    newgrp bluetooth
    sudo reboot
    
```

起動後、`service` コマンドでbluetoothのserviceを見ると正常に見えます。

```

    $ service bluetooth status
    ------------------------------------------------------------------------------------------
    ● bluetooth.service - Bluetooth service
       Loaded: loaded (/lib/systemd/system/bluetooth.service; enabled; vendor preset: enabled)
       Active: active (running) since Sat 2021-07-24 06:28:48 BST; 2min 33s ago
         Docs: man:bluetoothd(8)
     Main PID: 580 (bluetoothd)
       Status: "Running"
        Tasks: 1 (limit: 3874)
       CGroup: /system.slice/bluetooth.service
               └─580 /usr/lib/bluetooth/bluetoothd
    
    Jul 24 06:28:48 raspberry0 systemd[1]: Starting Bluetooth service...
    Jul 24 06:28:48 raspberry0 bluetoothd[580]: Bluetooth daemon 5.50
    Jul 24 06:28:48 raspberry0 systemd[1]: Started Bluetooth service.
    Jul 24 06:28:48 raspberry0 bluetoothd[580]: Starting SDP server
    Jul 24 06:28:48 raspberry0 bluetoothd[580]: Bluetooth management interface 1.18 initialized
    Jul 24 06:28:48 raspberry0 bluetoothd[580]: Sap driver initialization failed.
    Jul 24 06:28:48 raspberry0 bluetoothd[580]: sap-server: Operation not permitted (1)
    Jul 24 06:28:49 raspberry0 bluetoothd[580]: Failed to set privacy: Rejected (0x0b)
    Jul 24 06:31:12 raspberry0 bluetoothd[580]: No cache for DC:A6:32:97:17:7E
    
```

また、hci0を見るとこちらも正常起動しているように見えます。

```

    $ hciconfig -a
    ------------------------------------------------------------------------------------------
    hci0:   Type: Primary  Bus: UART
            BD Address: DC:A6:32:7A:9C:3A  ACL MTU: 1021:8  SCO MTU: 64:1
            UP RUNNING PSCAN ISCAN
            RX bytes:1811 acl:3 sco:0 events:118 errors:0
            TX bytes:2731 acl:4 sco:0 commands:108 errors:0
            Features: 0xbf 0xfe 0xcf 0xfe 0xdb 0xff 0x7b 0x87
            Packet type: DM1 DM3 DM5 DH1 DH3 DH5 HV1 HV2 HV3
            Link policy: RSWITCH SNIFF
            Link mode: SLAVE ACCEPT
            Name: 'raspberry0'
            Class: 0x000fdc
            Service Classes: Unspecified
            Device Class: Invalid Device Class!
            HCI Version: 5.0 (0x9)  Revision: 0x156
            LMP Version: 5.0 (0x9)  Subversion: 0x6119
            Manufacturer: Cypress Semiconductor Corporation (305)
    
```

Adverise送出のため、raspberry0で以下を実行。  
(なぜかbluez-5.50に添付のexample-advertisementはErrorで起動できません)

```

    sudo hciconfig hci0 leadv 0
    
```

その後、raspberry1でgatttoolを起動して、raspberry0のGATTを見ると正常にGATTが見られます。

```

    $ sudo gatttool -b DC:A6:32:7A:9C:3A -I
    [DC:A6:32:7A:9C:3A][LE]> connect
    Attempting to connect to DC:A6:32:7A:9C:3A
    Connection successful
    Indication   handle = 0x0008 value: 26 00 41 00
    [DC:A6:32:7A:9C:3A][LE]> primary
    attr handle: 0x0001, end grp handle: 0x0005 uuid: 00001800-0000-1000-8000-00805f9b34fb
    attr handle: 0x0006, end grp handle: 0x0009 uuid: 00001801-0000-1000-8000-00805f9b34fb
    
```

その後、raspberry0でbluea-5.50のexample-gatt-serverを起動すると、raspberry1側ではexample-gatt-
serverの設定が正常に有効に見えます。

```

    Indication   handle = 0x0008 value: 42 00 49 00
    Indication   handle = 0x0008 value: 4a 00 4d 00
    Indication   handle = 0x0008 value: 4e 00 5d 00
    [DC:A6:32:7A:9C:3A][LE]> primary
    attr handle: 0x0001, end grp handle: 0x0005 uuid: 00001800-0000-1000-8000-00805f9b34fb
    attr handle: 0x0006, end grp handle: 0x0009 uuid: 00001801-0000-1000-8000-00805f9b34fb
    attr handle: 0x0042, end grp handle: 0x0049 uuid: 0000180d-0000-1000-8000-00805f9b34fb
    attr handle: 0x004a, end grp handle: 0x004d uuid: 0000180f-0000-1000-8000-00805f9b34fb
    attr handle: 0x004e, end grp handle: 0x005d uuid: 12345678-1234-5678-1234-56789abcdef0
    [DC:A6:32:7A:9C:3A][LE]>
    
```

しかし、この状態でAndrod端末で、Nordic社製nRF Connectでraspberry0を見てもDevice
Informationの`0000180a-...`しか見ることができません。

```

    00001800-...
    00001801-...
    
```

raspberry1でgatttoolの結果からgattには正しく設定されているにも関わらず、他のToolで見えないことから、bluezが正しくgattを公開していないように見えるのですが、どなたか原因と対策方法は判るでしょうか？
CC BY-SA 4.0
2021-07-24T06:16:20.370
78385
2021-07-24T10:40:58.087
2021-07-24T10:40:58.087
3060
47413
question
bluetooth bluez
raspberry pi 4 + bluez の構成から gatt のデータを受信できない