Skip to content
This repository was archived by the owner on Mar 27, 2025. It is now read-only.
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
27 commits
Select commit Hold shift + click to select a range
11960bc
Added status handler
cmaglie Dec 7, 2017
d324c03
Removed one level of indirection in mqtt callbacks
cmaglie Dec 13, 2017
9d70b7b
Added status.InfoCommandOutput to simplify sending commands output
cmaglie Dec 13, 2017
3585708
Added APT package manager handlers
cmaglie Dec 13, 2017
72c1a36
Added APT repository handlers
cmaglie Dec 13, 2017
eb29080
Add network control feature
facchinm Dec 13, 2017
5a28fa8
Allow the connector to be compiled with development info
matteosuppo Dec 22, 2017
7110ecb
Merge pull request #25 from arduino/dev
Dec 28, 2017
e6df8a1
Handle errors
matteosuppo Dec 28, 2017
30babe6
Don't replicate authurl and apiurl
matteosuppo Dec 28, 2017
b3a12e1
Added search parameter in apt package listing
cmaglie Dec 28, 2017
9ad37fe
Small improvement in apt-package listing
cmaglie Dec 28, 2017
941132e
Added pagination on package listing
cmaglie Dec 28, 2017
3c4bff6
Ensure all the endpoint have the same behaviour
matteosuppo Dec 22, 2017
717b95b
Docs
matteosuppo Dec 22, 2017
44c30ba
apt.list: return upgradable packages when search is not set
matteosuppo Jan 2, 2018
7b2c76d
Fixed typo in mqtt queue identifier
cmaglie Jan 4, 2018
86c107b
Small fix in readme
cmaglie Jan 4, 2018
47848f9
Fixed comment
cmaglie Jan 4, 2018
62227b4
Fixed linter warning on const name
cmaglie Jan 4, 2018
86ce704
add updater
AlbyIanna Jan 8, 2018
683f7f2
update readme
AlbyIanna Jan 8, 2018
536d977
Merge remote-tracking branch 'origin/status' into integration
AlbyIanna Jan 9, 2018
5a57826
sync with status refactor
AlbyIanna Jan 9, 2018
6b066a9
change download update feed repository
AlbyIanna Jan 9, 2018
7b3fedd
print version number
AlbyIanna Jan 9, 2018
c027a5a
version as var to allow rewrite via ldflag
AlbyIanna Jan 9, 2018
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
263 changes: 262 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,4 +20,265 @@ The Arduino Connector is tied to a specific device registered within the Arduino

Make sure you have an Arduino Account and you are able to log at: https://auth.arduino.cc/login

Please write us at auth@arduino.cc if you encounter any issue loggin in and you need support.
Please write us at auth@arduino.cc if you encounter any issue loggin in and you need support.


## Compile
```
go get github.com/arduino/arduino-connector
go build -ldflags "-X main.version=$VERSION" github.com/arduino/arduino-connector
```

## Autoupdate
```
go get github.com/sanbornm/go-selfupdate
./bin/go-selfupdate arduino-connector $VERSION
# scp -r public/* user@server:/var/www/files/arduino-connector
```

### API

To control the arduino-connector you must have:

- the ID of the device in which the arduino-connector has been installed (eg `username:0002251d-4e19-4cc8-a4a9-1de215bfb502`)
- a working mqtt connection

Send messages to the topic ending with /post, Receive the answer from the topic ending with /. Errors are sent to the same endpoint.

You can distinguish between errors and non-errors because of the INFO: or ERROR: prefix of the message

#### Status

Retrieve the status of the connector
```
{}
--> $aws/things/{{id}}/status/post

INFO: {
"sketches": {
"4c1f3a9d-ed78-4ae4-94c8-bcfa2e94c692": {
"name":"sketch_oct31a",
"id":"4c1f3a9d-ed78-4ae4-94c8-bcfa2e94c692",
"pid":31343,
"status":"RUNNING",
"endpoints":null
}
}
}
<-- $aws/things/{{id}}/status
```

Upload a sketch on the connector
```
{
"token": "toUZDUNTcooVlyqAUwooBGAEtgr8iPzp017RhcST8gM.bDBgrxVzKKySBX-kBPMRqFRqlP3j_cwlgt9qPh_Ct2Y",
"url": "https://api-builder.arduino.cc/builder/v1/compile/sketch_oct31a.bin",
"name": "sketch_oct31a",
"id": "4c1f3a9d-ed78-4ae4-94c8-bcfa2e94c692"
}
--> $aws/things/{{id}}/upload/post

INFO: Sketch started with PID 570
<-- $aws/things/{{id}}/upload
```

