allblue 0.1.0__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- allblue-0.1.0/.gitignore +90 -0
- allblue-0.1.0/LICENSE +21 -0
- allblue-0.1.0/PKG-INFO +52 -0
- allblue-0.1.0/README.md +42 -0
- allblue-0.1.0/pyproject.toml +24 -0
- allblue-0.1.0/src/allblue/__init__.py +127 -0
- allblue-0.1.0/src/allblue/_cdefs.py +306 -0
- allblue-0.1.0/src/allblue/_loader.py +146 -0
- allblue-0.1.0/src/allblue/_native_hashes.py +12 -0
- allblue-0.1.0/src/allblue/_native_hashes.pyi +1 -0
- allblue-0.1.0/src/allblue/_release.py +327 -0
- allblue-0.1.0/src/allblue/channel.py +208 -0
- allblue-0.1.0/src/allblue/client.py +105 -0
- allblue-0.1.0/src/allblue/endpoints.py +117 -0
- allblue-0.1.0/src/allblue/errors.py +94 -0
- allblue-0.1.0/src/allblue/py.typed +0 -0
- allblue-0.1.0/src/allblue/types.py +75 -0
- allblue-0.1.0/src/allblue/watcher.py +122 -0
- allblue-0.1.0/tests/conftest.py +43 -0
- allblue-0.1.0/tests/test_channel.py +187 -0
- allblue-0.1.0/tests/test_discovery.py +55 -0
- allblue-0.1.0/tests/test_resolver.py +149 -0
- allblue-0.1.0/tests/test_wheel.py +37 -0
allblue-0.1.0/.gitignore
ADDED
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
# Local workspace data & isolated git worktrees
|
|
2
|
+
/.data/
|
|
3
|
+
/.worktrees/
|
|
4
|
+
|
|
5
|
+
# OS & Editor metadata
|
|
6
|
+
.DS_Store
|
|
7
|
+
Thumbs.db
|
|
8
|
+
*.swp
|
|
9
|
+
*.swo
|
|
10
|
+
*~
|
|
11
|
+
.idea/
|
|
12
|
+
.vscode/
|
|
13
|
+
*.iml
|
|
14
|
+
|
|
15
|
+
# Shared build & release staging
|
|
16
|
+
/dist/
|
|
17
|
+
/artifacts/
|
|
18
|
+
|
|
19
|
+
# Rust
|
|
20
|
+
/rust/Cargo.lock
|
|
21
|
+
**/target/
|
|
22
|
+
|
|
23
|
+
# C / C++
|
|
24
|
+
**/cmake-build-*/
|
|
25
|
+
*.o
|
|
26
|
+
*.obj
|
|
27
|
+
*.a
|
|
28
|
+
*.lib
|
|
29
|
+
*.so
|
|
30
|
+
*.so.*
|
|
31
|
+
*.dylib
|
|
32
|
+
*.dll
|
|
33
|
+
*.pdb
|
|
34
|
+
*.exp
|
|
35
|
+
*.xcframework/
|
|
36
|
+
|
|
37
|
+
# Dart / Flutter
|
|
38
|
+
**/.dart_tool/
|
|
39
|
+
**/.packages
|
|
40
|
+
**/build/
|
|
41
|
+
**/.flutter-plugins
|
|
42
|
+
**/.flutter-plugins-dependencies
|
|
43
|
+
|
|
44
|
+
# Go
|
|
45
|
+
**/vendor/
|
|
46
|
+
*.exe
|
|
47
|
+
*.test
|
|
48
|
+
*.out
|
|
49
|
+
|
|
50
|
+
# Python
|
|
51
|
+
**/__pycache__/
|
|
52
|
+
**/*.py[cod]
|
|
53
|
+
**/.venv/
|
|
54
|
+
**/venv/
|
|
55
|
+
**/*.egg-info/
|
|
56
|
+
**/.pytest_cache/
|
|
57
|
+
**/.mypy_cache/
|
|
58
|
+
**/.ruff_cache/
|
|
59
|
+
|
|
60
|
+
# TypeScript / JavaScript
|
|
61
|
+
**/node_modules/
|
|
62
|
+
**/.turbo/
|
|
63
|
+
*.tsbuildinfo
|
|
64
|
+
*.node
|
|
65
|
+
|
|
66
|
+
# JVM / Kotlin / Android
|
|
67
|
+
**/.gradle/
|
|
68
|
+
**/local.properties
|
|
69
|
+
*.apk
|
|
70
|
+
*.aab
|
|
71
|
+
*.aar
|
|
72
|
+
*.jar
|
|
73
|
+
!**/gradle/wrapper/gradle-wrapper.jar
|
|
74
|
+
|
|
75
|
+
# Zig
|
|
76
|
+
**/.zig-cache/
|
|
77
|
+
**/zig-cache/
|
|
78
|
+
**/zig-out/
|
|
79
|
+
|
|
80
|
+
# .NET / C#
|
|
81
|
+
**/[Bb]in/
|
|
82
|
+
**/[Oo]bj/
|
|
83
|
+
*.nupkg
|
|
84
|
+
*.snupkg
|
|
85
|
+
*.user
|
|
86
|
+
|
|
87
|
+
# Swift
|
|
88
|
+
**/.build/
|
|
89
|
+
**/.swiftpm/
|
|
90
|
+
**/DerivedData/
|
allblue-0.1.0/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 fewensa
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is furnished
|
|
10
|
+
to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice (including the next
|
|
13
|
+
paragraph) shall be included in all copies or substantial portions of the
|
|
14
|
+
Software.
|
|
15
|
+
|
|
16
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
17
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
|
|
18
|
+
FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS
|
|
19
|
+
OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
|
|
20
|
+
WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF
|
|
21
|
+
OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
allblue-0.1.0/PKG-INFO
ADDED
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
Metadata-Version: 2.5
|
|
2
|
+
Name: allblue
|
|
3
|
+
Version: 0.1.0
|
|
4
|
+
Summary: Cross-platform byte-stream SDK for ALLBlue
|
|
5
|
+
Project-URL: Repository, https://github.com/fewensa/allblue
|
|
6
|
+
License-Expression: MIT
|
|
7
|
+
Requires-Python: >=3.9
|
|
8
|
+
Requires-Dist: cffi>=1.16
|
|
9
|
+
Description-Content-Type: text/markdown
|
|
10
|
+
|
|
11
|
+
# ALLBlue
|
|
12
|
+
|
|
13
|
+
Open a BLE, Bluetooth Classic, USB, or serial endpoint as a byte stream.
|
|
14
|
+
Platform wheels include the native library. Python 3.9 or later and cffi
|
|
15
|
+
are required.
|
|
16
|
+
|
|
17
|
+
```python
|
|
18
|
+
import allblue
|
|
19
|
+
|
|
20
|
+
with allblue.open(allblue.SerialEndpoint("/dev/ttyUSB0")) as channel:
|
|
21
|
+
channel.write(b"ping")
|
|
22
|
+
reply = channel.read_exact(4, timeout=2.0)
|
|
23
|
+
```
|
|
24
|
+
|
|
25
|
+
Open an asynchronous channel with `await allblue.open_async(endpoint)`.
|
|
26
|
+
Data, state, and discovery watchers support either context manager and
|
|
27
|
+
iterator protocol. A data watcher receives its own copy of incoming packets,
|
|
28
|
+
independent of reads or clearing the channel's read buffer.
|
|
29
|
+
|
|
30
|
+
```python
|
|
31
|
+
async def receive(endpoint):
|
|
32
|
+
async with await allblue.open_async(endpoint) as channel:
|
|
33
|
+
async with channel.watch() as packets:
|
|
34
|
+
async for packet in packets:
|
|
35
|
+
return packet
|
|
36
|
+
```
|
|
37
|
+
|
|
38
|
+
Use a watcher as a context manager or call `close()` when finished.
|
|
39
|
+
Each watcher retains the most recent 256 unconsumed events. Contiguous
|
|
40
|
+
`bytes`, `bytearray`, and `memoryview` writes borrow the caller's
|
|
41
|
+
buffer until the operation completes.
|
|
42
|
+
|
|
43
|
+
## Native library selection
|
|
44
|
+
|
|
45
|
+
Set `ALLBLUE_LIB_DIR` to a directory containing a release library or a
|
|
46
|
+
Cargo-built FFI library. To build offline from a source checkout, set
|
|
47
|
+
`ALLBLUE_BUILD_FROM_SOURCE=1` with the Rust dependencies cached.
|
|
48
|
+
Otherwise, the SDK uses its bundled library or a verified release cache.
|
|
49
|
+
`ALLBLUE_CACHE_DIR` overrides the cache location and `ALLBLUE_OFFLINE=1`
|
|
50
|
+
requires a warm cache. Downloads require a package release pin and are
|
|
51
|
+
verified before extraction. A wheel can be built with
|
|
52
|
+
`ALLBLUE_LIB_DIR=/path/to/libraries uv build --wheel` from this directory.
|
allblue-0.1.0/README.md
ADDED
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
# ALLBlue
|
|
2
|
+
|
|
3
|
+
Open a BLE, Bluetooth Classic, USB, or serial endpoint as a byte stream.
|
|
4
|
+
Platform wheels include the native library. Python 3.9 or later and cffi
|
|
5
|
+
are required.
|
|
6
|
+
|
|
7
|
+
```python
|
|
8
|
+
import allblue
|
|
9
|
+
|
|
10
|
+
with allblue.open(allblue.SerialEndpoint("/dev/ttyUSB0")) as channel:
|
|
11
|
+
channel.write(b"ping")
|
|
12
|
+
reply = channel.read_exact(4, timeout=2.0)
|
|
13
|
+
```
|
|
14
|
+
|
|
15
|
+
Open an asynchronous channel with `await allblue.open_async(endpoint)`.
|
|
16
|
+
Data, state, and discovery watchers support either context manager and
|
|
17
|
+
iterator protocol. A data watcher receives its own copy of incoming packets,
|
|
18
|
+
independent of reads or clearing the channel's read buffer.
|
|
19
|
+
|
|
20
|
+
```python
|
|
21
|
+
async def receive(endpoint):
|
|
22
|
+
async with await allblue.open_async(endpoint) as channel:
|
|
23
|
+
async with channel.watch() as packets:
|
|
24
|
+
async for packet in packets:
|
|
25
|
+
return packet
|
|
26
|
+
```
|
|
27
|
+
|
|
28
|
+
Use a watcher as a context manager or call `close()` when finished.
|
|
29
|
+
Each watcher retains the most recent 256 unconsumed events. Contiguous
|
|
30
|
+
`bytes`, `bytearray`, and `memoryview` writes borrow the caller's
|
|
31
|
+
buffer until the operation completes.
|
|
32
|
+
|
|
33
|
+
## Native library selection
|
|
34
|
+
|
|
35
|
+
Set `ALLBLUE_LIB_DIR` to a directory containing a release library or a
|
|
36
|
+
Cargo-built FFI library. To build offline from a source checkout, set
|
|
37
|
+
`ALLBLUE_BUILD_FROM_SOURCE=1` with the Rust dependencies cached.
|
|
38
|
+
Otherwise, the SDK uses its bundled library or a verified release cache.
|
|
39
|
+
`ALLBLUE_CACHE_DIR` overrides the cache location and `ALLBLUE_OFFLINE=1`
|
|
40
|
+
requires a warm cache. Downloads require a package release pin and are
|
|
41
|
+
verified before extraction. A wheel can be built with
|
|
42
|
+
`ALLBLUE_LIB_DIR=/path/to/libraries uv build --wheel` from this directory.
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
[build-system]
|
|
2
|
+
requires = ["hatchling>=1.24"]
|
|
3
|
+
build-backend = "hatchling.build"
|
|
4
|
+
|
|
5
|
+
[project]
|
|
6
|
+
name = "allblue"
|
|
7
|
+
version = "0.1.0"
|
|
8
|
+
description = "Cross-platform byte-stream SDK for ALLBlue"
|
|
9
|
+
readme = "README.md"
|
|
10
|
+
license = "MIT"
|
|
11
|
+
requires-python = ">=3.9"
|
|
12
|
+
dependencies = ["cffi>=1.16"]
|
|
13
|
+
|
|
14
|
+
[project.urls]
|
|
15
|
+
Repository = "https://github.com/fewensa/allblue"
|
|
16
|
+
|
|
17
|
+
[tool.hatch.build.targets.wheel]
|
|
18
|
+
packages = ["src/allblue"]
|
|
19
|
+
|
|
20
|
+
[tool.hatch.build.hooks.custom]
|
|
21
|
+
path = "src/allblue/_loader.py"
|
|
22
|
+
|
|
23
|
+
[tool.mypy]
|
|
24
|
+
strict = true
|
|
@@ -0,0 +1,127 @@
|
|
|
1
|
+
from .channel import (
|
|
2
|
+
AsyncChannel,
|
|
3
|
+
AsyncChannel as AsyncALLBlueChannel,
|
|
4
|
+
Channel,
|
|
5
|
+
Channel as ALLBlueChannel,
|
|
6
|
+
)
|
|
7
|
+
from .client import (
|
|
8
|
+
ALLBlue,
|
|
9
|
+
devices,
|
|
10
|
+
discover,
|
|
11
|
+
open,
|
|
12
|
+
open_async,
|
|
13
|
+
)
|
|
14
|
+
from .endpoints import (
|
|
15
|
+
ALLBlueDevice,
|
|
16
|
+
BleDetail,
|
|
17
|
+
BleEndpoint,
|
|
18
|
+
ClassicDetail,
|
|
19
|
+
ClassicEndpoint,
|
|
20
|
+
DeviceDetail,
|
|
21
|
+
Endpoint,
|
|
22
|
+
SerialDetail,
|
|
23
|
+
SerialEndpoint,
|
|
24
|
+
UsbDetail,
|
|
25
|
+
UsbEndpoint,
|
|
26
|
+
)
|
|
27
|
+
from .errors import (
|
|
28
|
+
ALLBlueError,
|
|
29
|
+
StatusCode,
|
|
30
|
+
InvalidArgError,
|
|
31
|
+
ALLBlueInvalidArgError,
|
|
32
|
+
NotFoundError,
|
|
33
|
+
ALLBlueNotFoundError,
|
|
34
|
+
PermissionError,
|
|
35
|
+
ALLBluePermissionError,
|
|
36
|
+
TimeoutError,
|
|
37
|
+
ALLBlueTimeoutError,
|
|
38
|
+
DisconnectedError,
|
|
39
|
+
ALLBlueDisconnectedError,
|
|
40
|
+
PacketTooBigError,
|
|
41
|
+
ALLBluePacketTooBigError,
|
|
42
|
+
UnsupportedError,
|
|
43
|
+
ALLBlueUnsupportedError,
|
|
44
|
+
BusyError,
|
|
45
|
+
ALLBlueBusyError,
|
|
46
|
+
IoError,
|
|
47
|
+
ALLBlueIOError,
|
|
48
|
+
InternalError,
|
|
49
|
+
ALLBlueInternalError,
|
|
50
|
+
)
|
|
51
|
+
from .types import (
|
|
52
|
+
BleProfile,
|
|
53
|
+
Buffer,
|
|
54
|
+
ConnectionState,
|
|
55
|
+
CustomFlowConfig,
|
|
56
|
+
FlowDecision,
|
|
57
|
+
SerialFlowControl,
|
|
58
|
+
SerialParity,
|
|
59
|
+
Transport,
|
|
60
|
+
UsbBackend,
|
|
61
|
+
WriteMode,
|
|
62
|
+
WriteWithResponse,
|
|
63
|
+
)
|
|
64
|
+
from .watcher import (
|
|
65
|
+
DeviceWatcher,
|
|
66
|
+
StateWatcher,
|
|
67
|
+
Watcher,
|
|
68
|
+
)
|
|
69
|
+
|
|
70
|
+
__all__ = [
|
|
71
|
+
"ALLBlueChannel",
|
|
72
|
+
"AsyncALLBlueChannel",
|
|
73
|
+
"ALLBlue",
|
|
74
|
+
"ALLBlueBusyError",
|
|
75
|
+
"ALLBlueDevice",
|
|
76
|
+
"ALLBlueDisconnectedError",
|
|
77
|
+
"ALLBlueError",
|
|
78
|
+
"ALLBlueIOError",
|
|
79
|
+
"ALLBlueInternalError",
|
|
80
|
+
"ALLBlueInvalidArgError",
|
|
81
|
+
"ALLBlueNotFoundError",
|
|
82
|
+
"ALLBluePacketTooBigError",
|
|
83
|
+
"ALLBluePermissionError",
|
|
84
|
+
"ALLBlueTimeoutError",
|
|
85
|
+
"ALLBlueUnsupportedError",
|
|
86
|
+
"AsyncChannel",
|
|
87
|
+
"BleDetail",
|
|
88
|
+
"BleEndpoint",
|
|
89
|
+
"BleProfile",
|
|
90
|
+
"Buffer",
|
|
91
|
+
"BusyError",
|
|
92
|
+
"Channel",
|
|
93
|
+
"ClassicDetail",
|
|
94
|
+
"ClassicEndpoint",
|
|
95
|
+
"ConnectionState",
|
|
96
|
+
"CustomFlowConfig",
|
|
97
|
+
"DeviceDetail",
|
|
98
|
+
"DeviceWatcher",
|
|
99
|
+
"DisconnectedError",
|
|
100
|
+
"Endpoint",
|
|
101
|
+
"FlowDecision",
|
|
102
|
+
"InternalError",
|
|
103
|
+
"InvalidArgError",
|
|
104
|
+
"IoError",
|
|
105
|
+
"NotFoundError",
|
|
106
|
+
"PacketTooBigError",
|
|
107
|
+
"PermissionError",
|
|
108
|
+
"SerialDetail",
|
|
109
|
+
"SerialEndpoint",
|
|
110
|
+
"SerialFlowControl",
|
|
111
|
+
"SerialParity",
|
|
112
|
+
"StateWatcher",
|
|
113
|
+
"StatusCode",
|
|
114
|
+
"TimeoutError",
|
|
115
|
+
"Transport",
|
|
116
|
+
"UnsupportedError",
|
|
117
|
+
"UsbBackend",
|
|
118
|
+
"UsbDetail",
|
|
119
|
+
"UsbEndpoint",
|
|
120
|
+
"Watcher",
|
|
121
|
+
"WriteMode",
|
|
122
|
+
"WriteWithResponse",
|
|
123
|
+
"devices",
|
|
124
|
+
"discover",
|
|
125
|
+
"open",
|
|
126
|
+
"open_async",
|
|
127
|
+
]
|
|
@@ -0,0 +1,306 @@
|
|
|
1
|
+
"""ABI declarations from the public C header."""
|
|
2
|
+
from importlib import import_module
|
|
3
|
+
|
|
4
|
+
ffi = import_module("cffi").FFI()
|
|
5
|
+
ffi.cdef("""
|
|
6
|
+
typedef enum allblue_status_t {
|
|
7
|
+
ALLBLUE_OK = 0,
|
|
8
|
+
ALLBLUE_ERR_INVALID_ARG = -1,
|
|
9
|
+
ALLBLUE_ERR_NOT_FOUND = -2,
|
|
10
|
+
ALLBLUE_ERR_PERMISSION = -3,
|
|
11
|
+
ALLBLUE_ERR_TIMEOUT = -4,
|
|
12
|
+
ALLBLUE_ERR_DISCONNECTED = -5,
|
|
13
|
+
ALLBLUE_ERR_PACKET_TOO_BIG = -6,
|
|
14
|
+
ALLBLUE_ERR_UNSUPPORTED = -7,
|
|
15
|
+
ALLBLUE_ERR_BUSY = -8,
|
|
16
|
+
ALLBLUE_ERR_IO = -9,
|
|
17
|
+
ALLBLUE_ERR_INTERNAL = -10,
|
|
18
|
+
} allblue_status_t;
|
|
19
|
+
|
|
20
|
+
typedef enum allblue_transport_t {
|
|
21
|
+
ALLBLUE_TRANSPORT_ALL = 0,
|
|
22
|
+
ALLBLUE_TRANSPORT_BLE = 1,
|
|
23
|
+
ALLBLUE_TRANSPORT_CLASSIC = 2,
|
|
24
|
+
ALLBLUE_TRANSPORT_USB = 3,
|
|
25
|
+
ALLBLUE_TRANSPORT_SERIAL = 4,
|
|
26
|
+
} allblue_transport_t;
|
|
27
|
+
|
|
28
|
+
typedef enum allblue_conn_state_t {
|
|
29
|
+
ALLBLUE_STATE_CONNECTING = 0,
|
|
30
|
+
ALLBLUE_STATE_CONNECTED = 1,
|
|
31
|
+
ALLBLUE_STATE_DISCONNECTING = 2,
|
|
32
|
+
ALLBLUE_STATE_DISCONNECTED = 3,
|
|
33
|
+
} allblue_conn_state_t;
|
|
34
|
+
|
|
35
|
+
typedef enum allblue_write_mode_t {
|
|
36
|
+
ALLBLUE_WRITE_DEFAULT = 0,
|
|
37
|
+
ALLBLUE_WRITE_SINGLE_PACKET = 1,
|
|
38
|
+
ALLBLUE_WRITE_CHUNKED = 2,
|
|
39
|
+
ALLBLUE_WRITE_IVT_FF03 = 3,
|
|
40
|
+
ALLBLUE_WRITE_CUSTOM_FLOW = 1000,
|
|
41
|
+
} allblue_write_mode_t;
|
|
42
|
+
|
|
43
|
+
typedef enum allblue_ble_profile_t {
|
|
44
|
+
ALLBLUE_BLE_PROFILE_AUTO = 0,
|
|
45
|
+
ALLBLUE_BLE_PROFILE_IVT_FF00 = 1,
|
|
46
|
+
ALLBLUE_BLE_PROFILE_FSC_UART = 2,
|
|
47
|
+
ALLBLUE_BLE_PROFILE_CUSTOM = 1000,
|
|
48
|
+
} allblue_ble_profile_t;
|
|
49
|
+
|
|
50
|
+
typedef enum allblue_usb_backend_t {
|
|
51
|
+
ALLBLUE_USB_BACKEND_AUTO = 0,
|
|
52
|
+
ALLBLUE_USB_BACKEND_USBPRINT = 1,
|
|
53
|
+
ALLBLUE_USB_BACKEND_WINUSB = 2,
|
|
54
|
+
ALLBLUE_USB_BACKEND_LIBUSB = 3,
|
|
55
|
+
} allblue_usb_backend_t;
|
|
56
|
+
|
|
57
|
+
typedef allblue_conn_state_t allblue_state_t;
|
|
58
|
+
|
|
59
|
+
typedef struct allblue_channel allblue_channel;
|
|
60
|
+
|
|
61
|
+
typedef struct allblue_discover_watcher allblue_discover_watcher;
|
|
62
|
+
|
|
63
|
+
typedef struct allblue_discoverer allblue_discoverer;
|
|
64
|
+
|
|
65
|
+
typedef struct allblue_watcher allblue_watcher;
|
|
66
|
+
|
|
67
|
+
typedef struct allblue_channel allblue_channel_t;
|
|
68
|
+
|
|
69
|
+
typedef void (*allblue_flow_parse_fn)(const uint8_t*, size_t, int32_t*, int32_t*, void*);
|
|
70
|
+
|
|
71
|
+
typedef struct allblue_custom_flow_t {
|
|
72
|
+
uint32_t struct_size;
|
|
73
|
+
uint32_t initial_credits;
|
|
74
|
+
uint32_t initial_mtu;
|
|
75
|
+
allblue_flow_parse_fn parse_fn;
|
|
76
|
+
void *user_data;
|
|
77
|
+
} allblue_custom_flow_t;
|
|
78
|
+
|
|
79
|
+
typedef struct allblue_custom_sink {
|
|
80
|
+
uint32_t struct_size;
|
|
81
|
+
} allblue_custom_sink;
|
|
82
|
+
|
|
83
|
+
typedef struct allblue_custom_sink allblue_custom_sink_t;
|
|
84
|
+
|
|
85
|
+
typedef struct allblue_custom_driver_vtable_t {
|
|
86
|
+
uint32_t struct_size;
|
|
87
|
+
void *driver_ctx;
|
|
88
|
+
void (*on_bind_sink)(void*, allblue_custom_sink_t*);
|
|
89
|
+
size_t (*max_packet_size)(void*);
|
|
90
|
+
uint8_t (*is_write_ready)(void*);
|
|
91
|
+
allblue_status_t (*write_packet)(void*, const uint8_t*, size_t, size_t*);
|
|
92
|
+
allblue_status_t (*close)(void*);
|
|
93
|
+
void (*destroy)(void*);
|
|
94
|
+
} allblue_custom_driver_vtable_t;
|
|
95
|
+
|
|
96
|
+
typedef struct allblue_device_t {
|
|
97
|
+
uint32_t struct_size;
|
|
98
|
+
const char *id;
|
|
99
|
+
const char *name;
|
|
100
|
+
int32_t transport;
|
|
101
|
+
int16_t rssi;
|
|
102
|
+
uint8_t connectable;
|
|
103
|
+
uint8_t paired;
|
|
104
|
+
uint16_t vid;
|
|
105
|
+
uint16_t pid;
|
|
106
|
+
int32_t interface_number;
|
|
107
|
+
const char *serial_number;
|
|
108
|
+
const char *path;
|
|
109
|
+
const uint8_t *manufacturer_data;
|
|
110
|
+
size_t manufacturer_data_len;
|
|
111
|
+
uint16_t manufacturer_company_id;
|
|
112
|
+
const char *const *service_uuids;
|
|
113
|
+
size_t service_uuids_len;
|
|
114
|
+
} allblue_device_t;
|
|
115
|
+
|
|
116
|
+
typedef uint8_t (*allblue_device_filter_fn)(const struct allblue_device_t*, void*);
|
|
117
|
+
|
|
118
|
+
typedef void (*allblue_discover_fn)(const struct allblue_device_t*, void*);
|
|
119
|
+
|
|
120
|
+
typedef struct allblue_discoverer allblue_discoverer_t;
|
|
121
|
+
|
|
122
|
+
typedef void (*allblue_doorbell_fn)(void*);
|
|
123
|
+
|
|
124
|
+
typedef struct allblue_discover_watcher allblue_discover_watcher_t;
|
|
125
|
+
|
|
126
|
+
typedef struct allblue_ble_open_opts_t {
|
|
127
|
+
uint32_t struct_size;
|
|
128
|
+
const char *device_id;
|
|
129
|
+
int32_t profile;
|
|
130
|
+
const char *service_uuid;
|
|
131
|
+
const char *write_uuid;
|
|
132
|
+
const char *notify_uuid;
|
|
133
|
+
const char *flow_uuid;
|
|
134
|
+
int32_t write_with_response;
|
|
135
|
+
int32_t write_mode;
|
|
136
|
+
size_t override_chunk_size;
|
|
137
|
+
const struct allblue_custom_flow_t *custom_flow;
|
|
138
|
+
uint32_t connect_timeout_ms;
|
|
139
|
+
size_t ring_capacity;
|
|
140
|
+
} allblue_ble_open_opts_t;
|
|
141
|
+
|
|
142
|
+
typedef struct allblue_classic_open_opts_t {
|
|
143
|
+
uint32_t struct_size;
|
|
144
|
+
const char *device_id;
|
|
145
|
+
const char *spp_uuid;
|
|
146
|
+
const char *mfi_protocol;
|
|
147
|
+
uint8_t secure;
|
|
148
|
+
uint32_t connect_timeout_ms;
|
|
149
|
+
size_t ring_capacity;
|
|
150
|
+
} allblue_classic_open_opts_t;
|
|
151
|
+
|
|
152
|
+
typedef struct allblue_usb_open_opts_t {
|
|
153
|
+
uint32_t struct_size;
|
|
154
|
+
uint16_t vid;
|
|
155
|
+
uint16_t pid;
|
|
156
|
+
const char *serial_number;
|
|
157
|
+
int32_t interface_number;
|
|
158
|
+
int32_t in_endpoint;
|
|
159
|
+
int32_t out_endpoint;
|
|
160
|
+
int32_t backend;
|
|
161
|
+
int32_t android_fd;
|
|
162
|
+
uint32_t open_timeout_ms;
|
|
163
|
+
size_t ring_capacity;
|
|
164
|
+
} allblue_usb_open_opts_t;
|
|
165
|
+
|
|
166
|
+
typedef struct allblue_serial_open_opts_t {
|
|
167
|
+
uint32_t struct_size;
|
|
168
|
+
const char *path;
|
|
169
|
+
uint32_t baud_rate;
|
|
170
|
+
uint8_t data_bits;
|
|
171
|
+
uint8_t parity;
|
|
172
|
+
uint8_t stop_bits;
|
|
173
|
+
uint8_t flow_control;
|
|
174
|
+
int32_t android_fd;
|
|
175
|
+
uint16_t vid;
|
|
176
|
+
uint16_t pid;
|
|
177
|
+
size_t ring_capacity;
|
|
178
|
+
} allblue_serial_open_opts_t;
|
|
179
|
+
|
|
180
|
+
typedef void (*allblue_watch_data_fn)(const uint8_t*, size_t, void*);
|
|
181
|
+
|
|
182
|
+
typedef void (*allblue_watch_state_fn)(int32_t, void*);
|
|
183
|
+
|
|
184
|
+
typedef struct allblue_watcher allblue_watcher_t;
|
|
185
|
+
|
|
186
|
+
uint32_t allblue_abi_version(void);
|
|
187
|
+
|
|
188
|
+
const char *allblue_version_string(void);
|
|
189
|
+
|
|
190
|
+
const char *allblue_last_error_message(void);
|
|
191
|
+
|
|
192
|
+
allblue_status_t allblue_channel_set_custom_flow(allblue_channel_t *ch,
|
|
193
|
+
const struct allblue_custom_flow_t *flow);
|
|
194
|
+
|
|
195
|
+
allblue_status_t allblue_channel_write(allblue_channel_t *ch,
|
|
196
|
+
const uint8_t *data,
|
|
197
|
+
size_t len,
|
|
198
|
+
int32_t write_mode);
|
|
199
|
+
|
|
200
|
+
allblue_status_t allblue_channel_read(allblue_channel_t *ch,
|
|
201
|
+
uint8_t *buf,
|
|
202
|
+
size_t cap,
|
|
203
|
+
uint32_t timeout_ms,
|
|
204
|
+
size_t *out_read);
|
|
205
|
+
|
|
206
|
+
allblue_status_t allblue_channel_read_exact(allblue_channel_t *ch,
|
|
207
|
+
uint8_t *buf,
|
|
208
|
+
size_t len,
|
|
209
|
+
uint32_t timeout_ms);
|
|
210
|
+
|
|
211
|
+
allblue_status_t allblue_channel_try_read(allblue_channel_t *ch,
|
|
212
|
+
uint8_t *buf,
|
|
213
|
+
size_t cap,
|
|
214
|
+
size_t *out_read);
|
|
215
|
+
|
|
216
|
+
allblue_status_t allblue_channel_clear_read_buffer(allblue_channel_t *ch);
|
|
217
|
+
|
|
218
|
+
int32_t allblue_channel_state(const allblue_channel_t *ch);
|
|
219
|
+
|
|
220
|
+
size_t allblue_channel_max_packet_size(const allblue_channel_t *ch);
|
|
221
|
+
|
|
222
|
+
allblue_status_t allblue_channel_close(allblue_channel_t *ch);
|
|
223
|
+
|
|
224
|
+
void allblue_channel_free(allblue_channel_t *ch);
|
|
225
|
+
|
|
226
|
+
allblue_status_t allblue_open_custom(const struct allblue_custom_driver_vtable_t *vtable,
|
|
227
|
+
size_t ring_capacity,
|
|
228
|
+
int32_t write_mode,
|
|
229
|
+
allblue_channel_t **out_ch);
|
|
230
|
+
|
|
231
|
+
void allblue_custom_sink_push_data(const allblue_custom_sink_t *p, const uint8_t *data, size_t len);
|
|
232
|
+
|
|
233
|
+
void allblue_custom_sink_push_flow_control(const allblue_custom_sink_t *p,
|
|
234
|
+
const uint8_t *data,
|
|
235
|
+
size_t len);
|
|
236
|
+
|
|
237
|
+
void allblue_custom_sink_notify_write_ready(const allblue_custom_sink_t *p);
|
|
238
|
+
|
|
239
|
+
void allblue_custom_sink_notify_state(const allblue_custom_sink_t *p, int32_t state);
|
|
240
|
+
|
|
241
|
+
void allblue_custom_sink_free(allblue_custom_sink_t *p);
|
|
242
|
+
|
|
243
|
+
void allblue_devices_free(struct allblue_device_t *p, size_t count);
|
|
244
|
+
|
|
245
|
+
allblue_status_t allblue_devices(int32_t transport,
|
|
246
|
+
allblue_device_filter_fn filter,
|
|
247
|
+
void *user_data,
|
|
248
|
+
struct allblue_device_t **out_devices,
|
|
249
|
+
size_t *out_count);
|
|
250
|
+
|
|
251
|
+
allblue_status_t allblue_discover(int32_t transport,
|
|
252
|
+
allblue_device_filter_fn filter,
|
|
253
|
+
allblue_discover_fn on_device,
|
|
254
|
+
void *user_data,
|
|
255
|
+
allblue_discoverer_t **out_discoverer);
|
|
256
|
+
|
|
257
|
+
void allblue_discover_stop(allblue_discoverer_t *p);
|
|
258
|
+
|
|
259
|
+
allblue_status_t allblue_discover_watcher_open(int32_t transport,
|
|
260
|
+
size_t queue_capacity,
|
|
261
|
+
allblue_doorbell_fn on_readable,
|
|
262
|
+
void *user_data,
|
|
263
|
+
allblue_discover_watcher_t **out_watcher);
|
|
264
|
+
|
|
265
|
+
allblue_status_t allblue_discover_watcher_try_next(allblue_discover_watcher_t *watcher,
|
|
266
|
+
struct allblue_device_t **out_device);
|
|
267
|
+
|
|
268
|
+
void allblue_discover_watcher_close(allblue_discover_watcher_t *p);
|
|
269
|
+
|
|
270
|
+
allblue_status_t allblue_open_ble(const struct allblue_ble_open_opts_t *opts,
|
|
271
|
+
allblue_channel_t **out_ch);
|
|
272
|
+
|
|
273
|
+
allblue_status_t allblue_open_classic(const struct allblue_classic_open_opts_t *opts,
|
|
274
|
+
allblue_channel_t **out_ch);
|
|
275
|
+
|
|
276
|
+
allblue_status_t allblue_open_usb(const struct allblue_usb_open_opts_t *opts,
|
|
277
|
+
allblue_channel_t **out_ch);
|
|
278
|
+
|
|
279
|
+
allblue_status_t allblue_open_serial(const struct allblue_serial_open_opts_t *opts,
|
|
280
|
+
allblue_channel_t **out_ch);
|
|
281
|
+
|
|
282
|
+
allblue_status_t allblue_channel_watch(allblue_channel_t *ch,
|
|
283
|
+
allblue_watch_data_fn cb,
|
|
284
|
+
void *user_data,
|
|
285
|
+
uint64_t *out_watch_id);
|
|
286
|
+
|
|
287
|
+
allblue_status_t allblue_channel_watch_state(allblue_channel_t *ch,
|
|
288
|
+
allblue_watch_state_fn cb,
|
|
289
|
+
void *user_data,
|
|
290
|
+
uint64_t *out_watch_id);
|
|
291
|
+
|
|
292
|
+
allblue_status_t allblue_channel_unwatch(allblue_channel_t *ch, uint64_t watch_id);
|
|
293
|
+
|
|
294
|
+
allblue_status_t allblue_watcher_open(allblue_channel_t *ch,
|
|
295
|
+
size_t queue_capacity,
|
|
296
|
+
allblue_doorbell_fn on_readable,
|
|
297
|
+
void *user_data,
|
|
298
|
+
allblue_watcher_t **out_watcher);
|
|
299
|
+
|
|
300
|
+
allblue_status_t allblue_watcher_try_read(allblue_watcher_t *watcher,
|
|
301
|
+
uint8_t *buf,
|
|
302
|
+
size_t cap,
|
|
303
|
+
size_t *out_read);
|
|
304
|
+
|
|
305
|
+
void allblue_watcher_close(allblue_watcher_t *p);
|
|
306
|
+
""")
|