Generic keyboard emulation using Arduino Leonardo - arduino

I am trying to use an Arduino Leonardo for keyboard emulation since that is one of its advertised features. I have been playing with the Leonardo and wrote a very simple sketch based off the Blink example.
// Pin 13 has an LED connected on most Arduino boards.
int led = 13;
// The setup routine runs once when you press reset:
void setup()
{
// Initialize the digital pin as an output.
pinMode(led, OUTPUT);
}
// The loop routine runs over and over again forever:
void loop()
{
delay(5000); // Wait for five seconds
digitalWrite(led, HIGH); // Turn the LED on (HIGH is the voltage level)
delay(100); // Wait for a secondA
digitalWrite(led, LOW); // Turn the LED off by making the voltage LOW
Keyboard.write('A'); // Write an A using keyboard emulator
}
Now this example works great on my Windows XP machine. It is recognized as a generic HID keyboard and will type an 'A' every five seconds.
The targeted environment is running DOS so to my knowledge I need to get the Arduino Leonardo recognized by the BIOS on this machine, which it is not and it does not type the 'A' in DOS.
I have been making modifications to the USB device descriptor of the Leonardo, trying to make it match a Dell L100 as much as possible. The modifications I've made haven't helped, and I suspect it is because the Leonardo is a composite device which exposes the serial communication, keyboard emulation, and mouse emulation on the same USB port. The source code for the USB descriptors/configuration is available to be edited and is located at:
Arduino_Installation\hardware\arduino\cores\arduino\HID.cpp
Arduino_Installation\hardware\arduino\cores\arduino\USBDesc.h
Arduino_Installation\hardware\arduino\cores\arduino\USBCore.h
Arduino_Installation\hardware\arduino\cores\arduino\USBCore.cpp
The following is a dump from USB Device Viewer for the Leonardo:
[Port3] : USB Composite Device
---===>Device Information<===---
English product name: "Arduino Leonardo"
ConnectionStatus:
Current Config Value: 0x01 -> Device Bus Speed: Full
Device Address: 0x03
Open Pipes: 4
===>Endpoint Descriptor<===
bLength: 0x07
bDescriptorType: 0x05
bEndpointAddress: 0x81 -> Direction: IN - EndpointID: 1
bmAttributes: 0x03 -> Interrupt Transfer Type
wMaxPacketSize: 0x0010 = 0x10 bytes
bInterval: 0x40
===>Endpoint Descriptor<===
bLength: 0x07
bDescriptorType: 0x05
bEndpointAddress: 0x02 -> Direction: OUT - EndpointID: 2
bmAttributes: 0x02 -> Bulk Transfer Type
wMaxPacketSize: 0x0040 = 0x40 bytes
bInterval: 0x00
===>Endpoint Descriptor<===
bLength: 0x07
bDescriptorType: 0x05
bEndpointAddress: 0x83 -> Direction: IN - EndpointID: 3
bmAttributes: 0x02 -> Bulk Transfer Type
wMaxPacketSize: 0x0040 = 0x40 bytes
bInterval: 0x00
===>Endpoint Descriptor<===
bLength: 0x07
bDescriptorType: 0x05
bEndpointAddress: 0x84 -> Direction: IN - EndpointID: 4
bmAttributes: 0x03 -> Interrupt Transfer Type
wMaxPacketSize: 0x0040 = 0x40 bytes
bInterval: 0x01
===>Device Descriptor<===
bLength: 0x12
bDescriptorType: 0x01
bcdUSB: 0x0110
bDeviceClass: 0x00
*!*ERROR: device class should be Multi-interface Function 0xEF
When IAD descriptor is used
bDeviceSubClass: 0x00
*!*ERROR: device SubClass should be USB Common Sub Class 2
When IAD descriptor is used
bDeviceProtocol: 0x00
*!*ERROR: device Protocol should be USB IAD Protocol 1
When IAD descriptor is used
bMaxPacketSize0: 0x40 = (64) Bytes
idVendor: 0x2341 = Vendor ID not listed with USB.org as of 03-19-2008
idProduct: 0x8036
bcdDevice: 0x0100
iManufacturer: 0x01
English (United States) "Arduino LLC"
iProduct: 0x02
English (United States) "Arduino Leonardo"
iSerialNumber: 0x00
bNumConfigurations: 0x01
===>Configuration Descriptor<===
bLength: 0x09
bDescriptorType: 0x02
wTotalLength: 0x0064 -> Validated
bNumInterfaces: 0x03
bConfigurationValue: 0x01
iConfiguration: 0x00
bmAttributes: 0x80 -> Bus Powered
MaxPower: 0xFA = 500 mA
===>IAD Descriptor<===
bLength: 0x08
bDescriptorType: 0x0B
bFirstInterface: 0x00
bInterfaceCount: 0x02
bFunctionClass: 0x02 -> This is Communications (CDC Control) USB Device Interface Class
bFunctionSubClass: 0x01
bFunctionProtocol: 0x01
iFunction: 0x00
===>Interface Descriptor<===
bLength: 0x09
bDescriptorType: 0x04
bInterfaceNumber: 0x00
bAlternateSetting: 0x00
bNumEndpoints: 0x01
bInterfaceClass: 0x02 -> This is Communications (CDC Control) USB Device Interface Class
bInterfaceSubClass: 0x01
bInterfaceProtocol: 0x00
CAUTION: This may be an invalid bInterfaceProtocol
iInterface: 0x00
-> This is a Communications (CDC Control) USB Device Interface Class
===>Descriptor Hex Dump<===
bLength: 0x05
bDescriptorType: 0x24
05 24 00 10 01
-> This is a Communications (CDC Control) USB Device Interface Class
===>Descriptor Hex Dump<===
bLength: 0x05
bDescriptorType: 0x24
05 24 01 01 01
-> This is a Communications (CDC Control) USB Device Interface Class
===>Descriptor Hex Dump<===
bLength: 0x04
bDescriptorType: 0x24
04 24 02 06
-> This is a Communications (CDC Control) USB Device Interface Class
===>Descriptor Hex Dump<===
bLength: 0x05
bDescriptorType: 0x24
05 24 06 00 01
===>Endpoint Descriptor<===
bLength: 0x07
bDescriptorType: 0x05
bEndpointAddress: 0x81 -> Direction: IN - EndpointID: 1
bmAttributes: 0x03 -> Interrupt Transfer Type
wMaxPacketSize: 0x0010 = 0x10 bytes
bInterval: 0x40
===>Interface Descriptor<===
bLength: 0x09
bDescriptorType: 0x04
bInterfaceNumber: 0x01
bAlternateSetting: 0x00
bNumEndpoints: 0x02
bInterfaceClass: 0x0A -> This is a CDC Data USB Device Interface Class
bInterfaceSubClass: 0x01
bInterfaceProtocol: 0x00
CAUTION: This may be an invalid bInterfaceProtocol
iInterface: 0x00
===>Endpoint Descriptor<===
bLength: 0x07
bDescriptorType: 0x05
bEndpointAddress: 0x02 -> Direction: OUT - EndpointID: 2
bmAttributes: 0x02 -> Bulk Transfer Type
wMaxPacketSize: 0x0040 = 0x40 bytes
bInterval: 0x00
===>Endpoint Descriptor<===
bLength: 0x07
bDescriptorType: 0x05
bEndpointAddress: 0x83 -> Direction: IN - EndpointID: 3
bmAttributes: 0x02 -> Bulk Transfer Type
wMaxPacketSize: 0x0040 = 0x40 bytes
bInterval: 0x00
===>Interface Descriptor<===
bLength: 0x09
bDescriptorType: 0x04
bInterfaceNumber: 0x02
bAlternateSetting: 0x00
bNumEndpoints: 0x01
bInterfaceClass: 0x03 -> HID Interface Class
bInterfaceSubClass: 0x01
bInterfaceProtocol: 0x00
CAUTION: This may be an invalid bInterfaceProtocol
iInterface: 0x00
===>HID Descriptor<===
bLength: 0x09
bDescriptorType: 0x21
bcdHID: 0x0101
bCountryCode: 0x00
bNumDescriptors: 0x01
bDescriptorType: 0x22
wDescriptorLength: 0x0065
===>Endpoint Descriptor<===
bLength: 0x07
bDescriptorType: 0x05
bEndpointAddress: 0x84 -> Direction: IN - EndpointID: 4
bmAttributes: 0x03 -> Interrupt Transfer Type
wMaxPacketSize: 0x0040 = 0x40 bytes
bInterval: 0x01
How could I get this Leonardo recognized by a BIOS as a generic keyboard?

