Btstack and windows CE 6.0

288 views
Skip to first unread message

Fernando Olmeda Arcos

unread,
Dec 6, 2020, 5:25:08 PM12/6/20
to btstack-dev
Dear all,

I have a little big problem. I have a project who works perfectly with Bluetooth BLE but now I need to send data to a portable computer (Zebra workabout pro4) which  has only bluetooth V2.0 so is not compatible with BLE. This computer has two bluetooth stacks.
Microsoft Bluetooth stack and StoneStree one (BTexplorer)

After a lot of searchs I discovered BTstack but it is for me more complicated than I would like.

My project consists in

1 - A scale which send data through RS232 to a RS232ttl pluged to  a ESP32.
2 - ESP32 read every line sent by the scale. I only need part of this data, the weight
3 - this weight is send it over bluetooth to a this portable computer (Workabout4) as keystrokes

If I use Microsoft Bluetooth stack, I can discover ESP32, then I can select type of device (Input Device) with a checkbox. But when I click this checkbox, after a while, is not possible to pair, because appears an error "Failed to enable service"

if I use StoneStreet (BTexplorer) I can pair ESP32 as hid device and in Monitor appears HID Connected, please start typing....

But if I type, nothing occurs.

Could someone tell me any clue to fix these problems?

Thanks in advanced.

PD.

This is that monitor said with Microsoft Bluetooth stack after I check Input device checkbox

[00:00:20.130] LOG -- hci.c.2365: Connection_incoming: 3C:A3:08:8E:1F:D4, type 1

[00:00:20.130] LOG -- hci.c.194: create_connection_for_addr 3C:A3:08:8E:1F:D4, type fd

[00:00:20.134] LOG -- hci.c.4037: sending hci_accept_connection_request

[00:00:20.151] LOG -- hci.c.2389: Connection_complete (status=0) 3C:A3:08:8E:1F:D4

[00:00:20.151] LOG -- hci.c.2409: New connection: handle 129, 3C:A3:08:8E:1F:D4

[00:00:20.157] LOG -- hci.c.4865: BTSTACK_EVENT_NR_CONNECTIONS_CHANGED 1

[00:00:20.165] LOG -- l2cap.c.1974: create channel 0x3ffd2af0, local_cid 0x0041

[00:00:20.170] LOG -- hci.c.5038: gap_request_security_level requested level 0, planned level 0, current level 0

[00:00:20.180] LOG -- hci.c.4896: hci_emit_security_level 0 for handle 81

[00:00:20.187] LOG -- l2cap.c.2413: l2cap - security level update for handle 0x0081

[00:00:20.194] LOG -- l2cap.c.2423: channel 0x3ffd2af0, cid 0041 - state 5: actual 0 >= required 0?

[00:00:20.203] LOG -- l2cap.c.1069: L2CAP_EVENT_INCOMING_CONNECTION addr 3C:A3:08:8E:1F:D4 handle 0x81 psm 0x1 local_cid 0x41 remote_cid 0x41

[00:00:20.215] LOG -- l2cap.c.2536: L2CAP_ACCEPT_CONNECTION local_cid 0x41

[00:00:20.223] LOG -- hci.c.1953: Remote features 03, bonding flags 18

[00:00:20.228] LOG -- l2cap.c.2406: remote supported features, channel 0x3ffd2af0, cid 0041 - state 11

[00:00:20.238] LOG -- l2cap.c.1227: l2cap_stop_rtx for local cid 0x41

[00:00:20.243] LOG -- l2cap.c.1236: l2cap_start_rtx for local cid 0x41

[00:00:20.250] LOG -- l2cap.c.2745: L2CAP signaling handler code 4, state 11

[00:00:20.256] LOG -- l2cap.c.2592: Remote MTU 4096

[00:00:20.261] LOG -- l2cap.c.2594: Remote MTU 4096 larger than outgoing buffer, only using MTU = 1691

[00:00:20.270] LOG -- l2cap.c.2745: L2CAP signaling handler code 5, state 11

[00:00:20.277] LOG -- l2cap.c.1227: l2cap_stop_rtx for local cid 0x41

[00:00:20.283] LOG -- l2cap.c.2676: l2cap_signaling_handle_configure_response

[00:00:20.290] LOG -- l2cap.c.1035: L2CAP_EVENT_CHANNEL_OPENED status 0x0 addr 3C:A3:08:8E:1F:D4 handle 0x81 psm 0x1 local_cid 0x41 remote_cid 0x41 local_mtu 1691, remote_mtu 1691, flush_timeout 0

[00:00:20.367] LOG -- l2cap.c.2745: L2CAP signaling handler code 6, state 12

