Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add real-time dashboard for viewing connected peripherals on the EV3 #2229

Merged
merged 15 commits into from
Sep 27, 2022

Conversation

RichDom2185
Copy link
Member

@RichDom2185 RichDom2185 commented Sep 21, 2022

Description

Take note of the breaking change: the frontend, backend*, EV3-source, and Sling* needs to be updated at the same time due to changes in the Sling protocol.

*Technically, Sling can be updated separately, as the frontend and EV3-source uses locked versions of the library and can be updated independently. The backend can also be updated separately as it only involves updating security settings, but this must be done before the rest are updated.

This PR can be merged independently the moment the new sling package is published on npmjs.

Related PRs:

Depencency updates:

  • @sourceacademy/sling-client: ^0.0.1 ~> ^0.1.0,

Change summary: Subscribe to a new MQTT topic, monitor, and listens to its messages sent by the EV3 to display real-time connection info when the EV3 is connected:
image

Backwards-compatible with older versions of EV3-source (hence can be merged independently). But not vice versa, so the frontend must be merged before EV3-source is updated.

As the monitor topic simply sends sensor/motor data (there are no "connect"/"disconnect" messages), the frontend auto marks a peripheral as "disconnected" and displays the unconnected port image when both of the following conditions are satisfied:

  • The frontend receives a new monitor update for any peripheral
  • The peripheral in question has not received any update within the last 5 seconds from the time the abovementioned event (first bullet point) ocurred.

Example:

  • Time = 0s : receives update about motor A. Is shown as connected
  • Time = 2s : receives update about motor B. Is shown as connected
  • Time = 3s: receives update about motor A. Its values are updated. No change for motor B
  • Time = 7s: receives update about motor A. Its values are updated. Motor B is marked as disconnected (replaced with initial state of an empty port)

Assets added are adapted from this repo (MIT license) and optimised using this app.

Type of change

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • This change requires a documentation update
  • Code quality improvements

How to test

Due to the major scale of this PR, you will need to perform the following steps:

  1. To test the frontend, you need to use the my fork + branch of sling here. Please clone the sling repository, run yarn build there, and run:
    yarn add file:../path/to/repo/dist
    
    in the frontend repo to use a local version of sling
  2. Set up a local MQTT server using Mosquito
    • Make to edit your mosquitto.conf file to enable both port 1883 (default port used for MQTT protocol) and 9001 (for MQTT over WebSockets), as well as allowing anonymous logins. Full instructions here.
  3. Reconfigure your backend copy to use the local MQTT server
    • Full instructions here.
  4. Manually point Sling on the EV3 to use your local MQTT server
    1. After the EV3 is connected to a network, SSH into the EV3. Default credentials are robot:maker:
    2. Stop the existing Sling service:
      sudo systemctl stop sling
      
    3. Manually run sling using the local IP address of the computer running the MQTT server + backend + frontend (in this case, 192.168.139.10). The -v flag is optional and enables verbose mode (recommended for debugging):
      cd /usr/local/bin
      sudo SLING_PORT=1883 /usr/local/bin/sling -v -h 192.168.139.10 -i 'env-sling:4' -k '' -c ''
      

Checklist

  • I have tested this code
  • I have updated the documentation No documentation update required for frontend

@RichDom2185 RichDom2185 marked this pull request as ready for review September 26, 2022 00:22
@coveralls
Copy link

coveralls commented Sep 27, 2022

Pull Request Test Coverage Report for Build 3134625514

Warning: This coverage report may be inaccurate.

This pull request's base commit is no longer the HEAD commit of its target branch. This means it includes changes from outside the original pull request, including, potentially, unrelated coverage changes.

Details

  • 14 of 55 (25.45%) changed or added relevant lines in 12 files are covered.
  • No unchanged relevant lines lost coverage.
  • Overall coverage decreased (-0.03%) to 33.539%

Changes Missing Coverage Covered Lines Changed/Added Lines %
src/assets/BrickSvg.tsx 1 2 50.0%
src/assets/PortSvg.tsx 1 2 50.0%
src/features/remoteExecution/PeripheralContainer.tsx 1 2 50.0%
src/features/remoteExecution/RemoteExecutionEv3Types.ts 3 10 30.0%
src/commons/sideContent/SideContentRemoteExecution.tsx 2 15 13.33%
src/commons/sagas/RemoteExecutionSaga.ts 0 18 0.0%
Totals Coverage Status
Change from base Build 3075993645: -0.03%
Covered Lines: 4302
Relevant Lines: 11970

💛 - Coveralls

Copy link
Member

@martin-henz martin-henz left a comment

Choose a reason for hiding this comment

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

Looks good to me. In the interest of speed, let's merge this one. @enrong has approved via telegram and github.

@martin-henz martin-henz merged commit f5f33ed into source-academy:master Sep 27, 2022
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.

4 participants