pxt-common-packages 9.3.6 → 9.3.10
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/libs/azureiot/azureiot.ts +15 -8
- package/libs/azureiot/built/debug/binary.js +461 -461
- package/libs/color/built/debug/binary.js +8 -8
- package/libs/core---esp32/pxt.h +2 -0
- package/libs/core---esp32/usb.cpp +43 -18
- package/libs/core---esp32/worker.cpp +8 -0
- package/libs/core---vm/vm.cpp +15 -8
- package/libs/game/built/debug/binary.js +6470 -6470
- package/libs/matrix-keypad/built/debug/binary.js +8 -8
- package/libs/mqtt/built/debug/binary.js +84 -84
- package/libs/mqtt/mqtt.ts +88 -23
- package/libs/palette/built/debug/binary.js +6469 -6469
- package/libs/radio/built/debug/binary.js +8 -8
- package/libs/radio-broadcast/built/debug/binary.js +8 -8
- package/libs/rotary-encoder/built/debug/binary.js +8 -8
- package/libs/storyboard/built/debug/binary.js +6469 -6469
- package/libs/wifi---esp32/controller.ts +2 -3
- package/libs/wifi---esp32/socket.cpp +4 -2
- package/package.json +1 -1
|
@@ -17,6 +17,7 @@ namespace azureiot {
|
|
|
17
17
|
let _messageBusId: number;
|
|
18
18
|
let _receiveHandler: (msg: Json, sysProps: SMap<string>) => void;
|
|
19
19
|
let _methodHandlers: SMap<(msg: Json) => Json>;
|
|
20
|
+
let twinRespHandlers: SMap<(status: number, body: any) => void>
|
|
20
21
|
|
|
21
22
|
function log(msg: string) {
|
|
22
23
|
console.add(logPriority, "azureiot: " + msg);
|
|
@@ -156,7 +157,6 @@ namespace azureiot {
|
|
|
156
157
|
}
|
|
157
158
|
catch {
|
|
158
159
|
// just ignore errors disconnecting
|
|
159
|
-
_mqttClient = undefined
|
|
160
160
|
}
|
|
161
161
|
}
|
|
162
162
|
}
|
|
@@ -167,6 +167,7 @@ namespace azureiot {
|
|
|
167
167
|
export function connect() {
|
|
168
168
|
const c = mqttClient();
|
|
169
169
|
if (!c.connected) {
|
|
170
|
+
c.connect() // start connect if not started yet
|
|
170
171
|
// busy wait for connection
|
|
171
172
|
const start = control.millis()
|
|
172
173
|
const timeout = 30000
|
|
@@ -249,11 +250,17 @@ namespace azureiot {
|
|
|
249
250
|
topic += encodeQuery(sysProps);
|
|
250
251
|
if (len == null)
|
|
251
252
|
len = msg.length
|
|
253
|
+
if (len > msg.length) {
|
|
254
|
+
log(`len too long: ${len}/${msg.length}`)
|
|
255
|
+
len = msg.length
|
|
256
|
+
}
|
|
252
257
|
// qos, retained are not supported
|
|
253
|
-
c.startPublish(topic, len * 2)
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
258
|
+
if (c.startPublish(topic, len * 2)) {
|
|
259
|
+
const chunk = 128
|
|
260
|
+
for (let ptr = 0; ptr < len; ptr += chunk)
|
|
261
|
+
c.continuePublish(Buffer.fromUTF8(msg.slice(ptr, Math.min(chunk, len - ptr)).toHex()))
|
|
262
|
+
c.finishPublish()
|
|
263
|
+
}
|
|
257
264
|
}
|
|
258
265
|
|
|
259
266
|
/**
|
|
@@ -313,16 +320,16 @@ namespace azureiot {
|
|
|
313
320
|
c.publish('$iothub/methods/res/' + status + "/?$rid=" + props["$rid"], JSON.stringify(resp))
|
|
314
321
|
}
|
|
315
322
|
|
|
316
|
-
let twinRespHandlers: SMap<(status: number, body: any) => void>
|
|
317
|
-
|
|
318
323
|
// $iothub/twin/res/{status}/?$rid={request id}
|
|
319
324
|
function twinResponse(msg: mqtt.IMessage) {
|
|
320
325
|
const args = parseTopicArgs(msg.topic)
|
|
321
326
|
const h = twinRespHandlers[args["$rid"]]
|
|
322
327
|
const status = parseInt(msg.topic.slice(17))
|
|
323
328
|
// log(`twin resp: ${status} ${msg.content.toHex()} ${msg.content.toString()}`)
|
|
324
|
-
if (h)
|
|
329
|
+
if (h) {
|
|
330
|
+
delete twinRespHandlers[args["$rid"]]
|
|
325
331
|
h(status, JSON.parse(msg.content.toString() || "{}"))
|
|
332
|
+
}
|
|
326
333
|
}
|
|
327
334
|
|
|
328
335
|
export class ValueAwaiter {
|