Arduino does not support the boot protocol. I have started using Teensy (which is Arduino compatible), and it works pretty well.

I might be mistaken, but if you want your device to be recognized during boot, its bInterfaceSubClass should be 0x01 (boot device subclass).
In source files, as you have pointed out, sub class is set to 0x00 everywhere.
You may try to set the subclass in all usages of the D_INTERFACE macro from file USBCore.h to 0x01.
I'm not an Arduino user. I was only once playing with HID keyboard emulation on AVR using V-USB. You can try to find detailed information about usb descriptors at USB.org in documentation. But it's quite a pile of pages to read.
Here is part od HID descriptor dump of my keyboard, notice values in Interface Descriptor:
Bus 005 Device 002: ID 046d:c30e Logitech, Inc. UltraX Keyboard (Y-BL49)
Device Descriptor:
bLength 18
bDescriptorType 1
bcdUSB 1.10
bDeviceClass 0 (Defined at Interface level)
bDeviceSubClass 0
bDeviceProtocol 0
bMaxPacketSize0 8
idVendor 0x046d Logitech, Inc.
idProduct 0xc30e UltraX Keyboard (Y-BL49)
bcdDevice 1.80
iManufacturer 1 Logitech
iProduct 2 HID compliant keyboard
iSerial 0
bNumConfigurations 1
Configuration Descriptor:
bLength 9
bDescriptorType 2
wTotalLength 59
bNumInterfaces 2
bConfigurationValue 1
iConfiguration 0
bmAttributes 0xa0
(Bus Powered)
Remote Wakeup
MaxPower 100mA
Interface Descriptor:
bLength 9
bDescriptorType 4
bInterfaceNumber 0
bAlternateSetting 0
bNumEndpoints 1
bInterfaceClass 3 Human Interface Device
bInterfaceSubClass 1 Boot Interface Subclass
bInterfaceProtocol 1 Keyboard
iInterface 0
HID Device Descriptor:
bLength 9
bDescriptorType 33
bcdHID 1.10
bCountryCode 0 Not supported
bNumDescriptors 1
bDescriptorType 34 Report
wDescriptorLength 62
The dump was made using "lsusb -v" as root under Linux.

Related

How to connect to password enabled BLE sensor?

I'm using Minew S1 Humidity and Temperature sensor with raspberry Pi, initially this sensor is password enabled, so how can I connect it to Humidity Sensor with Raspberry Pi using bluetoothctl or gatttool.
Edited:
< 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

raspberry pi4, hostapd is only working in hw_mode=a (5Ghz)

