Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
flow3r firmware
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Container registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
flow3r
flow3r firmware
Commits
c3396167
Commit
c3396167
authored
1 year ago
by
q3k
Browse files
Options
Downloads
Patches
Plain Diff
docs: document badgenet
parent
96ff3cfb
Branches
Branches containing commit
No related tags found
1 merge request
!106
Implement Badge Net
Pipeline
#6503
passed
1 year ago
Stage: check
Stage: build
Stage: deploy
Changes
4
Pipelines
2
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
docs/api/badgenet.rst
+12
-0
12 additions, 0 deletions
docs/api/badgenet.rst
docs/badge/badge_link.rst
+1
-0
1 addition, 0 deletions
docs/badge/badge_link.rst
docs/badge/badge_net.rst
+170
-0
170 additions, 0 deletions
docs/badge/badge_net.rst
docs/index.rst
+2
-0
2 additions, 0 deletions
docs/index.rst
with
185 additions
and
0 deletions
docs/api/badgenet.rst
0 → 100644
+
12
−
0
View file @
c3396167
.. _Badge Net API:
``badgenet`` module
===================
.. note::
See also: :ref:`Badge Net overview<Badge Net>`
.. automodule:: badgenet
:members:
:undoc-members:
This diff is collapsed.
Click to expand it.
docs/badge/badge_link.rst
+
1
−
0
View file @
c3396167
...
...
@@ -30,6 +30,7 @@ Typical use cases include:
* :ref:`badge-link-uart`
* :ref:`badge-link-midi`
* :ref:`badge-link-eurorack-cv`
* :ref:`badge net` (Ethernet/IPv6 over Badge Link)
.. _badge-link-uart:
...
...
This diff is collapsed.
Click to expand it.
docs/badge/badge_net.rst
0 → 100644
+
170
−
0
View file @
c3396167
.. _Badge Net:
Badge Net
=========
.. note::
See also: :ref:`Micropython API docs<Badge Net API>`
Badge Net builds on top of :ref:`Badge Link` to provide Ethernet and IPv6
connectivity between badges, using 3.5mm jacks. Multiple badges can be connected
together and can all talk to eachother!
Each badge always runs a Badge Net interface that's visible as a standard
network interface to Micropython/ESP32.
When Badge Net connectivity is established, normal `sockets` calls can be used
to send and receive UDP packets, establish TCP connectivity, etc.
Protocol Stack
--------------
+-------------------------------------+---------------------+
| Layer | Info |
+=====================================+=====================+
| **TCP/UDP** | You use this. |
+-------------------------------------+---------------------+
| **IPv6** | You use this. |
+-------------------------------------+---------------------+
| Ethernet | Badge Net! |
+-------------------------------------+ +
| SLIP (packetization) | |
+-------------------------------------+ +
| UART (115200 baud) | |
+-------------------------------------+---------------------+
| **Badge Link** (ESP32 digital pins) | You configure this. |
+-------------------------------------+---------------------+
Each badge runs an Ethernet switch (in software) which allows multiple badges to
be connected together.
Connecting Badges
-----------------
Currently, Badge Net needs to be manually configured for each jack. Because most
3.5mm audio cables are not-crossed-over, and because we use UART under the hood,
you will have to pay attention to the polarity of each configured jack.
Each jack has two pins: a tip and a ring. Each jack needs to be configured to
transmit on one and receive on another.
Each jack can be configured in one of four modes:
+-------------------+-----------------------------------------------------------+
| Mode | Description |
+===================+===========================================================+
| Disabled | No Badge Net on this jack. |
+-------------------+-----------------------------------------------------------+
| Enabled, Auto | Tip transmits on left jack, ring transmits on right jack. |
+-------------------+-----------------------------------------------------------+
| Enabled, Tip TX | Tip transmits on this jack. |
+-------------------+-----------------------------------------------------------+
| Enabled, Ring TX | Ring transmits on this jack. |
+-------------------+-----------------------------------------------------------+
The simplest option is to configure all participating jacks in 'Auto' mode, and
always connect the left jack of one badge to the right jack of another badge.
To actually establish connectivity, use :py:func:`badgenet.configure_jack` to
set a modde for a jack, then :py:mod:`badgelink` to enable Badge Link on the
same jack. **Configuring the jack with Badge Net is not enough, it must also be
enabled for Badge Link!**.
For example, on badge A:
.. code-block:: pycon
>>> import badgenet
>>> badgenet.configure_jack(badgenet.SIDE_LEFT, badgenet.MODE_ENABLE_AUTO)
>>> import badgelink
>>> badgelink.left.enable()
And on badge B:
.. code-block:: pycon
>>> import badgenet
>>> badgenet.configure_jack(badgenet.SIDE_RIGHT, badgenet.MODE_ENABLE_AUTO)
>>> import badgelink
>>> badgelink.right.enable()
And then connect badge A's left jack to badge B's right jack.
Sending Packets (broadcast)
---------------------------
The simplest option for communication is to use good old broadcast UDP.
Well, there's no real broadcast with IPv6 - but here we'll use a 'standard'
multicast group to get the equivalent functionality. Fell free to use different
`Multicast Groups
<https://en.wikipedia.org/wiki/IPv6_address#Multicast_addresses>`!
You'll also have to suffix the multicast group address with ``%bl1``, or
whatever the name of the badgelink interface is. This is an IPv6 scope, and it's
required when dealing with link-local addresses.
On badge A:
.. code-block:: pycon
>>> addr = 'ff02::1%' + bagenet.get_interface().name()
>>> import socket
# IPv6, UDP
>>> s = socket.socket(socket.AF_INET6, socket.SOCK_DGRAM)
# Listen on multicast, UDP, port 1337
>>> s.bind((addr, 1337))
# Block until data was received
>>> msg, addr = s.recvfrom(1024)
On badge B:
.. code-block:: pycon
>>> addr = 'ff02::1%' + bagenet.get_interface().name()
>>> import socket
# IPv6, UDP
>>> s = socket.socket(socket.AF_INET6, socket.SOCK_DGRAM)
# Tell everyone something nice.
>>> s.sendto('hi, good to see you!', (addr, 1337))
Sending Packets (unicast)
-------------------------
You can find out the link-local address of badge A, then listen on ``::`` and
connect or send data to this badge via unicast packets (not broadcasting the
data to everyone).
.. code-block:: pycon
>>> badgenet.get_interface().ifconfig6()
['fe80::3685:18ff:fe90:888f']
>>> s = socket.socket(socket.AF_INET6, socket.SOCK_DGRAM)
>>> s.bind(('::', 1337))
>>> msg, addr = s.recvfrom(1024)
Then, on another badge:
.. code-block:: pycon
>>> addr = 'fe80::3685:18ff:fe90:888f%' + bagenet.get_interface().name()
>>> import socket
>>> s = socket.socket(socket.AF_INET6, socket.SOCK_DGRAM)
>>> s.sendto('hi there, badge A', (addr, 1337))
Implementing badge discovery using multicasts is an exercise left to the reader. :)
In a similar fashion, TCP connections over unicast should just work.
Known Issues
------------
Badge Net is very experimental. Here are some known issues that we'd like to
address in future versions of the flow3r firmware:
- No polarity autodetection.
- No unified user settings.
- No unified discovery mechanism.
- Badge Net loops are undefined behaviour :)
\ No newline at end of file
This diff is collapsed.
Click to expand it.
docs/index.rst
+
2
−
0
View file @
c3396167
...
...
@@ -17,6 +17,7 @@ Welcome to flow3r's documentation!
badge/firmware.rst
badge/firmware-development.rst
badge/badge_link.rst
badge/badge_net.rst
badge/bl00mbox.rst
.. toctree::
...
...
@@ -25,6 +26,7 @@ Welcome to flow3r's documentation!
api/audio.rst
api/badgelink.rst
api/badgenet.rst
api/captouch.rst
api/ctx.rst
api/leds.rst
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment