Skip to content

Commit 920c94a

Browse files
committed
ble debugging for iOS
1 parent de054a0 commit 920c94a

File tree

4 files changed

+35
-21
lines changed

4 files changed

+35
-21
lines changed

components/ble/gatt.c

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@
3434
/*hid information infos*/
3535
#define HID_FLAGS_REMOTE_WAKE 0x01 // RemoteWake
3636
#define HID_FLAGS_NORMALLY_CONNECTABLE 0x02 // NormallyConnectable
37-
#define HID_KBD_FLAGS HID_FLAGS_REMOTE_WAKE
37+
#define HID_KBD_FLAGS HID_FLAGS_REMOTE_WAKE | HID_FLAGS_NORMALLY_CONNECTABLE
3838
#define HID_INFORMATION_LEN 4 // HID Information
3939

4040
static int gatt_svr_chr_access_device_info(uint16_t conn_handle, uint16_t attr_handle, struct ble_gatt_access_ctxt *ctxt, void *arg);
@@ -52,7 +52,7 @@ static const char *firmware_rev = "1.0";
5252
static const char *software_rev = "1.0";
5353

5454
static const uint8_t hidInfo[HID_INFORMATION_LEN] = {
55-
0x11, 0x01, // bcdHID (USB HID version) --> Version 1.11
55+
0x01, 0x01, // bcdHID (USB HID version) --> Version 1.01
5656
0x00, // bCountryCode
5757
HID_KBD_FLAGS // Flags
5858
};
@@ -108,22 +108,22 @@ static const struct ble_gatt_svc_def gatt_svr_svcs[] = {
108108
/* Characteristic: Manufacturer name */
109109
.uuid = BLE_UUID16_DECLARE(GATT_MANUFACTURER_NAME_UUID),
110110
.access_cb = gatt_svr_chr_access_device_info,
111-
.flags = BLE_GATT_CHR_F_READ,
111+
.flags = BLE_GATT_CHR_F_READ | BLE_GATT_CHR_F_READ_ENC,
112112
}, {
113113
/* Characteristic: Model number string */
114114
.uuid = BLE_UUID16_DECLARE(GATT_MODEL_NUMBER_UUID),
115115
.access_cb = gatt_svr_chr_access_device_info,
116-
.flags = BLE_GATT_CHR_F_READ,
116+
.flags = BLE_GATT_CHR_F_READ | BLE_GATT_CHR_F_READ_ENC,
117117
}, {
118118
/* Characteristic: Firmware Revision string */
119119
.uuid = BLE_UUID16_DECLARE(GATT_FIRMWARE_REVISION_UUID),
120120
.access_cb = gatt_svr_chr_access_device_info,
121-
.flags = BLE_GATT_CHR_F_READ,
121+
.flags = BLE_GATT_CHR_F_READ | BLE_GATT_CHR_F_READ_ENC,
122122
}, {
123123
/* Characteristic: Software Revision string */
124124
.uuid = BLE_UUID16_DECLARE(GATT_SOFTWARE_REVISION_UUID),
125125
.access_cb = gatt_svr_chr_access_device_info,
126-
.flags = BLE_GATT_CHR_F_READ,
126+
.flags = BLE_GATT_CHR_F_READ | BLE_GATT_CHR_F_READ_ENC,
127127
}, {
128128
0, /* No more characteristics in this service */
129129
},
@@ -140,7 +140,7 @@ static const struct ble_gatt_svc_def gatt_svr_svcs[] = {
140140
.uuid = BLE_UUID16_DECLARE(GATT_BATTERY_LEVEL_UUID),
141141
.access_cb = gatt_svr_chr_access_device_info,
142142
.val_handle = &battery_status_handle,
143-
.flags = BLE_GATT_CHR_F_READ | BLE_GATT_CHR_F_NOTIFY,
143+
.flags = BLE_GATT_CHR_F_READ | BLE_GATT_CHR_F_READ_ENC | BLE_GATT_CHR_F_NOTIFY,
144144
}, {
145145
0, /* No more characteristics in this service */
146146
},
@@ -156,12 +156,12 @@ static const struct ble_gatt_svc_def gatt_svr_svcs[] = {
156156
/* Characteristic: Report Map */
157157
.uuid = BLE_UUID16_DECLARE(GATT_HID_REPORT_MAP_UUID),
158158
.access_cb = gatt_svr_chr_hid,
159-
.flags = BLE_GATT_CHR_F_READ,
159+
.flags = BLE_GATT_CHR_F_READ | BLE_GATT_CHR_F_READ_ENC,
160160
}, {
161161
/* Characteristic: HID Information */
162162
.uuid = BLE_UUID16_DECLARE(GATT_HID_INFORMATION_UUID),
163163
.access_cb = gatt_svr_chr_hid,
164-
.flags = BLE_GATT_CHR_F_READ,
164+
.flags = BLE_GATT_CHR_F_READ | BLE_GATT_CHR_F_READ_ENC,
165165
}, {
166166
/* Characteristic: HID Control Point */
167167
.uuid = BLE_UUID16_DECLARE(GATT_HID_CONTROL_POINT_UUID),
@@ -172,7 +172,7 @@ static const struct ble_gatt_svc_def gatt_svr_svcs[] = {
172172
.uuid = BLE_UUID16_DECLARE(GATT_HID_REPORT_UUID),
173173
.access_cb = gatt_svr_chr_hid,
174174
.val_handle = &report_data_handle,
175-
.flags = BLE_GATT_CHR_F_READ | BLE_GATT_CHR_F_NOTIFY,
175+
.flags = BLE_GATT_CHR_F_READ | BLE_GATT_CHR_F_READ_ENC | BLE_GATT_CHR_F_NOTIFY,
176176
.descriptors = (struct ble_gatt_dsc_def[]){
177177
//client configuration descriptor soll nicht manuell hinzugefügt werden, da dieser mittels dem flag notify automatisch hinzugefügt wird
178178
{

docs/BLE-Debugging.md

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,13 @@
99
# Linux
1010
- Tools: hcitool, gatttool, bluetoothctl, hidraw-dump, Bluepy
1111

12+
## Allgemein
13+
Edit `/lib/systemd/system/bluetooth.service` and change to:
14+
15+
`ExecStart=/usr/libexec/bluetooth/bluetoothd --noplugin=input,hog`
16+
17+
Then Bluetooth daemon won't grab input or hog devices and won't create system input nodes. Then the HID GATT service and corresponding characteristics are available via BlueZ to application.
18+
1219
## hcitool
1320

1421
### Verfügbares Bluetoothgerät am Linuxrechner
@@ -93,4 +100,4 @@ Auf dieser [Website](https://eleccelerator.com/usbdescreqparser/) umwandeln.
93100
`svcs`
94101

95102
## Hinweis:
96-
- Debugging des XBox controllers hat nur verbunden, wenn man ihn nicht in den Bluetooth-Einstellungen verbunden hatte und wenn mann ihn erst connecting modus bringt wenn man gatttools offen hat und danach connect aufruft.
103+
- Debugging des XBox controllers hat nur verbunden, wenn man ihn nicht in den Bluetooth-Einstellungen verbunden hatte und wenn mann ihn erst connecting modus bringt wenn man gatttools offen hat und danach connect aufruft. Beim gatttool darf auch nicht die Option random aktiviert sein.

docs/TODO.md

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
# Code
2+
## Aufgaben
3+
- [ ] LEDs hinzufügen
4+
- [ ] kommentieren und in .md-Datein dokumentieren, wo was zu finden ist
5+
6+
## Probleme
7+
- [ ] iOS funktioniert nicht / kann nicht getestet werden
8+
- [ ] Manchmal passt die Anzeige auf dem Display nicht, wenn unerwartete GAP-Events auftreten
9+
- [ ] Beim Xbox Controller ist der Client Configuration Deskriptor auf 01 00 gesetzt (default) --> notification an. Bei mir ist der Client Configuration Deskriptor auf 00 00 gesetzt (default) --> Soll auch so laut spec sein
10+
- [ ] Linux erkennt meine HID Version nur als 0.0, obwohl ich sie so wie beim XBox Controller gesetzt hab
11+
12+
# Platine
13+
- [ ] Button entprellen in finaler Platine
14+
- [ ] Verbindung zu ADC sollte eigentlich mit Transistor geschalten werden damit nicht dauerhaft strom fließt zu maße über den Spannungsteiler, auch sollte ein Kondensator noch hinzugefügt werden, damit rauschen vermindert wird.
15+
16+
# Gehäuse
17+
- [ ] Erstellen

docs/todo

Lines changed: 0 additions & 10 deletions
This file was deleted.

0 commit comments

Comments
 (0)