Skip to content

Commit

Permalink
Update tutorial markdown files
Browse files Browse the repository at this point in the history
  • Loading branch information
tcamise-gpsw committed Dec 7, 2023
1 parent b5da577 commit a40e29f
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 14 deletions.
2 changes: 1 addition & 1 deletion demos/python/tutorial/pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[tool.poetry]
name = "open-gopro-tutorials"
version = "0.1.0"
version = "0.2.0"
description = "Open GoPro Python Tutorials"
authors = ["Tim Camise <[email protected]>"]
license = "MIT"
Expand Down
6 changes: 3 additions & 3 deletions docs/_tutorials/tutorial_2_send_ble_commands/tutorial.md
Original file line number Diff line number Diff line change
Expand Up @@ -167,11 +167,11 @@ This is a very simple handler; response parsing will be expanded upon in the
{% linkedTabs response_parsing %}
{% tab response_parsing python %}
```python
def notification_handler(handle: int, data: bytes) -> None:
logger.info(f'Received response at {handle=}: {hexlify(data, ":")!r}')
def notification_handler(characteristic: BleakGATTCharacteristic, data: bytes) -> None:
logger.info(f'Received response at handle {characteristic.handle}: {data.hex(":")}')

# If this is the correct handle and the status is success, the command was a success
if client.services.characteristics[handle].uuid == response_uuid and data[2] == 0x00:
if client.services.characteristics[characteristic.handle].uuid == response_uuid and data[2] == 0x00:
logger.info("Command sent successfully")
# Anything else is unexpected. This shouldn't happen
else:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -624,7 +624,7 @@ received the entire response, at which point we notify the writer that the respo
{% linkedTabs parse_get_all_settings_values %}
{% tab parse_get_all_settings_values python %}
```python
def notification_handler(handle: int, data: bytes) -> None:
def notification_handler(characteristic: BleakGATTCharacteristic, data: bytes) -> None:
response.accumulate(data)
if response.is_received:
Expand Down
18 changes: 9 additions & 9 deletions docs/_tutorials/tutorial_4_ble_queries/tutorial.md
Original file line number Diff line number Diff line change
Expand Up @@ -149,13 +149,13 @@ Therefore, we have slightly changed the notification handler to update a global
queries the resolution:

```python
def notification_handler(handle: int, data: bytes) -> None:
def notification_handler(characteristic: BleakGATTCharacteristic, data: bytes) -> None:
response.accumulate(data)

if response.is_received:
response.parse()

if client.services.characteristics[handle].uuid == QUERY_RSP_UUID:
if client.services.characteristics[characteristic.handle].uuid == QUERY_RSP_UUID:
resolution = Resolution(response.data[RESOLUTION_ID][0])

# Notify writer that the procedure is complete
Expand Down Expand Up @@ -290,15 +290,15 @@ When the response is received in / from the notification handler, we update the
{% linkedTabs individual_parse %}
{% tab individual_parse python %}
```python
def notification_handler(handle: int, data: bytes) -> None:
def notification_handler(characteristic: BleakGATTCharacteristic, data: bytes) -> None:
response.accumulate(data)

# Notify the writer if we have received the entire response
if response.is_received:
response.parse()

# If this is query response, it must contain a resolution value
if client.services.characteristics[handle].uuid == QUERY_RSP_UUID:
if client.services.characteristics[characteristic.handle].uuid == QUERY_RSP_UUID:
resolution = Resolution(response.data[RESOLUTION_ID][0])
```

Expand Down Expand Up @@ -417,13 +417,13 @@ We are also parsing the response to get all 3 values:
{% linkedTabs multiple_parse %}
{% tab multiple_parse python %}
```python
def notification_handler(handle: int, data: bytes) -> None:
def notification_handler(characteristic: BleakGATTCharacteristic, data: bytes) -> None:
response.accumulate(data)

if response.is_received:
response.parse()

if client.services.characteristics[handle].uuid == QUERY_RSP_UUID:
if client.services.characteristics[characteristic.handle].uuid == QUERY_RSP_UUID:
resolution = Resolution(response.data[RESOLUTION_ID][0])
fps = FPS(response.data[FPS_ID][0])
video_fov = VideoFOV(response.data[FOV_ID][0])
Expand Down Expand Up @@ -578,8 +578,8 @@ the raw byte data as well as by inspecting the response's `id` property.
{% linkedTabs register_parse %}
{% tab register_parse python %}
```python
def notification_handler(handle: int, data: bytes) -> None:
logger.info(f'Received response at {handle=}: {hexlify(data, ":")!r}')
def notification_handler(characteristic: BleakGATTCharacteristic, data: bytes) -> None:
logger.info(f'Received response at handle {characteristic.handle}: {data.hex(":")}')
response.accumulate(data)
Expand All @@ -588,7 +588,7 @@ def notification_handler(handle: int, data: bytes) -> None:
response.parse()
# If this is query response, it must contain a resolution value
if client.services.characteristics[handle].uuid == QUERY_RSP_UUID:
if client.services.characteristics[characteristic.handle].uuid == QUERY_RSP_UUID:
global resolution
resolution = Resolution(response.data[RESOLUTION_ID][0])
```
Expand Down

0 comments on commit a40e29f

Please sign in to comment.