Skip to content

Commit d4ef3a1

Browse files
committed
Release 1.13.15
1 parent fdf16a0 commit d4ef3a1

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

68 files changed

+1999
-131
lines changed

cli/daemon.ts

Lines changed: 16 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ import { EventEmitter } from "tsee";
2222
import { getCliVersion, initCliApp, setupCliApp } from './init-cli-app';
2323
import { Mutex } from 'async-mutex';
2424
import WebSocket from 'ws';
25+
import encodeLabel from '../shared/encoding';
2526

2627
const TCP_PREFIX = '\x1b[32m[WS ]\x1b[0m';
2728
const SERIAL_PREFIX = '\x1b[33m[SER]\x1b[0m';
@@ -34,6 +35,8 @@ const apiKeyArgvIx = process.argv.indexOf('--api-key');
3435
const apiKeyArgv = apiKeyArgvIx !== -1 ? process.argv[apiKeyArgvIx + 1] : undefined;
3536
const baudRateArgvIx = process.argv.indexOf('--baud-rate');
3637
const baudRateArgv = baudRateArgvIx !== -1 ? process.argv[baudRateArgvIx + 1] : undefined;
38+
const whichDeviceArgvIx = process.argv.indexOf('--which-device');
39+
const whichDeviceArgv = whichDeviceArgvIx !== -1 ? Number(process.argv[whichDeviceArgvIx + 1]) : undefined;
3740

3841
let configFactory: Config;
3942
let serial: SerialConnector | undefined;
@@ -53,7 +56,7 @@ const cliOptions = {
5356
};
5457

