cobra-bridge 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.
- cobra_bridge-0.1.0/.gitignore +8 -0
- cobra_bridge-0.1.0/PKG-INFO +145 -0
- cobra_bridge-0.1.0/README.md +122 -0
- cobra_bridge-0.1.0/pyproject.toml +36 -0
- cobra_bridge-0.1.0/src/cobra_bridge/__init__.py +28 -0
- cobra_bridge-0.1.0/src/cobra_bridge/async_.py +425 -0
- cobra_bridge-0.1.0/src/cobra_bridge/constants.py +134 -0
- cobra_bridge-0.1.0/src/cobra_bridge/drivers/__init__.py +1 -0
- cobra_bridge-0.1.0/src/cobra_bridge/drivers/bmm350.py +483 -0
- cobra_bridge-0.1.0/src/cobra_bridge/drivers/bmm350_async.py +389 -0
- cobra_bridge-0.1.0/src/cobra_bridge/reader.py +235 -0
- cobra_bridge-0.1.0/src/cobra_bridge/sync.py +253 -0
- cobra_bridge-0.1.0/src/cobra_bridge/transport.py +453 -0
- cobra_bridge-0.1.0/tests/test_async.py +208 -0
- cobra_bridge-0.1.0/tests/test_sync.py +122 -0
|
@@ -0,0 +1,145 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: cobra-bridge
|
|
3
|
+
Version: 0.1.0
|
|
4
|
+
Summary: COines BRidge Access — Bosch AppBoard protocol for Python
|
|
5
|
+
Project-URL: Homepage, https://github.com/drpoom/cobra
|
|
6
|
+
Project-URL: Repository, https://github.com/drpoom/cobra
|
|
7
|
+
Author-email: John Poom <drpoom@users.noreply.github.com>
|
|
8
|
+
License-Expression: MIT
|
|
9
|
+
Keywords: appboard,ble,bmm350,bosch,coines,i2c,magnetometer,sensortec,serial,spi
|
|
10
|
+
Classifier: Development Status :: 3 - Alpha
|
|
11
|
+
Classifier: Intended Audience :: Developers
|
|
12
|
+
Classifier: License :: OSI Approved :: MIT License
|
|
13
|
+
Classifier: Programming Language :: Python :: 3
|
|
14
|
+
Classifier: Topic :: System :: Hardware :: Hardware Drivers
|
|
15
|
+
Requires-Python: >=3.9
|
|
16
|
+
Requires-Dist: pyserial>=3.5
|
|
17
|
+
Provides-Extra: ble
|
|
18
|
+
Requires-Dist: bleak>=0.21; extra == 'ble'
|
|
19
|
+
Provides-Extra: dev
|
|
20
|
+
Requires-Dist: hatch; extra == 'dev'
|
|
21
|
+
Requires-Dist: pytest; extra == 'dev'
|
|
22
|
+
Description-Content-Type: text/markdown
|
|
23
|
+
|
|
24
|
+
# cobra-bridge
|
|
25
|
+
|
|
26
|
+
**COines BRidge Access** — Bosch AppBoard protocol for Python
|
|
27
|
+
|
|
28
|
+
Transport-agnostic library for the Bosch Sensortec Application Board 3.1+.
|
|
29
|
+
Supports USB-Serial (pyserial) and BLE (Bleak) backends with identical protocol logic.
|
|
30
|
+
|
|
31
|
+
## Install
|
|
32
|
+
|
|
33
|
+
```bash
|
|
34
|
+
pip install cobra-bridge
|
|
35
|
+
```
|
|
36
|
+
|
|
37
|
+
For BLE support:
|
|
38
|
+
|
|
39
|
+
```bash
|
|
40
|
+
pip install cobra-bridge[ble]
|
|
41
|
+
```
|
|
42
|
+
|
|
43
|
+
## Quick Start
|
|
44
|
+
|
|
45
|
+
```python
|
|
46
|
+
from cobra_bridge.transport import SerialTransport
|
|
47
|
+
from cobra_bridge.sync import CobraBridge
|
|
48
|
+
from cobra_bridge.drivers.bmm350 import BMM350
|
|
49
|
+
|
|
50
|
+
# USB-Serial
|
|
51
|
+
transport = SerialTransport(port='/dev/ttyACM0')
|
|
52
|
+
bridge = CobraBridge(transport=transport)
|
|
53
|
+
bridge.connect()
|
|
54
|
+
|
|
55
|
+
sensor = BMM350(bridge)
|
|
56
|
+
sensor.init()
|
|
57
|
+
data = sensor.read_mag_data(compensated=True)
|
|
58
|
+
print(f"X={data['x']:.2f} Y={data['y']:.2f} Z={data['z']:.2f} uT")
|
|
59
|
+
|
|
60
|
+
bridge.disconnect()
|
|
61
|
+
```
|
|
62
|
+
|
|
63
|
+
## Platform-Specific Setup
|
|
64
|
+
|
|
65
|
+
### Linux
|
|
66
|
+
|
|
67
|
+
```bash
|
|
68
|
+
# Install
|
|
69
|
+
pip install cobra-bridge
|
|
70
|
+
|
|
71
|
+
# Serial port — typically /dev/ttyACM0 or /dev/ttyUSB0
|
|
72
|
+
# Add yourself to the dialout group to avoid sudo:
|
|
73
|
+
sudo usermod -aG dialout $USER
|
|
74
|
+
# Log out and back in for group changes to take effect
|
|
75
|
+
|
|
76
|
+
# Find your board:
|
|
77
|
+
ls /dev/ttyACM* /dev/ttyUSB*
|
|
78
|
+
|
|
79
|
+
# Usage
|
|
80
|
+
from cobra_bridge.transport import SerialTransport
|
|
81
|
+
transport = SerialTransport(port='/dev/ttyACM0')
|
|
82
|
+
```
|
|
83
|
+
|
|
84
|
+
### macOS
|
|
85
|
+
|
|
86
|
+
```bash
|
|
87
|
+
# Install
|
|
88
|
+
pip install cobra-bridge
|
|
89
|
+
|
|
90
|
+
# Serial port — typically /dev/cu.usbmodemXXXX
|
|
91
|
+
# List available ports:
|
|
92
|
+
ls /dev/cu.usbmodem*
|
|
93
|
+
|
|
94
|
+
# Usage
|
|
95
|
+
from cobra_bridge.transport import SerialTransport
|
|
96
|
+
transport = SerialTransport(port='/dev/cu.usbmodem1401')
|
|
97
|
+
```
|
|
98
|
+
|
|
99
|
+
### Windows
|
|
100
|
+
|
|
101
|
+
```bash
|
|
102
|
+
# Install
|
|
103
|
+
pip install cobra-bridge
|
|
104
|
+
|
|
105
|
+
# Serial port — typically COM3, COM4, etc.
|
|
106
|
+
# Check Device Manager → Ports (COM & LPT) to find your board
|
|
107
|
+
|
|
108
|
+
# Usage
|
|
109
|
+
from cobra_bridge.transport import SerialTransport
|
|
110
|
+
transport = SerialTransport(port='COM3')
|
|
111
|
+
```
|
|
112
|
+
|
|
113
|
+
## BLE (All Platforms)
|
|
114
|
+
|
|
115
|
+
```python
|
|
116
|
+
from cobra_bridge.transport import BleTransport
|
|
117
|
+
|
|
118
|
+
# Scan for devices
|
|
119
|
+
devices = await BleTransport.scan(timeout=5.0)
|
|
120
|
+
|
|
121
|
+
# Connect by address
|
|
122
|
+
transport = BleTransport(address='AA:BB:CC:DD:EE:FF')
|
|
123
|
+
bridge = CobraBridge(transport=transport)
|
|
124
|
+
bridge.connect()
|
|
125
|
+
```
|
|
126
|
+
|
|
127
|
+
> **Note:** BLE requires the `[ble]` extra: `pip install cobra-bridge[ble]`
|
|
128
|
+
|
|
129
|
+
## Architecture
|
|
130
|
+
|
|
131
|
+
```
|
|
132
|
+
┌──────────────┐ ┌─────────────┐
|
|
133
|
+
│ CobraBridge │────▶│ Transport │ ← abstract base
|
|
134
|
+
│ (Packetizer)│ │ (I/O) │
|
|
135
|
+
└──────────────┘ └─────────────┘
|
|
136
|
+
│
|
|
137
|
+
┌───────────┴───────────┐
|
|
138
|
+
│ │
|
|
139
|
+
Serial Transport BLE Transport
|
|
140
|
+
(pyserial/WebSerial) (Bleak/WebBluetooth)
|
|
141
|
+
```
|
|
142
|
+
|
|
143
|
+
## License
|
|
144
|
+
|
|
145
|
+
MIT
|
|
@@ -0,0 +1,122 @@
|
|
|
1
|
+
# cobra-bridge
|
|
2
|
+
|
|
3
|
+
**COines BRidge Access** — Bosch AppBoard protocol for Python
|
|
4
|
+
|
|
5
|
+
Transport-agnostic library for the Bosch Sensortec Application Board 3.1+.
|
|
6
|
+
Supports USB-Serial (pyserial) and BLE (Bleak) backends with identical protocol logic.
|
|
7
|
+
|
|
8
|
+
## Install
|
|
9
|
+
|
|
10
|
+
```bash
|
|
11
|
+
pip install cobra-bridge
|
|
12
|
+
```
|
|
13
|
+
|
|
14
|
+
For BLE support:
|
|
15
|
+
|
|
16
|
+
```bash
|
|
17
|
+
pip install cobra-bridge[ble]
|
|
18
|
+
```
|
|
19
|
+
|
|
20
|
+
## Quick Start
|
|
21
|
+
|
|
22
|
+
```python
|
|
23
|
+
from cobra_bridge.transport import SerialTransport
|
|
24
|
+
from cobra_bridge.sync import CobraBridge
|
|
25
|
+
from cobra_bridge.drivers.bmm350 import BMM350
|
|
26
|
+
|
|
27
|
+
# USB-Serial
|
|
28
|
+
transport = SerialTransport(port='/dev/ttyACM0')
|
|
29
|
+
bridge = CobraBridge(transport=transport)
|
|
30
|
+
bridge.connect()
|
|
31
|
+
|
|
32
|
+
sensor = BMM350(bridge)
|
|
33
|
+
sensor.init()
|
|
34
|
+
data = sensor.read_mag_data(compensated=True)
|
|
35
|
+
print(f"X={data['x']:.2f} Y={data['y']:.2f} Z={data['z']:.2f} uT")
|
|
36
|
+
|
|
37
|
+
bridge.disconnect()
|
|
38
|
+
```
|
|
39
|
+
|
|
40
|
+
## Platform-Specific Setup
|
|
41
|
+
|
|
42
|
+
### Linux
|
|
43
|
+
|
|
44
|
+
```bash
|
|
45
|
+
# Install
|
|
46
|
+
pip install cobra-bridge
|
|
47
|
+
|
|
48
|
+
# Serial port — typically /dev/ttyACM0 or /dev/ttyUSB0
|
|
49
|
+
# Add yourself to the dialout group to avoid sudo:
|
|
50
|
+
sudo usermod -aG dialout $USER
|
|
51
|
+
# Log out and back in for group changes to take effect
|
|
52
|
+
|
|
53
|
+
# Find your board:
|
|
54
|
+
ls /dev/ttyACM* /dev/ttyUSB*
|
|
55
|
+
|
|
56
|
+
# Usage
|
|
57
|
+
from cobra_bridge.transport import SerialTransport
|
|
58
|
+
transport = SerialTransport(port='/dev/ttyACM0')
|
|
59
|
+
```
|
|
60
|
+
|
|
61
|
+
### macOS
|
|
62
|
+
|
|
63
|
+
```bash
|
|
64
|
+
# Install
|
|
65
|
+
pip install cobra-bridge
|
|
66
|
+
|
|
67
|
+
# Serial port — typically /dev/cu.usbmodemXXXX
|
|
68
|
+
# List available ports:
|
|
69
|
+
ls /dev/cu.usbmodem*
|
|
70
|
+
|
|
71
|
+
# Usage
|
|
72
|
+
from cobra_bridge.transport import SerialTransport
|
|
73
|
+
transport = SerialTransport(port='/dev/cu.usbmodem1401')
|
|
74
|
+
```
|
|
75
|
+
|
|
76
|
+
### Windows
|
|
77
|
+
|
|
78
|
+
```bash
|
|
79
|
+
# Install
|
|
80
|
+
pip install cobra-bridge
|
|
81
|
+
|
|
82
|
+
# Serial port — typically COM3, COM4, etc.
|
|
83
|
+
# Check Device Manager → Ports (COM & LPT) to find your board
|
|
84
|
+
|
|
85
|
+
# Usage
|
|
86
|
+
from cobra_bridge.transport import SerialTransport
|
|
87
|
+
transport = SerialTransport(port='COM3')
|
|
88
|
+
```
|
|
89
|
+
|
|
90
|
+
## BLE (All Platforms)
|
|
91
|
+
|
|
92
|
+
```python
|
|
93
|
+
from cobra_bridge.transport import BleTransport
|
|
94
|
+
|
|
95
|
+
# Scan for devices
|
|
96
|
+
devices = await BleTransport.scan(timeout=5.0)
|
|
97
|
+
|
|
98
|
+
# Connect by address
|
|
99
|
+
transport = BleTransport(address='AA:BB:CC:DD:EE:FF')
|
|
100
|
+
bridge = CobraBridge(transport=transport)
|
|
101
|
+
bridge.connect()
|
|
102
|
+
```
|
|
103
|
+
|
|
104
|
+
> **Note:** BLE requires the `[ble]` extra: `pip install cobra-bridge[ble]`
|
|
105
|
+
|
|
106
|
+
## Architecture
|
|
107
|
+
|
|
108
|
+
```
|
|
109
|
+
┌──────────────┐ ┌─────────────┐
|
|
110
|
+
│ CobraBridge │────▶│ Transport │ ← abstract base
|
|
111
|
+
│ (Packetizer)│ │ (I/O) │
|
|
112
|
+
└──────────────┘ └─────────────┘
|
|
113
|
+
│
|
|
114
|
+
┌───────────┴───────────┐
|
|
115
|
+
│ │
|
|
116
|
+
Serial Transport BLE Transport
|
|
117
|
+
(pyserial/WebSerial) (Bleak/WebBluetooth)
|
|
118
|
+
```
|
|
119
|
+
|
|
120
|
+
## License
|
|
121
|
+
|
|
122
|
+
MIT
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
[build-system]
|
|
2
|
+
requires = ["hatchling"]
|
|
3
|
+
build-backend = "hatchling.build"
|
|
4
|
+
|
|
5
|
+
[project]
|
|
6
|
+
name = "cobra-bridge"
|
|
7
|
+
version = "0.1.0"
|
|
8
|
+
description = "COines BRidge Access — Bosch AppBoard protocol for Python"
|
|
9
|
+
readme = "README.md"
|
|
10
|
+
license = "MIT"
|
|
11
|
+
requires-python = ">=3.9"
|
|
12
|
+
authors = [
|
|
13
|
+
{ name = "John Poom", email = "drpoom@users.noreply.github.com" },
|
|
14
|
+
]
|
|
15
|
+
keywords = ["bosch", "sensortec", "coines", "appboard", "bmm350", "magnetometer", "i2c", "spi", "ble", "serial"]
|
|
16
|
+
classifiers = [
|
|
17
|
+
"Development Status :: 3 - Alpha",
|
|
18
|
+
"Intended Audience :: Developers",
|
|
19
|
+
"License :: OSI Approved :: MIT License",
|
|
20
|
+
"Programming Language :: Python :: 3",
|
|
21
|
+
"Topic :: System :: Hardware :: Hardware Drivers",
|
|
22
|
+
]
|
|
23
|
+
dependencies = [
|
|
24
|
+
"pyserial>=3.5",
|
|
25
|
+
]
|
|
26
|
+
|
|
27
|
+
[project.optional-dependencies]
|
|
28
|
+
ble = ["bleak>=0.21"]
|
|
29
|
+
dev = ["hatch", "pytest"]
|
|
30
|
+
|
|
31
|
+
[project.urls]
|
|
32
|
+
Homepage = "https://github.com/drpoom/cobra"
|
|
33
|
+
Repository = "https://github.com/drpoom/cobra"
|
|
34
|
+
|
|
35
|
+
[tool.hatch.build.targets.wheel]
|
|
36
|
+
packages = ["src/cobra_bridge"]
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
"""
|
|
2
|
+
COBRA — COines BRidge Access for Python
|
|
3
|
+
|
|
4
|
+
Transport-agnostic Bosch AppBoard protocol library.
|
|
5
|
+
Supports USB-Serial (pyserial) and BLE (Bleak).
|
|
6
|
+
|
|
7
|
+
Quick start:
|
|
8
|
+
from cobra_bridge.transport import SerialTransport
|
|
9
|
+
from cobra_bridge.sync import CobraBridge
|
|
10
|
+
|
|
11
|
+
transport = SerialTransport(port='/dev/ttyACM0')
|
|
12
|
+
bridge = CobraBridge(transport=transport)
|
|
13
|
+
bridge.connect()
|
|
14
|
+
"""
|
|
15
|
+
|
|
16
|
+
from cobra_bridge.constants import (
|
|
17
|
+
HEADER, TYPE_GET, TYPE_SET, STATUS_OK,
|
|
18
|
+
CMD_GET_BOARD_INFO, CMD_SET_VDD, CMD_SET_PIN, CMD_SET_VDDIO, CMD_INT_CONFIG,
|
|
19
|
+
CMD_I2C_WRITE, CMD_I2C_READ,
|
|
20
|
+
CMD_SPI_WRITE, CMD_SPI_READ,
|
|
21
|
+
I2C_SPEED_400K, I2C_SPEED_1M,
|
|
22
|
+
SPI_SPEED_5MHZ, SPI_SPEED_10MHZ, SPI_MODE_0, SPI_MODE_3,
|
|
23
|
+
BMM350_I2C_ADDR, BMM350_CHIP_ID, BMM350_DATA_LEN,
|
|
24
|
+
BMM350_REG, BMM350_PMU, BMM350_PMU_STATUS, BMM350_ODR, BMM350_AVG, BMM350_OTP_ADDR,
|
|
25
|
+
BMM350_LSB_TO_UT_XY, BMM350_LSB_TO_UT_Z, BMM350_LSB_TO_DEGC, BMM350_TEMP_OFFSET,
|
|
26
|
+
)
|
|
27
|
+
|
|
28
|
+
__version__ = '0.1.0'
|