[00:00:20.368] LOG -- l2cap.c.1063: L2CAP_EVENT_CHANNEL_CLOSED local_cid 0x41

[00:00:20.370] LOG -- l2cap.c.1980: free channel 0x3ffd2af0, local_cid 0x0041

[00:00:20.377] LOG -- l2cap.c.1227: l2cap_stop_rtx for local cid 0x41

[00:00:20.388] LOG -- l2cap.c.1974: create channel 0x3ffd2af0, local_cid 0x0042

[00:00:20.390] LOG -- hci.c.5038: gap_request_security_level requested level 0, planned level 0, current level 0

[00:00:20.400] LOG -- hci.c.4896: hci_emit_security_level 0 for handle 81

[00:00:20.406] LOG -- l2cap.c.2413: l2cap - security level update for handle 0x0081

[00:00:20.414] LOG -- l2cap.c.2423: channel 0x3ffd2af0, cid 0042 - state 5: actual 0 >= required 0?

[00:00:20.422] LOG -- l2cap.c.1069: L2CAP_EVENT_INCOMING_CONNECTION addr 3C:A3:08:8E:1F:D4 handle 0x81 psm 0x1 local_cid 0x42 remote_cid 0x42

[00:00:20.435] LOG -- l2cap.c.2536: L2CAP_ACCEPT_CONNECTION local_cid 0x42

[00:00:20.442] LOG -- l2cap.c.1227: l2cap_stop_rtx for local cid 0x42

[00:00:20.448] LOG -- l2cap.c.1236: l2cap_start_rtx for local cid 0x42

[00:00:20.478] LOG -- l2cap.c.2745: L2CAP signaling handler code 4, state 11

[00:00:20.479] LOG -- l2cap.c.2592: Remote MTU 4096

[00:00:20.479] LOG -- l2cap.c.2594: Remote MTU 4096 larger than outgoing buffer, only using MTU = 1691

[00:00:20.488] LOG -- l2cap.c.2745: L2CAP signaling handler code 5, state 11

[00:00:20.494] LOG -- l2cap.c.1227: l2cap_stop_rtx for local cid 0x42

[00:00:20.501] LOG -- l2cap.c.2676: l2cap_signaling_handle_configure_response

[00:00:20.508] LOG -- l2cap.c.1035: L2CAP_EVENT_CHANNEL_OPENED status 0x0 addr 3C:A3:08:8E:1F:D4 handle 0x81 psm 0x1 local_cid 0x42 remote_cid 0x42 local_mtu 1691, remote_mtu 1691, flush_timeout 0

[00:00:20.546] LOG -- l2cap.c.2745: L2CAP signaling handler code 6, state 12

[00:00:20.546] LOG -- l2cap.c.1063: L2CAP_EVENT_CHANNEL_CLOSED local_cid 0x42

[00:00:20.549] LOG -- l2cap.c.1980: free channel 0x3ffd2af0, local_cid 0x0042

[00:00:20.555] LOG -- l2cap.c.1227: l2cap_stop_rtx for local cid 0x42

[00:00:29.633] LOG -- hci.c.950: Connection closed: handle 0x81, 3C:A3:08:8E:1F:D4

[00:00:29.634] LOG -- hci.c.4865: BTSTACK_EVENT_NR_CONNECTIONS_CHANGED 0

[00:01:08.167] LOG -- hci.c.2365: Connection_incoming: 3C:A3:08:8E:1F:D4, type 1

[00:01:08.168] LOG -- hci.c.194: create_connection_for_addr 3C:A3:08:8E:1F:D4, type fd

[00:01:08.171] LOG -- hci.c.4037: sending hci_accept_connection_request

[00:01:08.188] LOG -- hci.c.2389: Connection_complete (status=0) 3C:A3:08:8E:1F:D4

[00:01:08.189] LOG -- hci.c.2409: New connection: handle 128, 3C:A3:08:8E:1F:D4

[00:01:08.192] LOG -- hci.c.4865: BTSTACK_EVENT_NR_CONNECTIONS_CHANGED 1

[00:01:08.202] LOG -- l2cap.c.1974: create channel 0x3ffd2af0, local_cid 0x0043

[00:01:08.205] LOG -- hci.c.5038: gap_request_security_level requested level 2, planned level 0, current level 0

[00:01:08.215] LOG -- hci.c.1953: Remote features 03, bonding flags 418

[00:01:08.221] LOG -- l2cap.c.2406: remote supported features, channel 0x3ffd2af0, cid 0043 - state 5

[00:01:08.232] LOG -- hci.c.2502: HCI_EVENT_LINK_KEY_REQUEST

[00:01:08.236] LOG -- hci.c.4079: responding to link key request