5558
class SerialDevice extends (EventEmitter as new () => TypedEmitter<{
56-
snapshot: (buffer: Buffer) => void
59+
snapshot: (buffer: Buffer, filename: string) => void
5760
}>) implements RemoteMgmtDevice {
5861
private _config: EdgeImpulseConfig;
5962
private _serial: SerialConnector;
@@ -116,6 +119,10 @@ class SerialDevice extends (EventEmitter as new () => TypedEmitter<{
116119
return this._deviceConfig.snapshot.supportsStreaming;
117120
}
118121

122+
supportsSnapshotStreamingWhileCapturing() {
123+
return false;
124+
}
125+
119126
async stopSnapshotStreamFromSignal() {
120127
if (!this._waitingForSnapshotToStart && !this._snapshotStream) {
121128
return;
@@ -211,7 +218,7 @@ class SerialDevice extends (EventEmitter as new () => TypedEmitter<{
211218
height: height,
212219
}, 80);
213220

214-
this.emit('snapshot', jpegImageData.data);
221+
this.emit('snapshot', jpegImageData.data, '');
215222
this._lastSnapshot = new Date();
216223
}
217224
}
@@ -350,11 +357,12 @@ class SerialDevice extends (EventEmitter as new () => TypedEmitter<{
350357

351358
let headers: { [k: string]: string} = {
352359
'x-api-key': this._deviceConfig.upload.apiKey,
353-
'x-file-name': filename,
360+
'x-file-name': encodeLabel(filename),
354361
'Content-Type': (!processed.attachments ? processed.contentType : 'multipart/form-data'),
355362
'Connection': 'keep-alive'
356363
};
357-
headers['x-label'] = s.label;
364+
365+
headers['x-label'] = encodeLabel(s.label);
358366

359367
let url = this._config.endpoints.internal.ingestion + s.path;
360368
console.log(SERIAL_PREFIX, 'Uploading to', url);
@@ -427,8 +435,8 @@ class SerialDevice extends (EventEmitter as new () => TypedEmitter<{
427435
await request.post(url, {
428436
headers: {
429437
'x-api-key': this._deviceConfig.upload.apiKey,
430-
'x-file-name': deviceResponse.filename,
431-
'x-label': dr.label,
438+
'x-file-name': encodeLabel(deviceResponse.filename),
439+
'x-label': encodeLabel(dr.label),
432440
'Content-Type': 'application/octet-stream'
433441
},
434442
body: deviceResponse.file,
@@ -439,7 +447,7 @@ class SerialDevice extends (EventEmitter as new () => TypedEmitter<{
439447
await request.post(url, {
440448
headers: {
441449
'x-api-key': this._deviceConfig.upload.apiKey,
442-
'x-file-name': deviceResponse.filename,
450+
'x-file-name': encodeLabel(deviceResponse.filename),
443451
'Content-Type': 'application/cbor'
444452
},
445453
body: deviceResponse.file,
@@ -482,7 +490,7 @@ class SerialDevice extends (EventEmitter as new () => TypedEmitter<{
482490
console.log(' Ingestion:', config.endpoints.internal.ingestion);
483491
console.log('');
484492

485-
let deviceId = await findSerial();
493+
let deviceId = await findSerial(whichDeviceArgv);
486494
await connectToSerial(config, deviceId, baudRate, (cleanArgv || apiKeyArgv) ? true : false);
487495
}
488496
catch (ex) {

cli/data-forwarder.ts

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ import { Config, EdgeImpulseConfig } from './config';
1616
import { findSerial } from './find-serial';
1717
import crypto from 'crypto';
1818
import { getCliVersion, initCliApp, setupCliApp } from './init-cli-app';
19+
import encodeLabel from '../shared/encoding';
1920

2021
const TCP_PREFIX = '\x1b[32m[WS ]\x1b[0m';
2122
const SERIAL_PREFIX = '\x1b[33m[SER]\x1b[0m';
@@ -30,6 +31,8 @@ const frequencyArgvIx = process.argv.indexOf('--frequency');
3031
const frequencyArgv = frequencyArgvIx !== -1 ? Number(process.argv[frequencyArgvIx + 1]) : undefined;
3132
const baudRateArgvIx = process.argv.indexOf('--baud-rate');
3233
const baudRateArgv = baudRateArgvIx !== -1 ? process.argv[baudRateArgvIx + 1] : undefined;
34+
const whichDeviceArgvIx = process.argv.indexOf('--which-device');
35+
const whichDeviceArgv = whichDeviceArgvIx !== -1 ? Number(process.argv[whichDeviceArgvIx + 1]) : undefined;
3336

3437
const cliOptions = {
3538
appName: 'Edge Impulse data forwarder',
@@ -75,7 +78,7 @@ let configFactory: Config;
7578
console.log(' Ingestion:', config.endpoints.internal.ingestion);
7679
console.log('');
7780

78-
let serialPath = await findSerial();
81+
let serialPath = await findSerial(whichDeviceArgv);
7982
await connectToSerial(config, serialPath, baudRate, (cleanArgv || apiKeyArgv) ? true : false);
8083
}
8184
catch (ex) {
@@ -385,8 +388,8 @@ async function connectToSerial(eiConfig: EdgeImpulseConfig, serialPath: string,
385388
await request.post(eiConfig.endpoints.internal.ingestion + s.path, {
386389
headers: {
387390
'x-api-key': dataForwarderConfig.apiKey,
388-
'x-file-name': s.label + '.json',
389-
'x-label': s.label,
391+
'x-file-name': encodeLabel(s.label + '.json'),
392+
'x-label': encodeLabel(s.label),
390393
'Content-Type': 'application/json'
391394
},
392395
body: encoded,

cli/eta-flash-tool/flashtool.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ let configFactory = new Config();
5757
/* noop */
5858
}
5959

60-
let deviceId = await findSerial();
60+
let deviceId = await findSerial(undefined);
6161
await connectToSerial(deviceId);
6262
}
6363
catch (ex) {

cli/find-serial.ts

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ function sleep(ms: number) {
77
return new Promise((res) => setTimeout(res, ms));
88
}
99

10-
export async function findSerial() {
10+
export async function findSerial(whichDeviceIndex: number | undefined) {
1111
let filteredDevices;
1212
while (1) {
1313
let allDevices = await SerialConnector.list();
@@ -39,6 +39,13 @@ export async function findSerial() {
3939
let deviceId = filteredDevices[0].path;
4040

4141
if (filteredDevices.length > 1) {
42+
if (typeof whichDeviceIndex === 'number') {
43+
if (!filteredDevices[whichDeviceIndex]) {
44+
throw new Error('--which-device index was not found');
45+
}
46+
return filteredDevices[whichDeviceIndex].path;
47+
}
48+
4249
let deviceRes = <{ device: string }>await inquirer.prompt([{
4350
type: 'list',
4451
choices: filteredDevices.map(d => ({

cli/himax-flash-tool/flashtool.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ let configFactory = new Config();
5757
/* noop */
5858
}
5959

60-
let deviceId = await findSerial();
60+
let deviceId = await findSerial(undefined);
6161
await connectToSerial(deviceId);
6262
}
6363
catch (ex) {

0 commit comments

Comments
 (0)