Skip to content

docs: add an example for the streaming feature#99

Merged
mariobehling merged 1 commit intofossasia:masterfrom
kienvo:ng-example
Jul 21, 2025
Merged

docs: add an example for the streaming feature#99
mariobehling merged 1 commit intofossasia:masterfrom
kienvo:ng-example

Conversation

@kienvo
Copy link
Copy Markdown
Member

@kienvo kienvo commented Jul 18, 2025

Resolves #98

Changes:

  • Add a script to test the streaming feature with expect and bluez
  • Document how to use this script
  • Fix the streaming feature was limited to 22 columns.

Summary by Sourcery

Provide an end-to-end example script and documentation for the BLE streaming feature and fix its column limit

New Features:

  • Add expect-based example script for testing the BLE streaming feature

Bug Fixes:

  • Remove the 22-column limit in the streaming feature by updating the memory copy length

Documentation:

  • Document how to use the streaming example script in BadgeBLE.md

Tests:

  • Include automated steps in the example script to scan, connect, enter/exit streaming mode, and send bitmap data

@sourcery-ai
Copy link
Copy Markdown
Contributor

sourcery-ai Bot commented Jul 18, 2025

Reviewer's Guide

This PR enhances the streaming feature by fixing its data length limitation, adding an automated expect-based example script, and documenting its usage in the Markdown reference.

Sequence diagram for the streaming feature test script interaction

sequenceDiagram
    actor User
    participant Script
    participant Bluetoothctl
    participant Badge
    User->>Script: Run streaming.sh
    Script->>Bluetoothctl: Start bluetoothctl
    Script->>Bluetoothctl: Scan for device
    Bluetoothctl->>Script: Device found
    Script->>Bluetoothctl: Connect to device
    Bluetoothctl->>Badge: Establish BLE connection
    Bluetoothctl->>Script: Connection successful
    Script->>Bluetoothctl: Select GATT attribute
    Script->>Bluetoothctl: Enter streaming mode (gatt.write '02 00')
    Bluetoothctl->>Badge: Enter streaming mode
    Script->>Bluetoothctl: Write bitmap content (gatt.write '03 ...')
    Bluetoothctl->>Badge: Update display
    Script->>Bluetoothctl: Exit streaming mode (gatt.write '02 01')
    Bluetoothctl->>Badge: Exit streaming mode
    Script->>Bluetoothctl: Exit
    Bluetoothctl->>Script: EOF
Loading

File-Level Changes

Change Details Files
Extend streaming data handling to support larger payloads
  • Changed tmos_memcpy to use min(LED_COLS * 2, len) instead of LED_COLS
src/main.c
Add expect-based streaming example script
  • Introduced a new example/streaming.sh to automate BLE scanning, connection, streaming, and exit
  • Configured steps for characteristic selection, entering/leaving streaming mode, and writing bitmap data
example/streaming.sh
Document the streaming example usage
  • Inserted an Example section in BadgeBLE.md
  • Outlined dependencies (expect, bluez) and usage steps for the script
BadgeBLE.md

Assessment against linked issues

Issue Objective Addressed Explanation
#98 Provide example(s) for the next-gen profile to help app-side developers understand its usage.

Tips and commands

Interacting with Sourcery

  • Trigger a new review: Comment @sourcery-ai review on the pull request.
  • Continue discussions: Reply directly to Sourcery's review comments.
  • Generate a GitHub issue from a review comment: Ask Sourcery to create an
    issue from a review comment by replying to it. You can also reply to a
    review comment with @sourcery-ai issue to create an issue from it.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull
    request title to generate a title at any time. You can also comment
    @sourcery-ai title on the pull request to (re-)generate the title at any time.
  • Generate a pull request summary: Write @sourcery-ai summary anywhere in
    the pull request body to generate a PR summary at any time exactly where you
    want it. You can also comment @sourcery-ai summary on the pull request to
    (re-)generate the summary at any time.
  • Generate reviewer's guide: Comment @sourcery-ai guide on the pull
    request to (re-)generate the reviewer's guide at any time.
  • Resolve all Sourcery comments: Comment @sourcery-ai resolve on the
    pull request to resolve all Sourcery comments. Useful if you've already
    addressed all the comments and don't want to see them anymore.
  • Dismiss all Sourcery reviews: Comment @sourcery-ai dismiss on the pull
    request to dismiss all existing Sourcery reviews. Especially useful if you
    want to start fresh with a new review - don't forget to comment
    @sourcery-ai review to trigger a new review!

Customizing Your Experience

Access your dashboard to:

  • Enable or disable review features such as the Sourcery-generated pull request
    summary, the reviewer's guide, and others.
  • Change the review language.
  • Add, remove or edit custom review instructions.
  • Adjust other review settings.

Getting Help

Copy link
Copy Markdown
Contributor

@sourcery-ai sourcery-ai Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey @kienvo - I've reviewed your changes and they look great!

Prompt for AI Agents
Please address the comments from this code review:
## Individual Comments

### Comment 1
<location> `example/streaming.sh:36` </location>
<code_context>
+sleep 5
+
+# Write an entire screen with increment values
+send -- "gatt.write '03 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 \
+22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 \
+48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 \
</code_context>

<issue_to_address>
Long gatt.write command is split across multiple lines using backslashes, which may not be portable.

Backslash line continuations in expect scripts can be unreliable across environments. Use a single long string or concatenate strings in a way that's compatible with expect.
</issue_to_address>

<suggested_fix>
<<<<<<< SEARCH
send -- "gatt.write '03 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 \
22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 \
48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 \
74 75 76 77 78 79 80 81 82 83 84 85 86 87 88'\r"
=======
send -- "gatt.write '03 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88'\r"
>>>>>>> REPLACE

</suggested_fix>

Sourcery is free for open source - if you like our reviews please consider sharing them ✨
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.

Comment thread example/streaming.sh
@kienvo
Copy link
Copy Markdown
Member Author

kienvo commented Jul 18, 2025

The CI build failed because the toolchain link was changed in the MounRiver site.

@mariobehling mariobehling merged commit f625f57 into fossasia:master Jul 21, 2025
1 of 2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Create examples for the next-gen profile

2 participants