Skip to content
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

Fix tethering inet bugs, introduce a few new nodes and five new chapters of tutorial #1998

Merged
merged 10 commits into from
Jul 9, 2020
Merged
Show file tree
Hide file tree
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
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ const splitDataOnChunks = R.curry((maxChunkSize, nodeId, data) => {
R.compose(
R.map(formatChunk),
R.splitEvery(dataMaxLength),
R.slice(R.__, -1, data),
R.slice(R.__, data.length, data),
R.add(1),
R.indexOf(':')
),
Expand All @@ -73,6 +73,15 @@ const createListener = (dispatch, transmit, nodeId) =>

const isReadOkResponse = R.startsWith(ACK);

// In case that the connection is closed before than all request has been received
// there is no reason to continue sending the response data.
const clearQueueOnCloseConnection = R.curry((dispatch, command) =>
R.when(
R.equals('AT+CIPCLOSE'),
R.compose(dispatch, client.tetheringInetClearChunks)
)(command)
);

export default ({ getState, dispatch }) => next => action => {
const state = getState();
const result = next(action);
Expand All @@ -86,7 +95,10 @@ export default ({ getState, dispatch }) => next => action => {
const worker = action.payload.worker;
const transmit = createTransmitter(dispatch, worker.sendToWasm);
const listener = createListener(dispatch, transmit, nodeId);
const write = AtNet.create(listener);
const write = R.compose(
AtNet.create(listener),
R.tap(clearQueueOnCloseConnection(dispatch))
);
dispatch(
client.tetheringInetCreated(
action.payload.tetheringInetNodeId,
Expand Down
2 changes: 2 additions & 0 deletions packages/xod-client/src/debugger/actionTypes.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,3 +31,5 @@ export const TETHERING_INET_CREATED = 'TETHERING_INET_CREATED';
export const TETHERING_INET_CHUNKS_ADDED = 'TETHERING_INET_CHUNKS_ADDED';

export const TETHERING_INET_CHUNK_SENT = 'TETHERING_INET_CHUNK_SENT';

export const TETHERING_INET_CLEAR_CHUNKS = 'TETHERING_INET_CLEAR_CHUNKS';
4 changes: 4 additions & 0 deletions packages/xod-client/src/debugger/actions.js
Original file line number Diff line number Diff line change
Expand Up @@ -106,3 +106,7 @@ export const tetheringInetChunkSent = () => (dispatch, getState) => {
});
return maybeProp(0, chunksToSend);
};

export const tetheringInetClearChunks = () => ({
type: AT.TETHERING_INET_CLEAR_CHUNKS,
});
3 changes: 3 additions & 0 deletions packages/xod-client/src/debugger/reducer.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ import {
TETHERING_INET_CREATED,
TETHERING_INET_CHUNKS_ADDED,
TETHERING_INET_CHUNK_SENT,
TETHERING_INET_CLEAR_CHUNKS,
} from './actionTypes';

import * as EAT from '../editor/actionTypes';
Expand Down Expand Up @@ -531,6 +532,8 @@ export default (state = initialState, action) => {
R.tail,
state
);
case TETHERING_INET_CLEAR_CHUNKS:
return R.assocPath(['tetheringInet', 'chunksToSend'], [], state);

case EAT.TABTEST_RUN_REQUESTED:
return R.compose(
Expand Down
80 changes: 80 additions & 0 deletions workspace/__lib__/xod-cloud/basics/example-external-ip/patch.xodp
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
{
"links": [
{
"id": "BJhT-HrnU",
"input": {
"nodeId": "ByZV6-BShI",
"pinKey": "HkXK-dGob"
},
"output": {
"nodeId": "HJtT-SSnU",
"pinKey": "Syv_rWrSn8"
}
},
{
"id": "rJoTbrB38",
"input": {
"nodeId": "HJtT-SSnU",
"pinKey": "BJluSWHrhU"
},
"output": {
"nodeId": "rkzVpbHr38",
"pinKey": "Bkf4BDsmV"
}
},
{
"id": "ry5TZBS2I",
"input": {
"nodeId": "HJtT-SSnU",
"pinKey": "B1OS-rS3I"
},
"output": {
"nodeId": "SJx4pbHrn8",
"pinKey": "SyveJHHBL"
}
}
],
"nodes": [
{
"id": "ByZV6-BShI",
"position": {
"units": "slots",
"x": 1,
"y": 2
},
"size": {
"height": 1,
"units": "slots",
"width": 4
},
"type": "xod/debug/watch"
},
{
"id": "HJtT-SSnU",
"position": {
"units": "slots",
"x": 1,
"y": 1
},
"type": "@/external-ip"
},
{
"id": "SJx4pbHrn8",
"position": {
"units": "slots",
"x": 1,
"y": 0
},
"type": "xod/debug/tethering-inet"
},
{
"id": "rkzVpbHr38",
"position": {
"units": "slots",
"x": 2,
"y": 0
},
"type": "xod/debug/tweak-pulse"
}
]
}
80 changes: 80 additions & 0 deletions workspace/__lib__/xod-cloud/basics/example-now-iso/patch.xodp
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
{
"links": [
{
"id": "B1G_6NBnI",
"input": {
"nodeId": "ryZupVrn8",
"pinKey": "Sywf6EBhU"
},
"output": {
"nodeId": "SkghDaVShL",
"pinKey": "SyveJHHBL"
}
},
{
"id": "H1mO64S38",
"input": {
"nodeId": "ryZupVrn8",
"pinKey": "rJlwfT4r2I"
},
"output": {
"nodeId": "Bkm3w6Vr3I",
"pinKey": "Bkf4BDsmV"
}
},
{
"id": "ry4uTErnI",
"input": {
"nodeId": "SkM3va4BhI",
"pinKey": "HkXK-dGob"
},
"output": {
"nodeId": "ryZupVrn8",
"pinKey": "r1jBTESnU"
}
}
],
"nodes": [
{
"id": "Bkm3w6Vr3I",
"position": {
"units": "slots",
"x": 4,
"y": 0
},
"type": "xod/debug/tweak-pulse"
},
{
"id": "SkM3va4BhI",
"position": {
"units": "slots",
"x": 3,
"y": 2
},
"size": {
"height": 1,
"units": "slots",
"width": 4
},
"type": "xod/debug/watch"
},
{
"id": "SkghDaVShL",
"position": {
"units": "slots",
"x": 3,
"y": 0
},
"type": "xod/debug/tethering-inet"
},
{
"id": "ryZupVrn8",
"position": {
"units": "slots",
"x": 3,
"y": 1
},
"type": "@/now-iso"
}
]
}
103 changes: 103 additions & 0 deletions workspace/__lib__/xod-cloud/basics/example-now/patch.xodp
Original file line number Diff line number Diff line change
@@ -0,0 +1,103 @@
{
"links": [
{
"id": "B17fLq838",
"input": {
"nodeId": "HyFcVVrnI",
"pinKey": "Hy_D4G0JOX"
},
"output": {
"nodeId": "Hk0-UcL3L",
"pinKey": "ryFe8qI3U"
}
},
{
"id": "ByA9NES2L",
"input": {
"nodeId": "HJicVES38",
"pinKey": "HkXK-dGob"
},
"output": {
"nodeId": "HyFcVVrnI",
"pinKey": "BkvDEzR1Om"
}
},
{
"id": "SkJfI9LhL",
"input": {
"nodeId": "Hk0-UcL3L",
"pinKey": "r1lFErc828"
},
"output": {
"nodeId": "H16KVNBhL",
"pinKey": "SyveJHHBL"
}
},
{
"id": "rJCCZq0h8",
"input": {
"nodeId": "Hk0-UcL3L",
"pinKey": "HyF4Hq828"
},
"output": {
"nodeId": "B1nAW5C2U",
"pinKey": "Bkf4BDsmV"
}
}
],
"nodes": [
{
"id": "B1nAW5C2U",
"position": {
"units": "slots",
"x": 5,
"y": 1
},
"type": "xod/debug/tweak-pulse"
},
{
"id": "H16KVNBhL",
"position": {
"units": "slots",
"x": 4,
"y": 1
},
"type": "xod/debug/tethering-inet"
},
{
"id": "HJicVES38",
"position": {
"units": "slots",
"x": 4,
"y": 4
},
"size": {
"height": 1,
"units": "slots",
"width": 4
},
"type": "xod/debug/watch"
},
{
"boundLiterals": {
"HyF4Hq828": "Never"
},
"id": "Hk0-UcL3L",
"position": {
"units": "slots",
"x": 4,
"y": 2
},
"type": "@/now"
},
{
"id": "HyFcVVrnI",
"position": {
"units": "slots",
"x": 4,
"y": 3
},
"type": "xod/datetime/format-timestamp"
}
]
}
Loading