[00:01:08.243] LOG -- btstack_link_key_db_tlv.c.95: tag 42544c0d, addr 5C:3A:45:29:1E:7C

[00:01:08.250] LOG -- btstack_link_key_db_tlv.c.95: tag 42544c0f, addr 70:1F:3C:92:B6:5A

[00:01:38.334] LOG -- hci.c.4896: hci_emit_security_level 0 for handle 80

[00:01:38.334] LOG -- l2cap.c.2413: l2cap - security level update for handle 0x0080

[00:01:38.337] LOG -- l2cap.c.2423: channel 0x3ffd2af0, cid 0043 - state 5: actual 0 >= required 2?

abort() was called at PC 0x40082692 on core 0

0x40082692: lock_acquire_generic at C:/esp/components/newlib/locks.c:143

 

 

ELF file SHA256: c51455ef98509669

Matthias Ringwald

unread,
Dec 7, 2020, 9:54:56 AM12/7/20
to btsta...@googlegroups.com
Hi Fernando

What profiles are supported in the different stacks on Win CE?

For your scale, I can imagine using SPP (serial port) or HID (sending keystrokes)

In the lo below there's a line that mentions abort()

> abort() was called at PC 0x40082692 on core 0

It looks like something crashes here. It may be your code, something in the stack, or something in the ESP32 firmware/RTOS.

I suggest to test BTstack's hid_keyboard_demo example on a desktop computer, see port/libusb or port/windows-winusb to verify that you can simulate a keyboard to the Win CE thing, and if that's working, go back to the ESP32 and continue there.

Best
Matthias
> --
> You received this message because you are subscribed to the Google Groups "btstack-dev" group.
> To unsubscribe from this group and stop receiving emails from it, send an email to btstack-dev...@googlegroups.com.
> To view this discussion on the web visit https://groups.google.com/d/msgid/btstack-dev/6dc54aff-8e1f-4555-ba26-3fa4796a4259n%40googlegroups.com.

Fernando Olmeda Arcos

unread,
Dec 8, 2020, 7:46:45 AM12/8/20
to btstack-dev
Hi Matthias,

Stonestree One API Bluetopia, 

Supported Bluetooth profiles:

  • Generic Access Profile (GAP), Serial Port Profile (SPP), FAX Profile (FAX), Dial Up Networking Profile (DUN), Generic Object Exchange Profile (GOEP), OBEX Object Push Profile (OPP), OBEX File Transfer Profile (FTP), Headset Profile (HSP), Hands Free Profile (HFP), Hardcopy Cable Replacement Profile (HCRP), Human Interface Device Profile (HID), Synchronization Profile (SYNC), SIM Access Profile (SAP), Generic Audio/Video Distribution Profile (GAVDP), Advanced Audio Distribution Profile (A2DP), Basic Imaging Profile (BIP)
The same for MS bluetooth stack

My project which works perfect with any BLE device is made in Arduino IDE and only I read all data received by serial port with serial.read() and with substring I catch up weight data. Library that I have used for this project is ESP32 BLE Keyboard library.

The code I use for hid_keyboard_demo is one of provided by BTstack, unmodified. Works perfectly with android phone, not with windows 10 nor windows CE. In both cases I can find ESP32 but in Windows CE as said before, when I chose input device I can't pair with the error described before. With windows 10, in monitor appears this error

[00:00:31.872] LOG -- hci.c.1953: Remote features 03, bonding flags 38
[00:00:31.878] LOG -- l2cap.c.2406: remote supported features, channel 0x3ffd288c, cid 0042 - state 12
[00:00:31.888] LOG -- hci.c.4115: IO Capability Request received, stack bondable 1, io cap 3
[00:00:31.896] LOG -- hci.c.5010: gap_mitm_protection_required_for_security_level 0
[00:00:32.066] LOG -- hid_keyboard_demo.c.323: SSP User Confirmation Request with numeric value '394142'

[00:00:32.066] LOG -- hid_keyboard_demo.c.324: SSP User Confirmation Auto accept

