Skip to content

Create API document page (WIP) #123

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

Merged
merged 1 commit into from
Sep 17, 2020
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
61 changes: 61 additions & 0 deletions API.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
# BlocklyProp Launcher REST API

This document provides details of the API available in the BlocklyProp Launcher. These calls are
available through a websocket interface. The client system should send API requests as JSON packet
messages as described below.

## Open Channel
When the websocket is established, this message initializes the channel that all subsequent interactions
with the APU will use.

### Message elements
**type** - Message name

**baud** - Select a baud rate that the BlocklyProp Launcher will use to communicate with attached devices.
```json
{
"type": "hello-browser",
"baud": "115200"
}
```

Example:
```javascript
const apiUrl = 'ws://localhost:6009';
connection = new WebSocket(apiUrl);

// Callback executed when the connection is opened
connection.onopen = function(event) {

// Create a Hello message
const wsMessage = {
type: 'hello-browser',
baud: '115200',
};

// Send the message to the API
connection.send(JSON.stringify(wsMessage));
};
```
##Load Propeller request
The client sends this message when it wants to download a Propeller Application to the connected
Propeller device, storing the app in either RAM or EEPROM (which is really RAM & EEPROM together)
###Message Elements
**type** - "load-prop"

**action** - "RAM" or "EEPROM"

**portPath** - target port's name (direct from the port drop-down list); wired or wireless port.

**payload** - A base-64 encoded .elf, .binary, or .eeprom data containing the Propeller Application image

**debug** - set to 'true' if a terminal is intended to connect to the Propeller after download, otherwise set to false.
```json
{
"type": "load-prop",
"action": "RAM",
"portPath": "device_name",
"payload": "D4F2A34AB...",
"debug": "false"
}
```