I got a raspberry pi 4 with:
cat /etc/os-release
NAME="Ubuntu"
VERSION="18.04.5 LTS (Bionic Beaver)"
ID=ubuntu
ID_LIKE=debian
PRETTY_NAME="Ubuntu 18.04.5 LTS"
When I run hostapd in hw_mode=a, everything works fine, I can see my AP and connect to it from remote devices, but when I want to use hw_mode=g or hw_mode=b, it starts without errors but I AP is not not visible, but several times I saw it was up, but only for a few seconds.
My hostapd.conf (tried with different options)
country_code=US
ieee80211d=1
ieee80211w=0
interface=wlan0
driver=nl80211
ssid=RD
hw_mode=a
channel=36
macaddr_acl=0
auth_algs=1
ignore_broadcast_ssid=0
wpa=2
wpa_passphrase=password
wpa_key_mgmt=WPA-PSK
wpa_pairwise=TKIP
rsn_pairwise=CCMP
Log for hw_mode=a
# sudo hostapd -dd /etc/hostapd/hostapd.conf
random: Trying to read entropy from /dev/random
Configuration file: /etc/hostapd/hostapd.conf
nl80211: Using driver-based roaming
nl80211: TDLS supported
nl80211: Supported cipher 00-0f-ac:1
nl80211: Supported cipher 00-0f-ac:5
nl80211: Supported cipher 00-0f-ac:2
nl80211: Supported cipher 00-0f-ac:4
nl80211: Supported cipher 00-0f-ac:6
nl80211: Using driver-based off-channel TX
nl80211: Supported vendor command: vendor_id=0x1018 subcmd=1
nl80211: Use separate P2P group interface (driver advertised support)
nl80211: Enable multi-channel concurrent (driver advertised support)
nl80211: use P2P_DEVICE support
nl80211: interface wlan0 in phy phy0
nl80211: Set mode ifindex 3 iftype 3 (AP)
nl80211: Setup AP(wlan0) - device_ap_sme=1 use_monitor=0
nl80211: Subscribe to mgmt frames with AP handle 0x55783b0d30 (device SME)
nl80211: Register frame type=0xd0 (WLAN_FC_STYPE_ACTION) nl_handle=0x55783b0d30 match=04
nl80211: Register frame type=0xd0 (WLAN_FC_STYPE_ACTION) nl_handle=0x55783b0d30 match=0501
nl80211: Register frame type=0xd0 (WLAN_FC_STYPE_ACTION) nl_handle=0x55783b0d30 match=0504
nl80211: Register frame type=0xd0 (WLAN_FC_STYPE_ACTION) nl_handle=0x55783b0d30 match=06
nl80211: Register frame type=0xd0 (WLAN_FC_STYPE_ACTION) nl_handle=0x55783b0d30 match=08
nl80211: Register frame type=0xd0 (WLAN_FC_STYPE_ACTION) nl_handle=0x55783b0d30 match=09
nl80211: Register frame type=0xd0 (WLAN_FC_STYPE_ACTION) nl_handle=0x55783b0d30 match=0a
nl80211: Register frame type=0xd0 (WLAN_FC_STYPE_ACTION) nl_handle=0x55783b0d30 match=11
nl80211: Register frame type=0xd0 (WLAN_FC_STYPE_ACTION) nl_handle=0x55783b0d30 match=7f
nl80211: Enable Probe Request reporting nl_preq=0x55783b20f0
nl80211: Register frame type=0x40 (WLAN_FC_STYPE_PROBE_REQ) nl_handle=0x55783b20f0 match=
rfkill: initial event: idx=0 type=1 op=0 soft=0 hard=0
nl80211: Add own interface ifindex 3 (ifidx_reason -1)
nl80211: if_indices[16]: 3(-1)
phy: phy0
BSS count 1, BSSID mask 00:00:00:00:00:00 (0 bits)
wlan0: interface state UNINITIALIZED->COUNTRY_UPDATE
Previous country code US, new country code US
nl80211: Regulatory information - country=US (DFS-FCC)
nl80211: 2400-2472 # 40 MHz 30 mBm
nl80211: 5150-5250 # 80 MHz 23 mBm
nl80211: 5250-5350 # 80 MHz 23 mBm (DFS)
nl80211: 5470-5730 # 160 MHz 23 mBm (DFS)
nl80211: 5730-5850 # 80 MHz 30 mBm
nl80211: 57240-71000 # 2160 MHz 40 mBm
nl80211: Added 802.11b mode based on 802.11g information
Allowed channel: mode=1 chan=1 freq=2412 MHz max_tx_power=30 dBm
Allowed channel: mode=1 chan=2 freq=2417 MHz max_tx_power=30 dBm
Allowed channel: mode=1 chan=3 freq=2422 MHz max_tx_power=30 dBm
Allowed channel: mode=1 chan=4 freq=2427 MHz max_tx_power=30 dBm
Allowed channel: mode=1 chan=5 freq=2432 MHz max_tx_power=30 dBm
Allowed channel: mode=1 chan=6 freq=2437 MHz max_tx_power=30 dBm
Allowed channel: mode=1 chan=7 freq=2442 MHz max_tx_power=30 dBm
Allowed channel: mode=1 chan=8 freq=2447 MHz max_tx_power=30 dBm
Allowed channel: mode=1 chan=9 freq=2452 MHz max_tx_power=30 dBm
Allowed channel: mode=1 chan=10 freq=2457 MHz max_tx_power=30 dBm
Allowed channel: mode=1 chan=11 freq=2462 MHz max_tx_power=30 dBm
Allowed channel: mode=2 chan=36 freq=5180 MHz max_tx_power=23 dBm
Allowed channel: mode=2 chan=40 freq=5200 MHz max_tx_power=23 dBm
Allowed channel: mode=2 chan=44 freq=5220 MHz max_tx_power=23 dBm
Allowed channel: mode=2 chan=48 freq=5240 MHz max_tx_power=23 dBm
Allowed channel: mode=2 chan=149 freq=5745 MHz max_tx_power=30 dBm
Allowed channel: mode=2 chan=153 freq=5765 MHz max_tx_power=30 dBm
Allowed channel: mode=2 chan=157 freq=5785 MHz max_tx_power=30 dBm
Allowed channel: mode=2 chan=161 freq=5805 MHz max_tx_power=30 dBm
Allowed channel: mode=2 chan=165 freq=5825 MHz max_tx_power=30 dBm
Allowed channel: mode=0 chan=1 freq=2412 MHz max_tx_power=30 dBm
Allowed channel: mode=0 chan=2 freq=2417 MHz max_tx_power=30 dBm
Allowed channel: mode=0 chan=3 freq=2422 MHz max_tx_power=30 dBm
Allowed channel: mode=0 chan=4 freq=2427 MHz max_tx_power=30 dBm
Allowed channel: mode=0 chan=5 freq=2432 MHz max_tx_power=30 dBm
Allowed channel: mode=0 chan=6 freq=2437 MHz max_tx_power=30 dBm
Allowed channel: mode=0 chan=7 freq=2442 MHz max_tx_power=30 dBm
Allowed channel: mode=0 chan=8 freq=2447 MHz max_tx_power=30 dBm
Allowed channel: mode=0 chan=9 freq=2452 MHz max_tx_power=30 dBm
Allowed channel: mode=0 chan=10 freq=2457 MHz max_tx_power=30 dBm
Allowed channel: mode=0 chan=11 freq=2462 MHz max_tx_power=30 dBm
Completing interface initialization
Mode: IEEE 802.11a Channel: 36 Frequency: 5180 MHz
DFS 0 channels required radar detection
nl80211: Set freq 5180 (ht_enabled=0, vht_enabled=0, bandwidth=20 MHz, cf1=5180 MHz, cf2=0 MHz)
* freq=5180
* vht_enabled=0
* ht_enabled=0
* channel_type=0
RATE[0] rate=60 flags=0x1
RATE[1] rate=90 flags=0x0
RATE[2] rate=120 flags=0x1
RATE[3] rate=180 flags=0x0
RATE[4] rate=240 flags=0x1
RATE[5] rate=360 flags=0x0
RATE[6] rate=480 flags=0x0
RATE[7] rate=540 flags=0x0
hostapd_setup_bss(hapd=0x55783b0120 (wlan0), first=1)
wlan0: Flushing old station entries
nl80211: flush -> DEL_STATION wlan0 (all)
nl80211: Station flush failed: ret=-14 (Bad address)
wlan0: Could not connect to kernel driver
wlan0: Deauthenticate all stations
nl80211: sta_remove -> DEL_STATION wlan0 ff:ff:ff:ff:ff:ff --> 0 (Success)
wpa_driver_nl80211_set_key: ifindex=3 (wlan0) alg=0 addr=(nil) key_idx=0 set_tx=0 seq_len=0 key_len=0
nl80211: set_key failed; err=-22 Invalid argument)
Failed to clear default encryption keys (ifname=wlan0 keyidx=0)
wpa_driver_nl80211_set_key: ifindex=3 (wlan0) alg=0 addr=(nil) key_idx=1 set_tx=0 seq_len=0 key_len=0
wpa_driver_nl80211_set_key: ifindex=3 (wlan0) alg=0 addr=(nil) key_idx=2 set_tx=0 seq_len=0 key_len=0
nl80211: set_key failed; err=-22 Invalid argument)
Failed to clear default encryption keys (ifname=wlan0 keyidx=2)
wpa_driver_nl80211_set_key: ifindex=3 (wlan0) alg=0 addr=(nil) key_idx=3 set_tx=0 seq_len=0 key_len=0
nl80211: set_key failed; err=-22 Invalid argument)
Failed to clear default encryption keys (ifname=wlan0 keyidx=3)
Using interface wlan0 with hwaddr dc:a6:32:c5:cf:d9 and ssid "RD"
Deriving WPA PSK based on passphrase
SSID - hexdump_ascii(len=2):
52 44 RD
PSK (ASCII passphrase) - hexdump_ascii(len=8): [REMOVED]
PSK (from passphrase) - hexdump(len=32): [REMOVED]
random: Got 20/20 bytes from /dev/random
Get randomness: len=32 entropy=0
GMK - hexdump(len=32): [REMOVED]
Get randomness: len=32 entropy=0
Key Counter - hexdump(len=32): [REMOVED]
WPA: Delay group state machine start until Beacon frames have been configured
nl80211: Set beacon (beacon_set=0)
nl80211: Beacon head - hexdump(len=53): 80 00 00 00 ff ff ff ff ff ff dc a6 32 c5 cf d9 dc a6 32 c5 cf d9 00 00 00 00 00 00 00 00 00 00 64 00 11 00 00 02 52 44 01 08 8c 12 98 24 b0 48 60 6c 03 01 24
nl80211: Beacon tail - hexdump(len=40): 07 0a 55 53 20 24 04 17 95 05 1e 00 30 14 01 00 00 0f ac 04 01 00 00 0f ac 04 01 00 00 0f ac 02 00 00 7f 04 00 00 00 02
nl80211: ifindex=3
nl80211: beacon_int=100
nl80211: dtim_period=2
nl80211: ssid - hexdump_ascii(len=2):
52 44 RD
* beacon_int=100
* dtim_period=2
nl80211: hidden SSID not in use
nl80211: privacy=1
nl80211: auth_algs=0x1
nl80211: wpa_version=0x2
nl80211: key_mgmt_suites=0x2
nl80211: pairwise_ciphers=0x10
nl80211: group_cipher=0x10
nl80211: beacon_ies - hexdump(len=6): 7f 04 00 00 00 02
nl80211: proberesp_ies - hexdump(len=6): 7f 04 00 00 00 02
nl80211: assocresp_ies - hexdump(len=6): 7f 04 00 00 00 02
WPA: Start group state machine to set initial keys
WPA: group state machine entering state GTK_INIT (VLAN-ID 0)
Get randomness: len=16 entropy=0
GTK - hexdump(len=16): [REMOVED]
WPA: group state machine entering state SETKEYSDONE (VLAN-ID 0)
wpa_driver_nl80211_set_key: ifindex=3 (wlan0) alg=3 addr=0x557778c9b0 key_idx=1 set_tx=1 seq_len=0 key_len=16
nl80211: KEY_DATA - hexdump(len=16): [REMOVED]
broadcast key
nl80211: Set wlan0 operstate 0->1 (UP)
netlink: Operstate: ifindex=3 linkmode=-1 (no change), operstate=6 (IF_OPER_UP)
Failed to set TX queue parameters for queue 0.
Failed to set TX queue parameters for queue 1.
Failed to set TX queue parameters for queue 2.
Failed to set TX queue parameters for queue 3.
wlan0: interface state COUNTRY_UPDATE->ENABLED
wlan0: AP-ENABLED
wlan0: Setup of interface done.
ctrl_iface not configured!
RTM_NEWLINK: ifi_index=3 ifname=wlan0 operstate=2 linkmode=0 ifi_family=0 ifi_flags=0x1003 ([UP])
RTM_NEWLINK: ifi_index=3 ifname=wlan0 operstate=6 linkmode=0 ifi_family=0 ifi_flags=0x11043 ([UP][RUNNING][LOWER_UP])
VLAN: RTM_NEWLINK: ifi_index=3 ifname=wlan0 ifi_family=0 ifi_flags=0x11043 ([UP][RUNNING][LOWER_UP])
VLAN: vlan_newlink(wlan0)
Log for hw_mode=g (channel=3)
sudo hostapd -dd /etc/hostapd/hostapd.conf
random: Trying to read entropy from /dev/random
Configuration file: /etc/hostapd/hostapd.conf
nl80211: Using driver-based roaming
nl80211: TDLS supported
nl80211: Supported cipher 00-0f-ac:1
nl80211: Supported cipher 00-0f-ac:5
nl80211: Supported cipher 00-0f-ac:2
nl80211: Supported cipher 00-0f-ac:4
nl80211: Supported cipher 00-0f-ac:6
nl80211: Using driver-based off-channel TX
nl80211: Supported vendor command: vendor_id=0x1018 subcmd=1
nl80211: Use separate P2P group interface (driver advertised support)
nl80211: Enable multi-channel concurrent (driver advertised support)
nl80211: use P2P_DEVICE support
nl80211: interface wlan0 in phy phy0
nl80211: Set mode ifindex 3 iftype 3 (AP)
nl80211: Setup AP(wlan0) - device_ap_sme=1 use_monitor=0
nl80211: Subscribe to mgmt frames with AP handle 0x55ca4b8d30 (device SME)
nl80211: Register frame type=0xd0 (WLAN_FC_STYPE_ACTION) nl_handle=0x55ca4b8d30 match=04
nl80211: Register frame type=0xd0 (WLAN_FC_STYPE_ACTION) nl_handle=0x55ca4b8d30 match=0501
nl80211: Register frame type=0xd0 (WLAN_FC_STYPE_ACTION) nl_handle=0x55ca4b8d30 match=0504
nl80211: Register frame type=0xd0 (WLAN_FC_STYPE_ACTION) nl_handle=0x55ca4b8d30 match=06
nl80211: Register frame type=0xd0 (WLAN_FC_STYPE_ACTION) nl_handle=0x55ca4b8d30 match=08
nl80211: Register frame type=0xd0 (WLAN_FC_STYPE_ACTION) nl_handle=0x55ca4b8d30 match=09
nl80211: Register frame type=0xd0 (WLAN_FC_STYPE_ACTION) nl_handle=0x55ca4b8d30 match=0a
nl80211: Register frame type=0xd0 (WLAN_FC_STYPE_ACTION) nl_handle=0x55ca4b8d30 match=11
nl80211: Register frame type=0xd0 (WLAN_FC_STYPE_ACTION) nl_handle=0x55ca4b8d30 match=7f
nl80211: Enable Probe Request reporting nl_preq=0x55ca4ba0f0
nl80211: Register frame type=0x40 (WLAN_FC_STYPE_PROBE_REQ) nl_handle=0x55ca4ba0f0 match=
rfkill: initial event: idx=0 type=1 op=0 soft=0 hard=0
nl80211: Add own interface ifindex 3 (ifidx_reason -1)
nl80211: if_indices[16]: 3(-1)
phy: phy0
BSS count 1, BSSID mask 00:00:00:00:00:00 (0 bits)
wlan0: interface state UNINITIALIZED->COUNTRY_UPDATE
Previous country code US, new country code US
nl80211: Regulatory information - country=US (DFS-FCC)
nl80211: 2400-2472 # 40 MHz 30 mBm
nl80211: 5150-5250 # 80 MHz 23 mBm
nl80211: 5250-5350 # 80 MHz 23 mBm (DFS)
nl80211: 5470-5730 # 160 MHz 23 mBm (DFS)
nl80211: 5730-5850 # 80 MHz 30 mBm
nl80211: 57240-71000 # 2160 MHz 40 mBm
nl80211: Added 802.11b mode based on 802.11g information
Allowed channel: mode=1 chan=1 freq=2412 MHz max_tx_power=30 dBm
Allowed channel: mode=1 chan=2 freq=2417 MHz max_tx_power=30 dBm
Allowed channel: mode=1 chan=3 freq=2422 MHz max_tx_power=30 dBm
Allowed channel: mode=1 chan=4 freq=2427 MHz max_tx_power=30 dBm
Allowed channel: mode=1 chan=5 freq=2432 MHz max_tx_power=30 dBm
Allowed channel: mode=1 chan=6 freq=2437 MHz max_tx_power=30 dBm
Allowed channel: mode=1 chan=7 freq=2442 MHz max_tx_power=30 dBm
Allowed channel: mode=1 chan=8 freq=2447 MHz max_tx_power=30 dBm
Allowed channel: mode=1 chan=9 freq=2452 MHz max_tx_power=30 dBm
Allowed channel: mode=1 chan=10 freq=2457 MHz max_tx_power=30 dBm
Allowed channel: mode=1 chan=11 freq=2462 MHz max_tx_power=30 dBm
Allowed channel: mode=2 chan=36 freq=5180 MHz max_tx_power=23 dBm
Allowed channel: mode=2 chan=40 freq=5200 MHz max_tx_power=23 dBm
Allowed channel: mode=2 chan=44 freq=5220 MHz max_tx_power=23 dBm
Allowed channel: mode=2 chan=48 freq=5240 MHz max_tx_power=23 dBm
Allowed channel: mode=2 chan=149 freq=5745 MHz max_tx_power=30 dBm
Allowed channel: mode=2 chan=153 freq=5765 MHz max_tx_power=30 dBm
Allowed channel: mode=2 chan=157 freq=5785 MHz max_tx_power=30 dBm
Allowed channel: mode=2 chan=161 freq=5805 MHz max_tx_power=30 dBm
Allowed channel: mode=2 chan=165 freq=5825 MHz max_tx_power=30 dBm
Allowed channel: mode=0 chan=1 freq=2412 MHz max_tx_power=30 dBm
Allowed channel: mode=0 chan=2 freq=2417 MHz max_tx_power=30 dBm
Allowed channel: mode=0 chan=3 freq=2422 MHz max_tx_power=30 dBm
Allowed channel: mode=0 chan=4 freq=2427 MHz max_tx_power=30 dBm
Allowed channel: mode=0 chan=5 freq=2432 MHz max_tx_power=30 dBm
Allowed channel: mode=0 chan=6 freq=2437 MHz max_tx_power=30 dBm
Allowed channel: mode=0 chan=7 freq=2442 MHz max_tx_power=30 dBm
Allowed channel: mode=0 chan=8 freq=2447 MHz max_tx_power=30 dBm
Allowed channel: mode=0 chan=9 freq=2452 MHz max_tx_power=30 dBm
Allowed channel: mode=0 chan=10 freq=2457 MHz max_tx_power=30 dBm
Allowed channel: mode=0 chan=11 freq=2462 MHz max_tx_power=30 dBm
Completing interface initialization
Mode: IEEE 802.11g Channel: 3 Frequency: 2422 MHz
DFS 0 channels required radar detection
nl80211: Set freq 2422 (ht_enabled=0, vht_enabled=0, bandwidth=20 MHz, cf1=2422 MHz, cf2=0 MHz)
* freq=2422
* vht_enabled=0
* ht_enabled=0
* channel_type=0
RATE[0] rate=10 flags=0x1
RATE[1] rate=20 flags=0x1
RATE[2] rate=55 flags=0x1
RATE[3] rate=110 flags=0x1
RATE[4] rate=60 flags=0x0
RATE[5] rate=90 flags=0x0
RATE[6] rate=120 flags=0x0
RATE[7] rate=180 flags=0x0
RATE[8] rate=240 flags=0x0
RATE[9] rate=360 flags=0x0
RATE[10] rate=480 flags=0x0
RATE[11] rate=540 flags=0x0
hostapd_setup_bss(hapd=0x55ca4b8120 (wlan0), first=1)
wlan0: Flushing old station entries
nl80211: flush -> DEL_STATION wlan0 (all)
nl80211: Station flush failed: ret=-14 (Bad address)
wlan0: Could not connect to kernel driver
wlan0: Deauthenticate all stations
nl80211: sta_remove -> DEL_STATION wlan0 ff:ff:ff:ff:ff:ff --> 0 (Success)
wpa_driver_nl80211_set_key: ifindex=3 (wlan0) alg=0 addr=(nil) key_idx=0 set_tx=0 seq_len=0 key_len=0
nl80211: set_key failed; err=-22 Invalid argument)
Failed to clear default encryption keys (ifname=wlan0 keyidx=0)
wpa_driver_nl80211_set_key: ifindex=3 (wlan0) alg=0 addr=(nil) key_idx=1 set_tx=0 seq_len=0 key_len=0
wpa_driver_nl80211_set_key: ifindex=3 (wlan0) alg=0 addr=(nil) key_idx=2 set_tx=0 seq_len=0 key_len=0
nl80211: set_key failed; err=-22 Invalid argument)
Failed to clear default encryption keys (ifname=wlan0 keyidx=2)
wpa_driver_nl80211_set_key: ifindex=3 (wlan0) alg=0 addr=(nil) key_idx=3 set_tx=0 seq_len=0 key_len=0
nl80211: set_key failed; err=-22 Invalid argument)
Failed to clear default encryption keys (ifname=wlan0 keyidx=3)
Using interface wlan0 with hwaddr dc:a6:32:c5:cf:d9 and ssid "RD"
Deriving WPA PSK based on passphrase
SSID - hexdump_ascii(len=2):
52 44 RD
PSK (ASCII passphrase) - hexdump_ascii(len=8): [REMOVED]
PSK (from passphrase) - hexdump(len=32): [REMOVED]
random: Got 20/20 bytes from /dev/random
Get randomness: len=32 entropy=0
GMK - hexdump(len=32): [REMOVED]
Get randomness: len=32 entropy=0
Key Counter - hexdump(len=32): [REMOVED]
WPA: Delay group state machine start until Beacon frames have been configured
nl80211: Set beacon (beacon_set=0)
nl80211: Beacon head - hexdump(len=53): 80 00 00 00 ff ff ff ff ff ff dc a6 32 c5 cf d9 dc a6 32 c5 cf d9 00 00 00 00 00 00 00 00 00 00 64 00 11 04 00 02 52 44 01 08 82 84 8b 96 0c 12 18 24 03 01 03
nl80211: Beacon tail - hexdump(len=45): 07 06 55 53 20 01 0b 1e 2a 01 04 32 04 30 48 60 6c 30 14 01 00 00 0f ac 04 01 00 00 0f ac 04 01 00 00 0f ac 02 00 00 7f 04 00 00 00 02
nl80211: ifindex=3
nl80211: beacon_int=100
nl80211: dtim_period=2
nl80211: ssid - hexdump_ascii(len=2):
52 44 RD
* beacon_int=100
* dtim_period=2
nl80211: hidden SSID not in use
nl80211: privacy=1
nl80211: auth_algs=0x1
nl80211: wpa_version=0x2
nl80211: key_mgmt_suites=0x2
nl80211: pairwise_ciphers=0x10
nl80211: group_cipher=0x10
nl80211: beacon_ies - hexdump(len=6): 7f 04 00 00 00 02
nl80211: proberesp_ies - hexdump(len=6): 7f 04 00 00 00 02
nl80211: assocresp_ies - hexdump(len=6): 7f 04 00 00 00 02
WPA: Start group state machine to set initial keys
WPA: group state machine entering state GTK_INIT (VLAN-ID 0)
Get randomness: len=16 entropy=0
GTK - hexdump(len=16): [REMOVED]
WPA: group state machine entering state SETKEYSDONE (VLAN-ID 0)
wpa_driver_nl80211_set_key: ifindex=3 (wlan0) alg=3 addr=0x558d7f09b0 key_idx=1 set_tx=1 seq_len=0 key_len=16
nl80211: KEY_DATA - hexdump(len=16): [REMOVED]
broadcast key
nl80211: Set wlan0 operstate 0->1 (UP)
netlink: Operstate: ifindex=3 linkmode=-1 (no change), operstate=6 (IF_OPER_UP)
Failed to set TX queue parameters for queue 0.
Failed to set TX queue parameters for queue 1.
Failed to set TX queue parameters for queue 2.
Failed to set TX queue parameters for queue 3.
wlan0: interface state COUNTRY_UPDATE->ENABLED
wlan0: AP-ENABLED
wlan0: Setup of interface done.
ctrl_iface not configured!
RTM_NEWLINK: ifi_index=3 ifname=wlan0 operstate=2 linkmode=0 ifi_family=0 ifi_flags=0x1003 ([UP])
RTM_NEWLINK: ifi_index=3 ifname=wlan0 operstate=6 linkmode=0 ifi_family=0 ifi_flags=0x11043 ([UP][RUNNING][LOWER_UP])
VLAN: RTM_NEWLINK: ifi_index=3 ifname=wlan0 ifi_family=0 ifi_flags=0x11043 ([UP][RUNNING][LOWER_UP])
VLAN: vlan_newlink(wlan0)
My hostpad version is 2.6, but I also tried 2.4, 2.5, 2.7 and 2.8, no difference.
Could anyone suggest what else I can try?
I solved the issue, it seems to be in firmware BOOTPART/bcm2711-rpi-4-b.dtb, after replacing it with fresh version from Ubuntu 21.04, wifi access point works correctly in any hw_mode.

