im using BTool to send commands to CC2540 bluetooth module. I want to get notifications. when I send notification command, btool displayed the sent command
[43] : <Tx> - 11:11:47.051
-Type : 0x01 (Command)
-OpCode : 0xFD9B (GATT_Notification)
-Data Length : 0x06 (6) byte(s)
ConnHandle : 0x0000 (0)
Authentic : 0x00 (0) (No)
Handle : 0x1B00 (6912)
Value : 00:50
Dump(Tx):
0000:01 9B FD 06 00 00 00 1B 00 50
the values of the Handle (temperature characteristic) and connHandle are correct, but I dont get any response from the server. is there any prior configuration to perform, like enabling notifications somewhere?
You need to enable notification for the characteristic. First you need to query for the client characteristic configuration uuid:
08 1B 00 1C 00 02 29
where first byte is the op read request, next two bytes are you handle id, subsequent two bytes are the range limit (handle id + 1), and the last two bytes are the GATT_CLIENT_CHARAC_CFG_UUID filter. You'll get a response similar to this:
09 04 LL HH 00 00
where the first byte is the response (read by type response), next byte is payload length, LL HH is the configuration characteristic handle, and the last two bytes are it's value.
At this step you can enable the notification by writing a 0x0001 to this handle id:
12 LL HH 01 00
At his point the notification for you characteristic should be enabled.
Related
I followed the tutorial from The Bluetooth Technology for Linux Developers Study Guide (I skipped the 5th guide because I'm doing a gatt server), and everything worked fine until I got to Handling Characteristic Writes.
(Also, I am using a Raspberry PI 4 Model B)
In nRF Connect I have the following in the logs:
Writing request to characteristic e95d93ee-251d-470a-a062-fa1922dfa9a8
Data written to e95d93ee-251d-470a-a062-fa1922dfa9a8, value: (0x)68-65-6C-6C-6F, "hello"
"hello" sent
so the data should have been sent.
sudo btmon gives the following:
> ACL Data RX: Handle 64 flags 0x02 dlen 14 #129 [hci0] 82.584227
ATT: Prepare Write Request (0x16) len 9
Handle: 0x0019
Offset: 0x0000
Data: 68656c6c6f
< ACL Data TX: Handle 64 flags 0x00 dlen 14 #130 [hci0] 82.585053
ATT: Prepare Write Response (0x17) len 9
Handle: 0x0019
Offset: 0x0000
Data: 68656c6c6f
> HCI Event: Number of Completed Packets (0x13) plen 5 #131 [hci0] 82.814773
Num handles: 1
Handle: 64
Count: 1
so the data was indeed received. Though I don't understand why it says Prepare Write Request instead of just Write Request.
bluetoothd with -nd flag and tail -f /var/log/syslog gives the following:
Jul 28 09:20:45 raspberrypi bluetoothd[820]: bluetoothd[820]: src/device.c:gatt_debug() (chan 0x1bb9dd0) ATT PDU received: 0x16
Jul 28 09:20:45 raspberrypi bluetoothd[820]: bluetoothd[820]: src/device.c:gatt_debug() Prep Write Req - handle: 0x0019
Jul 28 09:20:45 raspberrypi bluetoothd[820]: src/device.c:gatt_debug() (chan 0x1bb9dd0) ATT PDU received: 0x16
Jul 28 09:20:45 raspberrypi bluetoothd[820]: src/device.c:gatt_debug() Prep Write Req - handle: 0x0019
but there is no reaction using sudo dbus-monitor --system, and nothing either in the program output terminal.
Do you have any Idea where the problem might come from?
(I tried reinstalling nRF Connect twice already, so I think the problem is from somewhere in the Raspberry, but is it from bluez? from dbus? or somewhere else?)
After reinstalling bluez, and not solving anything, I tried with an old samsung tablet, and it works. So it appears my assumption was wrong and the problem could be from my phone.
I am broadcasting a BLE advertisement using the following command in linux :
sudo hcitool -i hci0 cmd 0x08 0x0008 1E 02 01 1A 1A FF 4C 00 02 15 63 6F 3F 8F 64 91 4B EE 95 F7 D8 CC 64 A8 63 B5 00 00 00 00 C8
The BLE devce is visible, but don't allow any connection (since it follows the iBeacon specs, I think).
So my question is, is there a way to create with BlueZ a BLE device that allows not just one, but several connections ?
I read somewhere that A BLE device should be able to allow up to 20 connections, against 7 for a classic bluetooth.
Thank you very much
This depends on your hardware and the Bluetooth version that it supports. With Bluetooth v4.1, all restrictions have been removed and your device can be a peripheral connected to multiple centrals. This is mentioned at this link:-
Beginning with version 4.1 of the specification, any restrictions on
role combinations have been removed, and the following are all
possible:
A device can act as a central and a peripheral at the same time.
A central can be connected to multiple peripherals.
A peripheral can be connected to multiple centrals.
Previous versions of the specification limited the peripheral to a
single central connection (although not conversely) and limited the
role combinations.
You can find out the Bluetooth version of your device via hciconfig -a:-
hci0: Type: Primary Bus: USB
BD Address: 00:11:22:33:44:55 ACL MTU: 310:10 SCO MTU: 64:8
UP RUNNING
RX bytes:736 acl:0 sco:0 events:57 errors:0
TX bytes:5366 acl:0 sco:0 commands:57 errors:0
Features: 0xff 0xff 0xcf 0xfe 0xdb 0xff 0x5b 0x87
Packet type: DM1 DM3 DM5 DH1 DH3 DH5 HV1 HV2 HV3
Link policy: RSWITCH HOLD SNIFF PARK
Link mode: SLAVE ACCEPT
Name: 'uknown'
Class: 0x1c0000
Service Classes: Rendering, Capturing, Object Transfer
Device Class: Miscellaneous,
**HCI Version: 4.0 (0x6) Revision: 0x22bb**
LMP Version: 4.0 (0x6) Subversion: 0x22bb
Manufacturer: Cambridge Silicon Radio (10)
I would recommend using the bluetoothctl utility on Linux to advertise, instead of doing it through hcitool given that hcitool is deprecated and is also not very user friendly. More information on using bluetoothctl to advertise and accept incoming connections can be found here:-
BlueZ: How to set up a GATT server from the command line
I have inherited an ASP.NET MVC Application and an ASP.NET Web Api which both use SSL along with the api requiring client certificates. Both have been in production for over a year now with minor changes.
For development everything was originally set up with IIS Express and everything worked fine but now I have a requirement to move the local dev environment out of IIS Express and into Local IIS. My problem is all requests from the app to the api are failing with my setup.
I think I have my IIS (Windows 7 IIS 7.5) setup correct but it’s possible I could have something wrong. I have two different sites running on different ports for the api and app as well as what looks to be the appropriate settings for SSL and one to one mapping. Both sites have different app pools with two local users setup (I tried NetworkService originally). I added two domains to my host file (localapp.com and localapi.com) and I created two certificates for both domains with makecert. The api certificate is marked for server authentication and the app certificate is marked for server and client authentication (I have tried separate certificates for both purposes). The two SSL certificates have private keys that were marked as exportable when added to the certificate store and I have given private key permissions to the two local accounts. My self-signed root certificate is added to the LocalMachine root certificate store and the two site certificates (signed with the root certificate) are in the LocalMachine personal store. I can connect to both sites independently and don’t receive any warnings about certificate errors.
If I access an api URL through Chrome I can select the appropriate client certificate and see the JSON data expected. Accessing the app is similar in that I don’t get any certificate warnings but no data is being returned in any api calls it makes.
The app is using RestSharp for its HTTP requests and I have verified through debugging that the correct client certificate is being added to the request and a private key does exist. The code that is adding the certificate to the request should be fine since it has been running for over a year and nothing has changed. Every api request from the app returns
“System.ComponentModel.Win32Exception: The credentials supplied to the package were not recognized”
and
“The request was aborted: Could not create SSL/TLS secure channel.”
If I look into the network trace I get the following in regards to the localapp.com certificate…
System.Net Information: 0 : [6564] SecureChannel#37489757 - Left with 1 client certificates to choose from.
System.Net Information: 0 : [6564] SecureChannel#37489757 - Trying to find a matching certificate in the certificate store.
System.Net Information: 0 : [6564] SecureChannel#37489757 - Locating the private key for the certificate: [Version]
V3
[Subject]
CN=localapp.com
Simple Name: localapp.com
DNS Name: localapp.com
[Issuer]
CN=DevRoot
Simple Name: DevRoot
DNS Name: DevRoot
[Serial Number]
975C024DB7A08A9A48BE78F3382D4A93
[Not Before]
12/31/2015 11:00:00 PM
[Not After]
12/30/2039 11:00:00 PM
[Thumbprint]
28F3032F0E6ED488CFFE6706D3B17F851EFE1860
[Signature Algorithm]
sha512RSA(1.2.840.113549.1.1.13)
[Public Key]
Algorithm: RSA
Length: 4096
Key Blob: 30 82 02 0a 02 82 02 01 00 a9 c2 27 fc 60 11 1d 99 fe 1e e7 fb 05 b4 75 33 4a e3 d5 33 15 0c 9d 72 6a 3a df e2 58 49 20 34 39 59 77 7e 85 f7 fa 93 53 92 1d fa 63 32 98 b1 66 74 b6 60 23 e2 2b 97 f6 d9 ce bb 0a 1a ae 2f c8 a1 44 6f 60 12 9a bd b6 33 87 90 8d 1c 1f 61 7e f5 85 41 de 30 11 78 01 72 6b eb 77 8e 1b 9f 58 45 f6 ad 0d d3 2d ec 59 1d 63 2a 18 2f 77 87 6c a3 fe ee 68 2e 12 94 6a d5 ce 69 77 98 f2 14 bd bb ff eb 49 ac 1d a5 06 bf 97 51 0e 36 e6 8f 55 45 a3 91 29 77 94 93 1a 78 54 ....
System.Net Information: 0 : [6564] SecureChannel#37489757 - Certificate is of type X509Certificate2 and contains the private key.
System.Net Information: 0 : [6564] AcquireCredentialsHandle(package = Microsoft Unified Security Protocol Provider, intent = Outbound, scc = System.Net.SecureCredential)
System.Net Error: 0 : [6564] AcquireCredentialsHandle() failed with error 0X8009030D.
System.Net Information: 0 : [6564] AcquireCredentialsHandle(package = Microsoft Unified Security Protocol Provider, intent = Outbound, scc = System.Net.SecureCredential)
System.Net Error: 0 : [6564] AcquireCredentialsHandle() failed with error 0X8009030D.
System.Net.Sockets Verbose: 0 : [16268] Socket#3648821::Dispose()
System.Net Error: 0 : [16268] Exception in HttpWebRequest#16098066:: - The request was aborted: Could not create SSL/TLS secure channel..
System.Net Verbose: 0 : [16268] HttpWebRequest#16098066::EndGetResponse()
System.Net Error: 0 : [16268] Exception in HttpWebRequest#16098066::EndGetResponse - The request was aborted: Could not create SSL/TLS secure channel..
The trace log looks like I don’t have permissions set up correctly but I have explicitly given the local users permissions to the private keys for both the app and api certificates. Everyone else with the 0X8009030D error looks to have solved the issue by adding the app pool user to the private key permissions. If I go to Manage Private Keys in the MMC snap in for the localapp.com certificate I see my LocalApp and LocalApi users having read permissions.
I am completely out of ideas on things I can try to get the communication to work. It is probably something very simple but no matter what I try it just won’t work.
Anyone ever try this set up before and have success or anyone have ideas I can try to get this working?
Any help is greatly appreciated.
Thanks in advance!
-Aaron
I'm attempting to connect a bluez peripheral to an iOS device; it's not working.
Please find below logs on peripheral side. I'm advertising using hciconfig hci0 leadv but I don't see any "Connect" option on Scanner applications on phone. Also bluez-4.101 doesn't have hciconfig hci0 leadv0 option to make it connectable.
With the same device acting as a Central I am able to make LE connections with other BLE devices, so that confirms kernel LE support and device is fine, only some bluez issues I assume are there.
> HCI Event: LE Meta Event (0x3e) plen 19
LE Connection Complete
status 0x00 handle 1025, role slave
bdaddr 67:5D:F6:87:3D:2C (Random)
> ACL data: handle 1025 flags 0x02 dlen 7
ATT: MTU req (0x02)
client rx mtu 158
> ACL data: handle 1025 flags 0x02 dlen 27
> ACL data: handle 1025 flags 0x01 dlen 27
> ACL data: handle 1025 flags 0x01 dlen 9
L2CAP(d): cid 0x003a len 59 [psm 0]
0000: .9......com.appl
0010: e.BT.TS."....com
0020: .apple.BTLEServe
0030: r.classic..
> ACL data: handle 1025 flags 0x02 dlen 11
L2CAP(d): cid 0x003a len 7 [psm 0]
0000: ......
> HCI Event: Disconn Complete (0x05) plen 4
status 0x00 handle 1025 reason 0x13
Reason: Remote User Terminated Connection
How can I get this peripheral to connect?
Upgrading to the latest BlueZ version will solve the GATT related issues.
Quote from the linked page:
The 2.x , 3.x and 4.x series of libraries and packages are deprecated and not supported anymore by BlueZ developers. If you are using them please update to the 5.x series. The download link is only provided for reference.
I am running a JOGL based application, and it has been crashing when I perform certain drawing operations. However, The line it crashes on is a call to gl.glGenLists(1), so I'm not really sure how this could cause an error in the underlying application, since this line is a trivial line (unless the stack is in some sort of bad state - is that possible?).
I also tried updating my video card drivers and now it just freezes in the same place instead of crashing.
The relevant part of the crash report is below. Any help would be appreciated. I'm running an NVIDIA Quadro NVS 160M video card. Thanks.
#
# A fatal error has been detected by the Java Runtime Environment:
#
# EXCEPTION_ACCESS_VIOLATION (0xc0000005) at pc=0x6dd7ccac, pid=5520, tid=5684
#
# JRE version: 6.0_16-b01
# Java VM: Java HotSpot(TM) Client VM (14.2-b01 mixed mode windows-x86 )
# Problematic frame:
# C [nvoglnt.dll+0x23ccac]
#
# If you would like to submit a bug report, please visit:
# http://java.sun.com/webapps/bugreport/crash.jsp
# The crash happened outside the Java Virtual Machine in native code.
# See problematic frame for where to report the bug.
#
--------------- T H R E A D ---------------
Current thread (0x692c4c00): JavaThread "AWT-EventQueue-0" [_thread_in_native, id=5684, stack(0x696f0000,0x69740000)]
siginfo: ExceptionCode=0xc0000005, writing address 0x00040008
Registers:
EAX=0x6d360798, EBX=0x6e562ffc, ECX=0x00040000, EDX=0xffffffff
ESP=0x6973ee1c, EBP=0x0000000d, ESI=0x6d360650, EDI=0x6d362311
EIP=0x6dd7ccac, EFLAGS=0x00010246
Top of Stack: (sp=0x6973ee1c)
0x6973ee1c: 00001343 00000014 00001344 6e563040
0x6973ee2c: 00000000 6d362310 00000040 7ffad000
0x6973ee3c: 6dd7cdb8 6e562ffc 00001343 6e3c7540
0x6973ee4c: 6dc792a8 00000014 6dbdb13b 00000001
0x6973ee5c: 6e3c7540 6d620000 6973ee90 6dc06fb8
0x6973ee6c: 6d620000 6e3c7540 00000001 692c4c00
0x6973ee7c: 63e576a0 63d38030 6b6c4c0e 00000001
0x6973ee8c: 0ab4f368 6973eeb8 010669c7 692c4d10
Instructions: (pc=0x6dd7ccac)
0x6dd7cc9c: 00 8b 4b 08 8b 7b 04 89 79 04 8b 4b 04 8b 7b 08
0x6dd7ccac: 89 79 08 0f 84 8c 00 00 00 8b 4c 24 14 8b 7c d1
Stack: [0x696f0000,0x69740000], sp=0x6973ee1c, free space=315k
Native frames: (J=compiled Java code, j=interpreted, Vv=VM code, C=native code)
C [nvoglnt.dll+0x23ccac]
Java frames: (J=compiled Java code, j=interpreted, Vv=VM code)
J com.sun.opengl.impl.GLImpl.glGenLists0(I)I
...I omitted the rest of the stack, as this is the offending line ...
Despite the stack it seems to be nvoglnt.dll that is causing the trouble. Have you absolutely definitely installed the correct driver for your graphics device?