Update the arduino-connector (doesn't return anything)
```
{
"url": "https://downloads.arduino.cc/tools/arduino-connector",
}
--> $aws/things/{{id}}/update/post

<-- $aws/things/{{id}}/sketch
```

Update the arduino-connector
```
{
"url": "https://downloads.arduino.cc/tools/arduino-connector",
}
--> $aws/things/{{id}}/update/post

<-- $aws/things/{{id}}/sketch
```

Retrieve the stats of the machine (memory, disk, networks)
```
{}
--> $aws/things/{{id}}/stats/post

INFO: {
"memory":{
"FreeMem":1317964,
"TotalMem":15859984,
"AvailableMem":8184204,
"Buffers":757412,
"Cached":6569888,
"FreeSwapMem":0,
"TotalSwapMem":0
},
"disk":[
{
"Device":"sysfs",
"Type":"sysfs",
"MountPoint":"/sys",
"FreeSpace":0,
"AvailableSpace":0,
"DiskSize":0
},
],
"network":{
"Devices":[
{
"AccessPoints":[
{
"Flags":1,
"Frequency":2437,
"HWAddress":"58:6D:8F:8F:FD:F3",
"MaxBitrate":54000,
"Mode":"Nm80211ModeInfra",
"RSNFlags":392,
"SSID":"ssid-2g",
"Strength":80,
"WPAFlags":0
}
],
"AvailableConnections":[
{
"802-11-wireless":{
"mac-address":"QOIwy+Ef",
"mac-address-blacklist":[],
"mode":"infrastructure",
"security":"802-11-wireless-security",
"seen-bssids":[
"58:6D:8F:8F:FD:F3"
],
"ssid":"QkNNSWxhYnMtMmc="
},
"802-11-wireless-security":{
"auth-alg":"open",
"group":[],
"key-mgmt":"wpa-psk",
"pairwise":[],
"proto":[]
},
"connection":{
"id":"ssid-2g",
"permissions":[],
"secondaries":[],
"timestamp":1513953989,
"type":"802-11-wireless",
"uuid":"b5dd1024-db02-4e0f-ad3b-c41c375f750a"
},
"ipv4":{
"address-data":[],
"addresses":[],
"dns":[],
"dns-search":[],
"method":"auto",
"route-data":[],
"routes":[]
},
"ipv6":{
"address-data":[],
"addresses":[],
"dns":[],
"dns-search":[],
"method":"auto",
"route-data":[],
"routes":[]
}
}
],
"DeviceType":"NmDeviceTypeWifi",
"IP4Config":{
"Addresses":[
{
"Address":"10.130.22.132",
"Prefix":24,
"Gateway":"10.130.22.1"
}
],
"Domains":[],
"Nameservers":[
"10.130.22.1"
],
"Routes":[]
},
"Interface":"wlp4s0",
"State":"NmDeviceStateActivated"
}
],
"Status":"NmStateConnectedGlobal"
}
}
<-- $aws/things/{{id}}/stats
```

Configure the wifi (doesn't return anything)
```
{
"ssid": "ssid-2g",
"password": "passwordssid"
}
--> $aws/things/{{id}}/stats/post

<-- $aws/things/{{id}}/stats
```

#### Package Management

Retrieve a list of the upgradable packages

```
{}
--> $aws/things/{{id}}/apt/list/post

INFO: {"packages":[
{"Name":"firefox","Status":"upgradable","Architecture":"amd64","Version":"57.0.3+build1-0ubuntu0.17.10.1"},
{"Name":"firefox-locale-en","Status":"upgradable","Architecture":"amd64","Version":"57.0.3+build1-0ubuntu0.17.10.1"}
],
"page":0,"pages":1}
<-- $aws/things/{{id}}/apt/list
```

Search for installed/installable/upgradable packages

```
{"search": "linux"}
--> $aws/things/{{id}}/apt/list/post

INFO: {"packages":[
{"Name":"binutils-x86-64-linux-gnu","Status":"installed","Architecture":"amd64","Version":"2.29.1-4ubuntu1"},
{"Name":"firmware-linux","Status":"not-installed","Architecture":"","Version":""},
...
],"page":0,"pages":6}
<-- $aws/things/{{id}}/apt/list
```

Navigate pages

```
{"search": "linux", "page": 2}
--> $aws/things/{{id}}/apt/list/post

INFO: {"packages":[
{"Name":"linux-image-4.10.0-30-generic","Status":"config-files","Architecture":"amd64","Version":"4.10.0-30.34"},
{"Name":"linux-image-4.13.0-21-generic","Status":"installed","Architecture":"amd64","Version":"4.13.0-21.24"},
...
],"page":2,"pages":6}
<-- $aws/things/{{id}}/apt/list
```

TODO:
```
mqttClient.Subscribe("$aws/things/"+id+"/apt/install/post", 1, status.AptInstallEvent)
mqttClient.Subscribe("$aws/things/"+id+"/apt/update/post", 1, status.AptUpdateEvent)
mqttClient.Subscribe("$aws/things/"+id+"/apt/upgrade/post", 1, status.AptUpgradeEvent)
mqttClient.Subscribe("$aws/things/"+id+"/apt/remove/post", 1, status.AptRemoveEvent)

mqttClient.Subscribe("$aws/things/"+id+"/apt/repos/list/post", 1, status.AptRepositoryListEvent)
mqttClient.Subscribe("$aws/things/"+id+"/apt/repos/add/post", 1, status.AptRepositoryAddEvent)
mqttClient.Subscribe("$aws/things/"+id+"/apt/repos/remove/post", 1, status.AptRepositoryRemoveEvent)
mqttClient.Subscribe("$aws/things/"+id+"/apt/repos/edit/post", 1, status.AptRepositoryEditEvent)
```
Loading