ESP8266 constantly resetting, but blink script works

Hello I have been using the Wemos D1 mini lite for awhile now with this ArduCAM setup. Everything was working perfectly, but now my esp8266 is constantly resetting.
I unplugged the ArduCAM and saw I can ran the blink script successfully, but when I try to run a script where it attempts to connect to wifi, it constantly resets.
Here is my code:
#include <ESP8266WiFi.h> // Include the Wi-Fi library
const char* ssid = "ssid"; // The SSID (name) of the Wi-Fi network you want to connect to
const char* password = ""; // The password of the Wi-Fi network
void setup() {
Serial.begin(115200); // Start the Serial communication to send messages to the computer
delay(10);
Serial.println('\n');
WiFi.begin(ssid, password); // Connect to the network
Serial.print("Connecting to ");
Serial.print(ssid); Serial.println(" ...");
int i = 0;
while (WiFi.status() != WL_CONNECTED) { // Wait for the Wi-Fi to connect
delay(1000);
Serial.print(++i); Serial.print(' ');
}
Serial.println('\n');
Serial.println("Connection established!");
Serial.print("IP address:\t");
Serial.println(WiFi.localIP()); // Send the IP address of the ESP8266 to the computer
}
void loop() { }
When I run this, I get the following:
load 0x4010f000, len 1392, room 16
tail 0
chksum 0xd0
csum 0xd0
v3d128e5c
~ld
Exception (3):
epc1=0x40100710 epc2=0x00000000 epc3=0x00000000 excvaddr=0x4006e989 depc=0x00000000
>>>stack>>>
ctx: cont
sp: 3ffffb90 end: 3fffffc0 offset: 01a0
3ffffd30: feefeffe feefeffe feefeffe feefeffe
3ffffd40: feefeffe feefeffe feefeffe 3ffffef0
3ffffd50: 0000049c 0000049c 00000020 40100900
3ffffd60: feefeffe feefeffe feefeffe feefeffe
3ffffd70: 00000002 400042db 000000fd 40100b58
3ffffd80: 40004b31 00001000 000000fd 40100274
3ffffd90: 40105ae0 feefeffe feefeffe 4022da8d
3ffffda0: 40105c9d 4022db77 3ffef25c 0000049c
3ffffdb0: 000000fd 3ffffef0 3ffef25c 4022db5a
3ffffdc0: ffffff00 55aa55aa 0000000e 00000020
3ffffdd0: 00000020 00000078 00000012 aa55aa55
3ffffde0: 000000ff 4022e05a 3ffef25c 3ffef25c
3ffffdf0: 000000ff 00000119 00000119 40100640
3ffffe00: 40105c9d 00000001 3ffef26c 4022e27a
3ffffe10: 00000005 3ffef25c 000000ff 3ffffef0
3ffffe20: 3fffff10 3ffef293 0000000e 00000020
3ffffe30: 3ffef31c 3fffff51 00000001 4022e32a
3ffffe40: 3ffffef0 40239860 00000000 00000000
3ffffe50: 3ffef65c 3fffff10 3fff5594 4022e2f9
3ffffe60: 3ffef25c 4022e360 3ffe84d4 3ffe8642
3ffffe70: 40201946 3ffe8642 3ffe8663 4020189b
3ffffe80: 76696e55 69737265 6f207974 61572066
3ffffe90: 6e696873 6e6f7467 3ffffe00 40204cbc
3ffffea0: 3ffee400 00000000 3ffffe60 40204ef9
3ffffeb0: 00000f98 000001f3 000001f3 40100640
3ffffec0: 000006e8 000000dd 00000014 3ffeebc4
3ffffed0: 007a1200 44e0a632 00000000 401008cb
3ffffee0: adb5c801 fe20b34c feefeffe 00000100
3ffffef0: 76696e55 69737265 6f207974 61572066
3fffff00: 6e696873 6e6f7467 feefef00 feefeffe
3fffff10: 40203500 3ffeefcc 3ffeef4c 402035af
3fffff20: 0000001c 0001c200 00000000 00000000
3fffff30: 00000003 40203771 ffffffff 00000001
3fffff40: 40105065 00000001 3ffee35c 3ffee3d4
3fffff50: 00000000 00000001 3ffee381 00000000
3fffff60: 00000004 00000000 3ffee328 00000001
3fffff70: 0001c200 0000001c 00000000 3ffee3d4
3fffff80: 3fffdad0 3ffee328 3ffee35c 40201073
3fffff90: feefeffe feefeffe feefeffe feefeffe
3fffffa0: feefeffe 00000000 3ffee394 402024b4
3fffffb0: feefeffe feefeffe 3ffe84f0 40100b8d
<<<stack<<<
over and over and over.
I don't understand what is happening. Did I possibly short it? It couldn't have been the ArduCAM, since this was working fine already.
edit:
I found out that the Wifi.begin(ssid,password) command causes the constant reboots. When I remove this, it doesn't reboot. How can I fix this?
I think your main loop is empty. Add while(true) in the main loop function
and it´s better to set the esp in sation mode.
WiFi.mode(WIFI_STA);

