Skip to content

Commit 29a75d4

Browse files
committed
ble: upgrade to python-ndn 0.5.0
1 parent 0f6ec75 commit 29a75d4

File tree

6 files changed

+19
-30
lines changed

6 files changed

+19
-30
lines changed

.gitignore

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1 @@
11
/.vscode
2-
/docs/html
3-
/examples/*/build

extras/BLE/.gitignore

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,2 @@
1-
.venv
2-
Pipfile.lock
31
__pycache__
2+
venv

extras/BLE/BleClientFace.py

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,11 @@
11
import asyncio as aio
22
import struct
33
from concurrent.futures import ThreadPoolExecutor
4+
from typing import cast
45

56
from bluepy import btle
67
from ndn.encoding import parse_tl_num
7-
from ndn.transport.stream_socket import Face
8+
from ndn.transport.face import Face
89

910
UUID_SVC = '099577e3-0788-412a-8824-395084d97391'
1011
UUID_CS = 'cc5abb89-a541-46d8-a351-2f95a6a81f49'
@@ -34,9 +35,9 @@ async def open(self):
3435
self.delegate = BleClientFace.MyDelegate()
3536
self.p.setDelegate(self.delegate)
3637

37-
service = self.p.getServiceByUUID(UUID_SVC)
38-
self.cs, = service.getCharacteristics(UUID_CS)
39-
self.sc, = service.getCharacteristics(UUID_SC)
38+
service: btle.Service = self.p.getServiceByUUID(UUID_SVC)
39+
self.cs: btle.Characteristic = service.getCharacteristics(UUID_CS)[0]
40+
self.sc: btle.Characteristic = service.getCharacteristics(UUID_SC)[0]
4041
self.p.writeCharacteristic(
4142
self.sc.getHandle() + 1, struct.pack('<bb', 0x01, 0x00))
4243
self.delegate.scHandle = self.sc.getHandle()
@@ -74,3 +75,6 @@ def _once(self):
7475
tlvType, sizeofTlvType = parse_tl_num(wire)
7576
aio.ensure_future(self.callback(tlvType, wire), loop=self.loop)
7677
self.delegate.rxQueue.clear()
78+
79+
def isLocalFace(self):
80+
return False

extras/BLE/Pipfile

Lines changed: 0 additions & 15 deletions
This file was deleted.

extras/BLE/README.md

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -13,15 +13,15 @@ The protocol is summarized in NDNts [@ndn/web-bluetooth-transport](https://githu
1313
1. Install system-wide dependencies in a sudoer user:
1414

1515
```bash
16-
sudo apt install --no-install-recommends python3-dev python3-venv libglib2.0-dev
17-
curl -fsLS https://bootstrap.pypa.io/get-pip.py | sudo python3
18-
sudo pip install -U pip pipenv
16+
sudo apt install --no-install-recommends python3.11-dev python3.11-venv libglib2.0-dev
1917
```
2018

2119
2. Install local dependencies:
2220

2321
```bash
24-
pipenv install
22+
python3.11 -m venv venv
23+
source venv/bin/activate
24+
pip install -r requirements.txt
2525
```
2626

2727
3. Upload [BlePingServer](../../examples/BlePingServer) sketch to an ESP32 or nRF52 microcontroller.
@@ -30,8 +30,8 @@ The protocol is summarized in NDNts [@ndn/web-bluetooth-transport](https://githu
3030
4. Run the ping client with the displayed address and address type:
3131

3232
```bash
33-
pipenv run python BlePingClient.py --addr 02:00:00:00:00:00 --addr-type public
34-
pipenv run python BlePingClient.py --addr 02:00:00:00:00:00 --addr-type random
33+
python BlePingClient.py --addr 02:00:00:00:00:00 --addr-type public
34+
python BlePingClient.py --addr 02:00:00:00:00:00 --addr-type random
3535
```
3636

3737
## BLE-UDP Bridge
@@ -42,7 +42,7 @@ It listens on a UDP port and connects to a BLE peripheral.
4242
1. Start the bridge program:
4343

4444
```bash
45-
pipenv run python BleUdpBridge.py --addr 02:00:00:00:00:00 --addr-type public
45+
python BleUdpBridge.py --addr 02:00:00:00:00:00 --addr-type public
4646
```
4747

4848
2. In NFD, create a UDP face with NDNLPv2 fragmentation:

extras/BLE/requirements.txt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
bluepy == 1.3.0
2+
python-ndn == 0.5.1
3+

0 commit comments

Comments
 (0)