-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #9 from SmartParksOrg/dev
~Stable V1.1.1
- Loading branch information
Showing
22 changed files
with
16,700 additions
and
2,331 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
import testHelper, { TestFlowsItem } from "node-red-node-test-helper"; | ||
import chirpstackNetworkServerNode from "../nodes/chirpstack-network-server/chirpstack-network-server"; | ||
import { ChirpstackNetworkServerNodeDef } from "../nodes/chirpstack-network-server/modules/types"; | ||
|
||
type FlowsItem = TestFlowsItem<ChirpstackNetworkServerNodeDef>; | ||
type Flows = Array<FlowsItem>; | ||
|
||
describe("chirpstack-network-server node", () => { | ||
beforeEach((done) => { | ||
testHelper.startServer(done); | ||
}); | ||
|
||
afterEach((done) => { | ||
testHelper.unload().then(() => { | ||
testHelper.stopServer(done); | ||
}); | ||
}); | ||
|
||
it("should be loaded", (done) => { | ||
const flows: Flows = [ | ||
{ | ||
id: "n1", | ||
type: "chirpstack-network-server", | ||
name: "chirpstack-network-server", | ||
}, | ||
]; | ||
testHelper.load(chirpstackNetworkServerNode, flows, () => { | ||
const n1 = testHelper.getNode("n1"); | ||
expect(n1).toBeTruthy(); | ||
expect(n1.name).toEqual("chirpstack-network-server"); | ||
done(); | ||
}); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
16 changes: 16 additions & 0 deletions
16
src/nodes/chirpstack-network-server/chirpstack-network-server.html/editor.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
<script type="text/html" data-template-name="chirpstack-network-server"> | ||
<div class="form-row"> | ||
<label for="node-input-name"><i class="fa fa-tag"></i> Name</label> | ||
<input type="text" id="node-input-name" placeholder="Name"> | ||
</div> | ||
<div class="form-row"> | ||
<label for="node-input-connection"><i class="fa fa-desktop"></i> Connection</label> | ||
<input type="text" id="node-input-connection"> | ||
</div> | ||
<div class="form-row"> | ||
<label for="node-input-action"><i class="fa fa-download"></i> Action</label> | ||
<select id="node-input-action"> | ||
<option value="createMacReq">Create Mac Request</option> | ||
</select> | ||
</div> | ||
</script> |
3 changes: 3 additions & 0 deletions
3
src/nodes/chirpstack-network-server/chirpstack-network-server.html/help.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
<script type="text/html" data-help-name="chirpstack-network-server"> | ||
<p>Node description goes here.</p> | ||
</script> |
24 changes: 24 additions & 0 deletions
24
src/nodes/chirpstack-network-server/chirpstack-network-server.html/index.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
import { EditorRED } from "node-red"; | ||
import { ChirpstackNetworkServerEditorNodeProperties } from "./modules/types"; | ||
|
||
declare const RED: EditorRED; | ||
|
||
RED.nodes.registerType<ChirpstackNetworkServerEditorNodeProperties>( | ||
"chirpstack-network-server", | ||
{ | ||
category: "chirpstack", | ||
color: "#2094f3", | ||
defaults: { | ||
connection: { value: "", type: "chirpstack-connection" }, | ||
name: { value: "" }, | ||
action: { value: "createMacReq" }, | ||
}, | ||
inputs: 1, | ||
outputs: 1, | ||
icon: "chirpstack.png", | ||
paletteLabel: "ChirpStack network server requests", | ||
label() { | ||
return this.name || "ChirpStack network server requests"; | ||
}, | ||
} | ||
); |
6 changes: 6 additions & 0 deletions
6
src/nodes/chirpstack-network-server/chirpstack-network-server.html/modules/types.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
import { EditorNodeProperties } from "node-red"; | ||
import { ChirpstackNetworkServerOptions } from "../../shared/types"; | ||
|
||
export interface ChirpstackNetworkServerEditorNodeProperties | ||
extends EditorNodeProperties, | ||
ChirpstackNetworkServerOptions {} |
79 changes: 79 additions & 0 deletions
79
src/nodes/chirpstack-network-server/chirpstack-network-server.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,79 @@ | ||
import { NodeInitializer } from "node-red"; | ||
import { | ||
ChirpstackNetworkServerNode, | ||
ChirpstackNetworkServerNodeDef, | ||
} from "./modules/types"; | ||
import { setConnection } from "../shared/setConnection"; | ||
import grpc from "grpc"; | ||
import { CreateMACCommandQueueItemRequest } from "@chirpstack/chirpstack-api/ns/ns_pb"; | ||
import { NetworkServerServiceClient } from "@chirpstack/chirpstack-api/ns/ns_grpc_pb"; | ||
|
||
const nodeInit: NodeInitializer = (RED): void => { | ||
function ChirpstackNetworkServerNodeConstructor( | ||
this: ChirpstackNetworkServerNode, | ||
config: ChirpstackNetworkServerNodeDef | ||
): void { | ||
RED.nodes.createNode(this, config); | ||
this.chirpstackConnection = setConnection(this, config, RED); | ||
this.on("input", () => { | ||
this.chirpstackConnection = setConnection(this, config, RED); | ||
}); | ||
|
||
switch (config.action) { | ||
case "createMacReq": | ||
createMacRequest(this); | ||
break; | ||
default: | ||
this.on("input", (msg, send, done) => { | ||
this.error("no action selected"); | ||
msg.payload = undefined; | ||
send(msg); | ||
done(); | ||
}); | ||
break; | ||
} | ||
} | ||
|
||
function createMacRequest(node: ChirpstackNetworkServerNode): void { | ||
node.on("input", (msg, send, done) => { | ||
const createMACCommandQueueItemRequest = new CreateMACCommandQueueItemRequest(); | ||
//eslint-disable-next-line @typescript-eslint/no-explicit-any | ||
const inputParams: any = msg.payload; | ||
|
||
createMACCommandQueueItemRequest.setCid(inputParams.cid); // number | ||
createMACCommandQueueItemRequest.setCommandsList( | ||
inputParams.commandsList | ||
); // [string] | ||
createMACCommandQueueItemRequest.setDevEui(inputParams.devEui); // string | ||
//createMACCommandQueueItemRequest.setExtension() | ||
|
||
new NetworkServerServiceClient( | ||
node.chirpstackConnection.fullAddress, | ||
grpc.credentials.createInsecure() | ||
).createMACCommandQueueItem( | ||
createMACCommandQueueItemRequest, | ||
node.chirpstackConnection.grpcMetadata, | ||
null, | ||
(error, emptyResponse) => { | ||
if (error) { | ||
node.error(error); | ||
msg.payload = error; | ||
send(msg); | ||
done(); | ||
return; | ||
} | ||
msg.payload = emptyResponse?.toObject(); | ||
send(msg); | ||
done(); | ||
} | ||
); | ||
}); | ||
} | ||
|
||
RED.nodes.registerType( | ||
"chirpstack-network-server", | ||
ChirpstackNetworkServerNodeConstructor | ||
); | ||
}; | ||
|
||
export = nodeInit; |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
import { ChirpstackBaseNode, ChirpstackBaseNodeDef } from "../../shared/types"; | ||
import { ChirpstackNetworkServerOptions } from "../shared/types"; | ||
|
||
export interface ChirpstackNetworkServerNodeDef | ||
extends ChirpstackBaseNodeDef, | ||
ChirpstackNetworkServerOptions {} | ||
|
||
// export interface ChirpstackNetworkServerNode extends ChirpstackBaseNode {} | ||
export type ChirpstackNetworkServerNode = ChirpstackBaseNode; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
export interface ChirpstackNetworkServerOptions { | ||
connection: string; | ||
action: string; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.