How to find handles corresponding to different UUIDs of BLE devices

Using gattool, I am able to find the UUIDs correspoing to the handles of my smartwatch as follows:
Device: MAC address
Name: MS1020
Alias: MS1020
Paired: yes
Trusted: yes
Blocked: no
Connected: no
LegacyPairing: no
UUID: Generic Access Profile (00001800-0000-1000-8000-00805f9b34fb)
UUID: Unknown (0000cc00-0000-1000-8000-00805f9b34fb)
UUID: Tencent Holdings Limited (0000fee7-0000-1000-8000-00805f9b34fb)
UUID: Vendor specific (00010203-0405-0607-0809-0a0b0c0d1912)
ManufacturerData Key: 0x0211
ManufacturerData Value:
[LE]> characteristics
handle: 0x0002, char properties: 0x12, char value handle: 0x0003, uuid: 2b120008-0600-072a-0100-050200042a00
handle: 0x0004, char properties: 0x02, char value handle: 0x0005, uuid: 0708090a-0b0c-0d2b-1200-080600072a01
handle: 0x0007, char properties: 0x06, char value handle: 0x0008, uuid: 00010203-0405-0607-0809-0a0b0c0d2b12
handle: 0x000b, char properties: 0x08, char value handle: 0x000c, uuid: 0000fec7-0000-1000-8000-00805f9b34fb
handle: 0x000d, char properties: 0x20, char value handle: 0x000e, uuid: 0000fec8-0000-1000-8000-00805f9b34fb
handle: 0x0010, char properties: 0x02, char value handle: 0x0011, uuid: 0000fec9-0000-1000-8000-00805f9b34fb
handle: 0x0012, char properties: 0x32, char value handle: 0x0013, uuid: 0000fea1-0000-1000-8000-00805f9b34fb
handle: 0x0015, char properties: 0x2a, char value handle: 0x0016, uuid: 0000fea2-0000-1000-8000-00805f9b34fb
handle: 0x0019, char properties: 0x0a, char value handle: 0x001a, uuid: 0000cc02-0000-1000-8000-00805f9b34fb
handle: 0x001b, char properties: 0x12, char value handle: 0x001c, uuid: 0000cc03-0000-1000-8000-00805f9b34fb
handle: 0x001e, char properties: 0x12, char value handle: 0x001f, uuid: 0000cc04-0000-1000-8000-00805f9b34fb
handle: 0x0021, char properties: 0x1a, char value handle: 0x0022, uuid: 0000cc05-0000-1000-8000-00805f9b34fb
handle: 0x0024, char properties: 0x08, char value handle: 0x0025, uuid: 0000cc06-0000-1000-8000-00805f9b34fb
[LE]> primary
attr handle: 0x0001, end grp handle: 0x0005 uuid: 00001800-0000-1000-8000-00805f9b34fb
attr handle: 0x0006, end grp handle: 0x0009 uuid: 00010203-0405-0607-0809-0a0b0c0d1912
attr handle: 0x000a, end grp handle: 0x0017 uuid: 0000fee7-0000-1000-8000-00805f9b34fb
attr handle: 0x0018, end grp handle: 0x0025 uuid: 0000cc00-0000-1000-8000-00805f9b34fb
[LE]> char-desc
handle: 0x0001, uuid: 00002800-0000-1000-8000-00805f9b34fb
handle: 0x0002, uuid: 00002803-0000-1000-8000-00805f9b34fb
handle: 0x0003, uuid: 00002a00-0000-1000-8000-00805f9b34fb
handle: 0x0004, uuid: 00002803-0000-1000-8000-00805f9b34fb
handle: 0x0005, uuid: 00002a01-0000-1000-8000-00805f9b34fb
handle: 0x0006, uuid: 00002800-0000-1000-8000-00805f9b34fb
handle: 0x0007, uuid: 00002803-0000-1000-8000-00805f9b34fb
handle: 0x0008, uuid: 00010203-0405-0607-0809-0a0b0c0d2b12
handle: 0x0009, uuid: 00002901-0000-1000-8000-00805f9b34fb
handle: 0x000a, uuid: 00002800-0000-1000-8000-00805f9b34fb
handle: 0x000b, uuid: 00002803-0000-1000-8000-00805f9b34fb
handle: 0x000c, uuid: 0000fec7-0000-1000-8000-00805f9b34fb
handle: 0x000d, uuid: 00002803-0000-1000-8000-00805f9b34fb
handle: 0x000e, uuid: 0000fec8-0000-1000-8000-00805f9b34fb
handle: 0x000f, uuid: 00002902-0000-1000-8000-00805f9b34fb
handle: 0x0010, uuid: 00002803-0000-1000-8000-00805f9b34fb
handle: 0x0011, uuid: 0000fec9-0000-1000-8000-00805f9b34fb
handle: 0x0012, uuid: 00002803-0000-1000-8000-00805f9b34fb
handle: 0x0013, uuid: 0000fea1-0000-1000-8000-00805f9b34fb
handle: 0x0014, uuid: 00002902-0000-1000-8000-00805f9b34fb
handle: 0x0015, uuid: 00002803-0000-1000-8000-00805f9b34fb
handle: 0x0016, uuid: 0000fea2-0000-1000-8000-00805f9b34fb
handle: 0x0017, uuid: 00002902-0000-1000-8000-00805f9b34fb
handle: 0x0018, uuid: 00002800-0000-1000-8000-00805f9b34fb
handle: 0x0019, uuid: 00002803-0000-1000-8000-00805f9b34fb
handle: 0x001a, uuid: 0000cc02-0000-1000-8000-00805f9b34fb
handle: 0x001b, uuid: 00002803-0000-1000-8000-00805f9b34fb
handle: 0x001c, uuid: 0000cc03-0000-1000-8000-00805f9b34fb
handle: 0x001d, uuid: 00002902-0000-1000-8000-00805f9b34fb
handle: 0x001e, uuid: 00002803-0000-1000-8000-00805f9b34fb
handle: 0x001f, uuid: 0000cc04-0000-1000-8000-00805f9b34fb
handle: 0x0020, uuid: 00002902-0000-1000-8000-00805f9b34fb
handle: 0x0021, uuid: 00002803-0000-1000-8000-00805f9b34fb
handle: 0x0022, uuid: 0000cc05-0000-1000-8000-00805f9b34fb
handle: 0x0023, uuid: 00002902-0000-1000-8000-00805f9b34fb
handle: 0x0024, uuid: 00002803-0000-1000-8000-00805f9b34fb
handle: 0x0025, uuid: 0000cc06-0000-1000-8000-00805f9b34fb
I am confused, however, how to figure out which handle is for which
BLE feature. For instance, the page at https://www.bluetooth.com/specifications/gatt/characteristics/ shows that the Battery level specification feature is at 0x2A19. However, I can not figure out where or how to get the UUID corresponding to 0x2A19 in the char-desc output above. How do I get this?
Edit: Thanks for the very helpful descriptions in the answers (both are very good). I have added the characteristics information above. I also have some additional information which may or may not be useful.
By trial and error, I am able to establish that the blood pressure measurement (obtained from when I press the button on the watchband) Is obtained from the third and fourth entries (in hexadecimal format) of the notification handle (see output):
Notification handle = 0x001f value: f3 14 73 4d 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
However, when nothing is done, that is, no button is pressed, I get:
[LE]> char-read-hnd 0x001f
Characteristic value/descriptor: 07 00 04 4e 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
The same notification handle gives the heart rate (when that button is pressed) in the 11th entry:
Notification handle = 0x001f value: 20 00 00 00 00 00 00 00 00 00 63 00 00 00 00 00 00 00 00 00
In all cases, however, the first entry has also changed (and they appear to be unique to the operation and inaction).
I wonder if I can access the information, and also how to trigger the BP measurement, for example. Thanks again!
Please let me know in the comments if my question is not clear or if more information is needed. I am happy to provide additional information as needed. Thanks for your time in reading and making suggesitons/pointers.
Battery Level characteristic is not "at 0x2A19", but it is UUID 00002A19-0000-1000-8000-00805f9b34fb. It seems there is no such characteristic on your device. Note Battery Service is allowed to be declared as Secondary Service, then it may not be discovered by "primary" command.
Update after edit:
Unfortunately, this device uses non-standard characteristic (handle 0x1e, type 0000cc04-0000-1000-8000-00805f9b34fb) inside a non-standard service (handle 0x18, type 0000cc00-0000-1000-8000-00805f9b34fb) for passing data. If there is a way to trigger measurements you want, it belongs to reverse-engineering.
TL;DR
Bluetooth Specification wanted to allow vendor-specific GATT features to coexist with standard features, without the need for a global directory. For this, everything in GATT is designated through IDs that are 128 bits UUIDs in a way anyone can generate without really caring about collisions.
Everything is typed by an UUID, See 3.G.2.5.1:
The Attribute Type is a UUID that describes the Attribute Value.
Every Service has a type as well, See 3.G.3.1:
A service declaration is an Attribute with the Attribute Type set to the UUID for «Primary Service» or «Secondary Service». [...] A
client may ignore any service definition with an unknown service
UUID. An unknown service UUID is a UUID for an unsupported service.
And evey characteristic has a type as well, See 3.G.3.3.1:
A characteristic declaration is an Attribute with the Attribute Type set to the UUID for «Characteristic» and Attribute Value set to
the Characteristic Properties, Characteristic Value Attribute Handle
and Characteristic UUID.
UUID allocation is simple, and we have a perfect illustration with the dump from your device above:
Have standard-defined uses, stick to the standard UUIDs,
Bluetooth SIG offers its members to get a Bluetooth-based UUID for optimized usage, so 0000fee7-0000-1000-8000-00805f9b34fb is compliant and vendor-specific (Allocated by SIG to Tencent Holdings Limited on 24/04/2014).
Generate a random UUID from scratch and use it for custom purposes. 00010203-0405-0607-0809-0a0b0c0d1912 looks compliant, but does not look random at all. Someone else may get to the same value by chance.
OTOH, I cannot find any Bluetooth spec defining 0000cc00-0000-1000-8000-00805f9b34fb, it looks non-compliant.
Bluetooth spec took care of itself and optimized the UUID process for its own spec usage in two ways:
To make them easy to look for, all Bluetooth-defined IDs have a common base that is nnnnnnnn-0000-1000-8000-00805f9b34fb, where nnnnnnnn is 32-bit value where collisions are not acceptable, thus must be strictly controlled when allocated. See 3.B.2.5.1:
To reduce the burden of storing and transferring 128-bit UUID values, a range of UUID values has been pre-allocated for assignment to often-used, registered purposes.
When you look at the GATT Service/GATT Characteristics page, you are actually looking at a list of bluetooth-based UUIDs, i.e. you should append -0000-1000-8000-00805f9b34fb when you look for them in the output of gatttool.
As an optimization, GATT protocol allows to encode Bluettoth-based UUIDs as shorter variants that are the "16-bit" and "32-bit" variants, i.e. not repeating -0000-1000-8000-00805f9b34fb. For an example of such thing, see table 3.4 in 3.G.3.3.1.
The output of primary is telling you which services your device supports, e.g.: the first segment of uuid: 00001800-0000-1000-8000-00805f9b34fb is 00001800 which is the Generic Access service (org.bluetooth.service.generic_access, 0x1800).
The output of primary does not list the Battery Service (org.bluetooth.service.battery_service, 0x180F):
[LE]> primary
attr handle: 0x0001, end grp handle: 0x0005 uuid: 00001800-0000-1000-8000-00805f9b34fb
attr handle: 0x0006, end grp handle: 0x0009 uuid: 00010203-0405-0607-0809-0a0b0c0d1912
attr handle: 0x000a, end grp handle: 0x0017 uuid: 0000fee7-0000-1000-8000-00805f9b34fb
attr handle: 0x0018, end grp handle: 0x0025 uuid: 0000cc00-0000-1000-8000-00805f9b34fb
Due to the absence of the Battery Service you will not find any Battery Service-related characteristics, such as Battery Level, Battery Level State, Batter Power State, etc..
References:
GATT Services
GATT Characteristics

