pureswift / bluetoothlinux Goto Github PK
View Code? Open in Web Editor NEWPure Swift Linux Bluetooth Stack
License: MIT License
Pure Swift Linux Bluetooth Stack
License: MIT License
Hi,
I see rfcomm is defined in BluetoothProtocols but not aware if RFCOMM sockets can be established currently.
Seems the project is more focused on BLE implementation and would like to know if you consider implementing a RFCOMMSocket or similar class.
In case you foresee implementing it or accept contributions, could you describe briefly what steps should be followed for the implementation? Also thinking about BluetoothDarwin library and using IOBluetoothRFCOMMChannel there, but sharing similar architecture.
I've used IOBluetooth framework before, but still a newbie when it comes to Bluez. I'm interested in opening a serial port with bluetooth classic accessories.
Any light you can through on this matter would be really appreciated.
GATTServerTest
crashed when adding 16 bit service UUID.
colemancda@orangepipc:~/developer/BluetoothLinux$ sudo .build/debug/GATTServerTest
Found Bluetooth adapter with device ID: 0
Address: 00:1A:7D:DA:71:13
GATT Database:
1 - primaryService
Permissions: BitMaskOptionSet<ATTAttributePermission>(rawValue: 1)
Value: 60F14FE2-F972-11E5-B84F-23E070D5A8C7
2 - characteristic
Permissions: BitMaskOptionSet<ATTAttributePermission>(rawValue: 1)
Value: 19 bytes
3 - E77D264C-F96F-11E5-80E0-23E070D5A8C7
Permissions: BitMaskOptionSet<ATTAttributePermission>(rawValue: 1)
Value: Test Read-Only
4 - characteristic
Permissions: BitMaskOptionSet<ATTAttributePermission>(rawValue: 1)
Value: 19 bytes
5 - 0615FF6C-0E37-11E6-9E58-75D7DC50F6B1
Permissions: BitMaskOptionSet<ATTAttributePermission>(rawValue: 1)
Value: 512 bytes
6 - characteristic
Permissions: BitMaskOptionSet<ATTAttributePermission>(rawValue: 1)
Value: 19 bytes
7 - 37BBD7D0-F96F-11E5-8EC1-23E070D5A8C7
Permissions: BitMaskOptionSet<ATTAttributePermission>(rawValue: 2)
Value:
8 - characteristic
Permissions: BitMaskOptionSet<ATTAttributePermission>(rawValue: 1)
Value: 19 bytes
9 - 2FDDB448-F96F-11E5-A891-23E070D5A8C7
Permissions: BitMaskOptionSet<ATTAttributePermission>(rawValue: 2)
Value:
10 - primaryService
Permissions: BitMaskOptionSet<ATTAttributePermission>(rawValue: 1)
Value: FEA9
11 - characteristic
Permissions: BitMaskOptionSet<ATTAttributePermission>(rawValue: 1)
Value: 19 bytes
12 - E77D264C-F96F-11E5-80E0-23E070D5A8C7
Permissions: BitMaskOptionSet<ATTAttributePermission>(rawValue: 1)
Value: Test Read-Only
13 - characteristic
Permissions: BitMaskOptionSet<ATTAttributePermission>(rawValue: 1)
Value: 19 bytes
14 - 0615FF6C-0E37-11E6-9E58-75D7DC50F6B1
Permissions: BitMaskOptionSet<ATTAttributePermission>(rawValue: 1)
Value: 512 bytes
15 - characteristic
Permissions: BitMaskOptionSet<ATTAttributePermission>(rawValue: 1)
Value: 19 bytes
16 - 37BBD7D0-F96F-11E5-8EC1-23E070D5A8C7
Permissions: BitMaskOptionSet<ATTAttributePermission>(rawValue: 2)
Value:
17 - characteristic
Permissions: BitMaskOptionSet<ATTAttributePermission>(rawValue: 1)
Value: 19 bytes
18 - 2FDDB448-F96F-11E5-A891-23E070D5A8C7
Permissions: BitMaskOptionSet<ATTAttributePermission>(rawValue: 2)
Value:
Created L2CAP server
New bredr connection from AC:BC:32:A6:67:42
[AC:BC:32:A6:67:42]: MTU Exchange (104 -> 23)
[AC:BC:32:A6:67:42]: Read by Type (2A00) (1 - 65535)
[AC:BC:32:A6:67:42]: Error attributeNotFound - readByTypeRequest (1)
[AC:BC:32:A6:67:42]: Read by Group Type (1 - 65535)
Data: AttributeData(attributeHandle: 10, endGroupHandle: 18, value: [169, 254])
Limited attributes: [Bluetooth.ATTReadByGroupTypeResponse.AttributeData(attributeHandle: 1, endGroupHandle: 9, value: [199, 168, 213, 112, 224, 35, 79, 184, 229, 17, 114, 249, 226, 79, 241, 96]), Bluetooth.ATTReadByGroupTypeResponse.AttributeData(attributeHandle: 10, endGroupHandle: 18, value: [169, 254])]
[AC:BC:32:A6:67:42]: Error unlikelyError - readByGroupTypeRequest (1)
fatal error: Could not create ATTReadByGroupTypeResponse. Attribute Data: [Bluetooth.ATTReadByGroupTypeResponse.AttributeData(attributeHandle: 1, endGroupHandle: 9, value: [199, 168, 213, 112, 224, 35, 79, 184, 229, 17, 114, 249, 226, 79, 241, 96]), Bluetooth.ATTReadByGroupTypeResponse.AttributeData(attributeHandle: 10, endGroupHandle: 18, value: [169, 254])]: file /home/colemancda/developer/BluetoothLinux/Sources/BluetoothLinux/GATTServer.swift, line 342
Consolidate the separate test tools into a single hcitest
tool instead of multiple executable. Choose a appropriate command line argument parser framework.
Hello, we upgraded Swift to version 5.5.1 on our Raspberry PI 4 but now the HostController.default
is returning nil. I tried this on 2 different devices but the result is same. Do you please have any clue what might have gone wrong?
Looking at the instances where we use BlueZ, the few functions we use from them can be reverse engineered. The packed structures can also be duplicated. In essence, this would be yet another Linux Bluetooth stack (like Bluedroid) that would not link against the user land BlueZ libraries.
A major motivation for this feature is the GPL BlueZ requirement, which will not allow for this framework to be used in proprietary applications. I would like to keep this library MIT, but I can't legally can't as long as BlueZ is a dependency.
Hi,
I'm using swift 5.0 on Rpi Zero
from an empty project there is an issue on swift build
Updating https://github.com/PureSwift/BluetoothLinux.git error: the package bluetoothlinux[https://github.com/PureSwift/BluetoothLinux.git] @ 4.0.0 contains incompatible dependencies: bluetooth[https://github.com/PureSwift/Bluetooth.git] @ master
Is there a way to get it run on swift 5.0?
Thanks for your work!
In the Package.swift ,of the tagged version 5.0.5, is declared this dependency.
.package(
url: "https://github.com/PureSwift/Socket.git",
.branch("main")
)
Since the dependency is pointing to a branch SPM can not resolve it:
Computing version for https://github.com/PureSwift/BluetoothLinux
error: Dependencies could not be resolved because root depends on 'bluetoothlinux' 5.0.5..<5.1.0.
'bluetoothlinux' >= 5.0.5 cannot be used because no versions of 'bluetoothlinux' match the requirement 5.0.6..<5.1.0 and package 'bluetoothlinux' is required using a stable-version but 'bluetoothlinux' depends on an unstable-version package 'socket'.
The package file of a tagged version should point to a dependency with a tagged version.
Write unit tests (separate from the test tools), based on XCTest, and using two Bluetooth adapters.
This is gonna be fun!
Must implement ATT, GATT Server and GATT Client. Also write a basic test tool, and possibly unit tests.
I was able to create such device using modified code from GATTServerTest
. I can connect to the device but I can't see any services and characteristics in LightBlue Explorer
. waitForConnection()
keep everything blocked after connecting. Could you give an example for this?
Related to #24
fatal error: Could not add PDU to queue: ATTHandleValueNotification(handle: 3, value: [1, 27, 123, 10, 32, 32, 34, 83, 116, 97, 116, 101, 77, 97, 99, 104, 105, 110, 101, 34, 58, 32, 123, 10, 32, 32, 32, 32, 34, 115, 121, 115, 116, 101, 109, 115, 34, 58, 32, 91, 10, 32, 32, 32, 32, 32, 32, 123, 10, 32, 32, 32, 32, 32, 32, 32, 32, 34, 115, 116, 97, 116, 101, 77, 111, 100, 101, 34, 58, 32, 34, 98, 105, 103, 103, 101, 115, 116, 68, 105, 102, 102, 34, 44, 10, 32, 32, 32, 32, 32, 32, 32, 32, 34, 115, 121, 115, 116, 101, 109, 84, 121, 112, 101, 34, 58, 32, 34, 104, 101, 97, 116, 80, 117, 109, 112, 34, 44, 10, 32, 32, 32, 32, 32, 32, 32, 32, 34, 102, 97, 110, 83, 116, 97, 103, 101, 115, 34, 58, 32, 91, 10, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 123, 10, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 34, 114, 101, 108, 97, 121, 34, 58, 32, 123, 10, 32, 32, 32, 32, 32]): file /home/pi/developer/PROJECT_NAME/Sources/BluetoothLinux/GATTServer.swift, line 135
Current stack trace:
Illegal instruction
Implement ATTHandleValueNotification
for GATT Server and Client.
when attempting to scan I get a Invalid HCI Command Parameters error. However if I run bluetoothctl scan on the scanner starts working. It appears that there is some command being sent by bluetoothctl to turn on the scanner that the software is not performing.
When I use bemoan to watch what is happening when scanning with the command parameters error I see the following looping over as the app keeps trying and failing to scan.
`> HCI Event: Command Complete (0x0e) plen 4 [hci0] 2.144296
LE Set Scan Enable (0x08|0x000c) ncmd 1
Status: Invalid HCI Command Parameters (0x12)
< HCI Command: Disconnect (0x01|0x0006) plen 3 [hci0] 2.145767
Handle: 0
Reason: Connection Terminated By Local Host (0x16)
HCI Event: Command Status (0x0f) plen 4 [hci0] 2.146661
Disconnect (0x01|0x0006) ncmd 1
Status: Command Disallowed (0x0c)
`
When I watch the scanner start after using bluetoothctl scan on command I get the following.
`HCI Command: Disconnect (0x01|0x0006) plen 3 [hci0] 50.286713
Handle: 0
Reason: Connection Terminated By Local Host (0x16)
HCI Event: Command Status (0x0f) plen 4 [hci0] 50.287760
Disconnect (0x01|0x0006) ncmd 1
Status: Command Disallowed (0x0c)
@ MGMT Command: Start Discovery (0x0023) plen 1 {0x0001} [hci0] 50.577471
Address type: 0x07
BR/EDR
LE Public
LE Random
< HCI Command: LE Set Random Address (0x08|0x0005) plen 6 [hci0] 50.577599
Address: 01:54:A4:10:93:EA (Non-Resolvable)
HCI Event: Command Complete (0x0e) plen 4 [hci0] 50.582053
LE Set Random Address (0x08|0x0005) ncmd 1
Status: Success (0x00)
< HCI Command: LE Set Scan Parameters (0x08|0x000b) plen 7 [hci0] 50.582150
Type: Active (0x01)
Interval: 11.250 msec (0x0012)
Window: 11.250 msec (0x0012)
Own address type: Random (0x01)
Filter policy: Accept all advertisement (0x00)
HCI Event: Command Complete (0x0e) plen 4 [hci0] 50.584337
LE Set Scan Parameters (0x08|0x000b) ncmd 1
Status: Success (0x00)
< HCI Command: LE Set Scan Enable (0x08|0x000c) plen 2 [hci0] 50.584425
Scanning: Enabled (0x01)
Filter duplicates: Enabled (0x01)
HCI Event: Command Complete (0x0e) plen 4 [hci0] 50.588154
LE Set Scan Enable (0x08|0x000c) ncmd 1
Status: Success (0x00)
@ MGMT Event: Command Complete (0x0001) plen 4 {0x0001} [hci0] 50.588270
Start Discovery (0x0023) plen 1
Status: Success (0x00)
Address type: 0x07
BR/EDR
LE Public
LE Random
@ MGMT Event: Discovering (0x0013) plen 2 {0x0002} [hci0] 50.588295
Address type: 0x07
BR/EDR
LE Public
LE Random
Discovery: Enabled (0x01)
`
Hi, I try example and see this error:
/home/pi/Xport/DomoPhone/Sources/DomoPhone/main.swift:16:16: error: incorrect argument label in call (have 'rawValue:', expected 'uuidString:')
let uuid = UUID(rawValue: "E2C56DB5-DFFB-48D2-B060-D0F5A71096E0")!
^~~~~~~~~
uuidString
Please help
Implement LE Scan.
First step is to implement the "LE Set Scan Enable Command" PDU.
Reference the Bluetooth Core Specification v4.0 page 823 (7.8.11 LE Set Scan Enable Command)
Getting New BREDR connection
in L2CAPServerTest
and GATTServerTest
.
Should be LowEnergyPublic
. Could be related to endianness on ARM.
Integrate Travis CI to continuously build and run unit tests.
Implement reading the LE white list
Adding LE Secure Connections to Your Products
You need to upgrade the security manager in your Bluetooth stack to support the following:
Generation and management of ECDH keys
LE Secure Connection pairing requests
Generation of ECDH keys and Long Term Keys (LTK)
Generation and exchange of cross transport keys
Does BluetoothLinux stack implements ECDH ?
Hi
Wanted to try out your library but I'm stuck with a compile error:
/home/antongregersen/Swift/Projects/helloswift/Packages/CBlueZ-1.0.1/module.modulemap:3:12: error: header '/usr/include/bluetooth/a2mp.h' not found
header "/usr/include/bluetooth/a2mp.h"
I've installed the libbluetooth-dev package, where according to http://packages.ubuntu.com/trusty/libbluetooth-dev the
à2mp.h
file should be included, but it's not in the usr/include/bluetooth/
folder.
Have you experienced any issues with this?
I'm running Ubuntu 15.10 on VMWare.
Implement Read Local Name and Write Local Name (In PureSwift/Bluetooth#5) HCI commands and add extensions to Adapter
.
Implement a mechanism based on DispatchQueue
or CFRunloop
(or both) to wakeup and execute the IO for pending input / output instead of a simple while
loop.
Subtask of #5
Implement GATT Client connections.
The iBeacon functionality was working before the v2.0.0 release. The functionality is in place to send HCI commands to the kernel. What is lacking is to implement the HCICommandParameter
structures for the Bluetooth Low Energy commands.
ATTError
in ATT.swift
must include the complete list of error codes belonging to the ATT protocol.
Subtask of #5
Implement init(rawValue: String)
for Address
. I believe a regex would suffice.
Here is one I developed.
([0-9A-F]{2}):([0-9A-F]{2}):([0-9A-F]{2}):([0-9A-F]{2}):([0-9A-F]{2}):([0-9A-F]{2})
Integrate Jazzy to generate documentation.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.