Skip to content

Commit 0827fb2

Browse files
author
Alberto Iannaccone
committed
take boards url as parameter in Daemon constructor
1 parent 7750263 commit 0827fb2

File tree

5 files changed

+9
-8
lines changed

5 files changed

+9
-8
lines changed

README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ npm install arduino-create-agent-js-client --save
1515
```js
1616
import Daemon from 'arduino-create-agent-js-client';
1717

18-
const daemon = new Daemon();
18+
const daemon = new Daemon('https://builder.arduino.cc/v3/boards');
1919

2020
daemon.agentFound.subscribe(status => {
2121
// true / false

demo/app.jsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ const scrollToBottom = (target) => {
3131
}
3232
};
3333

34-
const daemon = new Daemon(chromeExtensionID);
34+
const daemon = new Daemon('https://builder.arduino.cc/v3/boards', chromeExtensionID);
3535

3636
const handleUpload = () => {
3737
const target = {

src/chrome-app-daemon.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,8 @@ import Daemon from './daemon';
2626
const POLLING_INTERVAL = 2000;
2727

2828
export default class ChromeOsDaemon extends Daemon {
29-
constructor(chromeExtensionId) {
30-
super();
29+
constructor(boardsUrl, chromeExtensionId) {
30+
super(boardsUrl);
3131
this.channel = null;
3232

3333
this.openChannel(() => this.channel.postMessage({

src/daemon.js

+3-2
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,8 @@ import { takeUntil, filter, startWith, first, distinctUntilChanged } from 'rxjs/
2424
const POLLING_INTERVAL = 1500;
2525

2626
export default class Daemon {
27-
constructor() {
27+
constructor(boardsUrl = 'https://builder.arduino.cc/v3/boards') {
28+
this.BOARDS_URL = boardsUrl;
2829
this.UPLOAD_NOPE = 'UPLOAD_NOPE';
2930
this.UPLOAD_DONE = 'UPLOAD_DONE';
3031
this.UPLOAD_ERROR = 'UPLOAD_ERROR';
@@ -112,7 +113,7 @@ export default class Daemon {
112113
this.closeSerialMonitor(target.port);
113114

114115
// Fetch command line for the board
115-
fetch(`https://builder.arduino.cc/v3/boards/${target.board}/compute`, {
116+
fetch(`${this.BOARDS_URL}/${target.board}/compute`, {
116117
method: 'POST',
117118
body: JSON.stringify({ action: 'upload', verbose })
118119
})

src/socket-daemon.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -54,8 +54,8 @@ if (browser.name !== 'chrome' && browser.name !== 'firefox') {
5454
}
5555

5656
export default class SocketDaemon extends Daemon {
57-
constructor() {
58-
super();
57+
constructor(boardsUrl) {
58+
super(boardsUrl);
5959
this.selectedProtocol = PROTOCOL.HTTP;
6060
this.socket = null;
6161
this.pluginURL = null;

0 commit comments

Comments
 (0)