Uploading Problems with the Arduino Robot: butterfly_recv(): programmer is not responding

I started working with the Arduino Robot Control Board a few days ago. I did a few tutorials and everything was fine. I could perfectly upload my programs using the Arduino IDE.
Today, I was working on a project and already did uploading, testing, adjusting, uploading again,... I pressed the Upload button and nothing happened and I got the following error message (with verbose output enabled):
Der Sketch verwendet 14960 Bytes (52%) des Programmspeicherplatzes. Das Maximum sind 28672 Bytes.
Globale Variablen verwenden 1539 Bytes (60%) des dynamischen Speichers, 1021 Bytes für lokale Variablen verbleiben. Das Maximum sind 2560 Bytes.
Erzwinge Reset durch öffnen/schließen mit 1200 bps auf dem Port /dev/ttyACM1
Beim Hochladen des Sketches ist ein Fehler aufgetreten
PORTS {/dev/ttyACM1, } / {/dev/ttyACM1, } => {}
PORTS {/dev/ttyACM1, } / {/dev/ttyACM1, } => {}
PORTS {/dev/ttyACM1, } / {/dev/ttyACM1, } => {}
PORTS {/dev/ttyACM1, } / {/dev/ttyACM1, } => {}
PORTS {/dev/ttyACM1, } / {/dev/ttyACM1, } => {}
PORTS {/dev/ttyACM1, } / {/dev/ttyACM1, } => {}
PORTS {/dev/ttyACM1, } / {/dev/ttyACM1, } => {}
PORTS {/dev/ttyACM1, } / {/dev/ttyACM1, } => {}
PORTS {/dev/ttyACM1, } / {/dev/ttyACM1, } => {}
PORTS {/dev/ttyACM1, } / {/dev/ttyACM1, } => {}
PORTS {/dev/ttyACM1, } / {/dev/ttyACM1, } => {}
PORTS {/dev/ttyACM1, } / {/dev/ttyACM1, } => {}
PORTS {/dev/ttyACM1, } / {/dev/ttyACM1, } => {}
PORTS {/dev/ttyACM1, } / {/dev/ttyACM1, } => {}
PORTS {/dev/ttyACM1, } / {/dev/ttyACM1, } => {}
PORTS {/dev/ttyACM1, } / {/dev/ttyACM1, } => {}
PORTS {/dev/ttyACM1, } / {/dev/ttyACM1, } => {}
PORTS {/dev/ttyACM1, } / {/dev/ttyACM1, } => {}
PORTS {/dev/ttyACM1, } / {/dev/ttyACM1, } => {}
PORTS {/dev/ttyACM1, } / {/dev/ttyACM1, } => {}
Uploading using selected port: /dev/ttyACM1
/home/lukas/Dokumente/Arduino/arduino-1.8.5/hardware/tools/avr/bin/avrdude -C/home/lukas/Dokumente/Arduino/arduino-1.8.5/hardware/tools/avr/etc/avrdude.conf -v -patmega32u4 -cavr109 -P/dev/ttyACM1 -b57600 -D -Uflash:w:/tmp/arduino_build_7255/Interrupts.ino.hex:i
avrdude: Version 6.3, compiled on Jan 17 2017 at 06:01:25
Copyright (c) 2000-2005 Brian Dean, http://www.bdmicro.com/
Copyright (c) 2007-2014 Joerg Wunsch
System wide configuration file is "/home/lukas/Dokumente/Arduino/arduino-1.8.5/hardware/tools/avr/etc/avrdude.conf"
User configuration file is "/home/lukas/.avrduderc"
User configuration file does not exist or is not a regular file, skipping
Using Port : /dev/ttyACM1
Using Programmer : avr109
Overriding Baud Rate : 57600
AVR Part : ATmega32U4
Chip Erase delay : 9000 us
PAGEL : PD7
BS2 : PA0
RESET disposition : dedicated
RETRY pulse : SCK
serial program mode : yes
parallel program mode : yes
Timeout : 200
StabDelay : 100
CmdexeDelay : 25
SyncLoops : 32
ByteDelay : 0
PollIndex : 3
PollValue : 0x53
Memory Detail :
Block Poll Page Polled
Memory Type Mode Delay Size Indx Paged Size Size #Pages MinW MaxW ReadBack
----------- ---- ----- ----- ---- ------ ------ ---- ------ ----- ----- ---------
eeprom 65 20 4 0 no 1024 4 0 9000 9000 0x00 0x00
flash 65 6 128 0 yes 32768 128 256 4500 4500 0x00 0x00
lfuse 0 0 0 0 no 1 0 0 9000 9000 0x00 0x00
hfuse 0 0 0 0 no 1 0 0 9000 9000 0x00 0x00
efuse 0 0 0 0 no 1 0 0 9000 9000 0x00 0x00
lock 0 0 0 0 no 1 0 0 9000 9000 0x00 0x00
calibration 0 0 0 0 no 1 0 0 0 0 0x00 0x00
signature 0 0 0 0 no 3 0 0 0 0 0x00 0x00
Programmer Type : butterfly
Description : Atmel AppNote AVR109 Boot Loader
Connecting to programmer: .avrdude: butterfly_recv(): programmer is not responding
avrdude: butterfly_recv(): programmer is not responding
avrdude: butterfly_recv(): programmer is not responding
avrdude: butterfly_recv(): programmer is not responding
avrdude: butterfly_recv(): programmer is not responding
avrdude: butterfly_recv(): programmer is not responding
Found programmer: Id = "�"; type = �
Software Version = Y.�; Hardware Version = .
avrdude: butterfly_recv(): programmer is not responding
avrdude: butterfly_recv(): programmer is not responding
avrdude: error: buffered memory access not supported. Maybe it isn't
a butterfly/AVR109 but a AVR910 device?
avrdude: initialization failed, rc=-1
Double check connections and try again, or use -F to override
this check.
avrdude: butterfly_recv(): programmer is not responding
avrdude: error: programmer did not respond to command: leave prog mode
avrdude: butterfly_recv(): programmer is not responding
avrdude: error: programmer did not respond to command: exit bootloader
I did check the connection, made sure, that the USB cable is not broken. I actually can use the IDE to upload programs to the lower Motor Board, so it's not the IDE's fault, I assume. But as I am fairly new to the Arduino World, I am quite clueless now.
I read a lot of forum posts, but I couldn't find a working solution. Similiar problems seem to happen to others as well, but for other Arduino platforms. Those answers did not solve my problem, including the Arduino Forum itself.
I am currently on Lubuntu 16.04.3 LTS or Windows 10. The same problem is on both OSes.

Resources