[00:00:32.432] LOG -- hci.c.398: gap_store_link_key_for_bd_addr: 5C:3A:45:29:1E:7C, type 4
[00:00:32.434] LOG -- btstack_link_key_db_tlv.c.151: tag_for_addr 42544c0e, tag_for_empy 42544c0d, tag_for_lowest_seq_nr 42544c0f
[00:00:32.441] LOG -- btstack_link_key_db_tlv.c.165: store with tag 42544c0e
[00:00:32.448] LOG -- btstack_tlv_esp32.c.97: store tag 42544C0E
[00:00:32.467] LOG -- hci.c.2133: Handle 0081 key Size: 16
[00:00:32.468] LOG -- hci.c.2502: HCI_EVENT_LINK_KEY_REQUEST
[00:00:32.469] LOG -- hci.c.4079: responding to link key request
[00:00:32.473] LOG -- btstack_link_key_db_tlv.c.95: tag 42544c0e, addr 5C:3A:45:29:1E:7C
[00:00:32.523] LOG -- hci.c.4896: hci_emit_security_level 2 for handle 81
[00:00:32.523] LOG -- l2cap.c.2413: l2cap - security level update for handle 0x0081
[00:00:32.526] LOG -- l2cASSERT_WARN(103 23), in lc_task.c at line 8775ap.c.2423: channel 0x3ffd288c, cid 0042 - state 12: actual 2 >= required 0?
ASSERT_WARN(103 24), in lc_task.c at line 8775

With Android phone, when I pair, phone ask me if i sure to pair devices, I chose yes and everything works perfect.

Is possible that I have problems pairing devices by security codes o policies?

Can I use BTstack keyboard demo  in Arduino IDE instead ESP-IDF ?

Fernando Olmeda Arcos

unread,
Dec 8, 2020, 11:26:09 AM12/8/20
to btstack-dev
For anyone who needs my solution to connect ESP32 with Windows CE V6.0 with Bluetooth 2.0 as input device.

After read a lot of logs from different devices. I noticed that at the moment when I try to pair ESP32 and Windows CE device, Security level was a problem when in the other devices no.

So in the same log I read than the problem was in HCI file and security policies

So I change hci_stack->gap_security_level = LEVEL_2; to hci_stack->gap_security_level = LEVEL_0;

and

hci_stack->ssp_io_capability = SSP_IO_CAPABILITY_KEYBOARD_ONLY;

Now, I can use PC keyboard as bluetooth keyboard.

Next step.
In ESP-IDF read serial data, work whit this data to obtain a variable and send it as keystroke to windows CE

Or put in Arduino IDE Btstack library and use only the code to make a server and HID Device and send data over bluetooth

I'm very comfortable with Arduino IDE and my first project works perfectly, but only works with BLE devices.

So please, please, please, Can anyone helps me to put btstack in arduino ide and make as HID_keyboard_demo? But only with necessary code.

Thanks in advanced

Matthias Ringwald

unread,
Dec 8, 2020, 12:10:09 PM12/8/20
to btsta...@googlegroups.com
Hi Fernardo

I'm glad that it works without encryption, although in your last log it looks like the pairing and encryption worked as expected.

If you want to dig deeper, please enable packet logging in main.c by uncommenting hci_dump(..).

Anyway, in your log below, you get a crash in the Bluetooth implementation of the ESP32, the "ASSERT_WARN" is not from BTstack.
Maybe we get more information with HCI dump enabled.

Again, it would also be good to check with hid_keyboard running on a desktop system.

As the keyboard emulation works, you could add the code to handle the ESP32 serial port to the hid_keyboard demo. E.g. you could use a BTstack timer to periodically check if there's no data from serial and send keystrokes as needed.

Integrating BTstack into the ESP version of Arduino is most likely more work... :) Again, putting code into a timer handler is very similar to putting code in the Arduino loop() functions.

Best
Matthias
> To view this discussion on the web visit https://groups.google.com/d/msgid/btstack-dev/606324e0-fdcc-4225-a477-811af32b56d5n%40googlegroups.com.

Fernando Olmeda Arcos

unread,
Dec 8, 2020, 12:24:03 PM12/8/20
to btstack-dev
Hi Matthias,

Thanks for your help.

I'm very very new with C++ and ESP-IDF, and I have no much time to deploy this project. Is that because I would like to use Arduino IDE, but if is more work to do, with Arduino IDE, i will use ESP-IDF with HID_KEYBOARD_DEMO code.

So to start using HID_KEYBOARD_DEMO code, I need to delete the part that use BTstack stdin. Any suggestion for that? Because now I can typing with monitor but not send text.

Matthias Ringwald

unread,
Dec 9, 2020, 5:03:24 AM12/9/20
to btsta...@googlegroups.com
Hi Fernando

Removing functionality from existing code is usually easy - unless product marketing is sitting in your neck :)

In the demo, if HAVE_BTSTACK_STDIN is not defined, the demo will connect to a fixed device and then type a hard-coded text. If you disable the code to connect and just use the simulated typing, you're pretty close to your use case.

Best
Matthias
> To view this discussion on the web visit https://groups.google.com/d/msgid/btstack-dev/651bb187-e748-476e-9c89-16df5567c039n%40googlegroups.com.

Reply all
Reply to author
Forward
0 new messages