Skip to content

Commit

Permalink
IoTScape Improvements (#205)
Browse files Browse the repository at this point in the history
* Copy over old changes

* Fix code formatting

* Fix typo and include other change

* Fix code formatting

* Fix missing methods

* Fix code formatting

* fix sending

* Fix code formatting

* Fix set key behavior

* Setup to allow "set client rate" and "set total rate"

* Fix code formatting

* Improve comment

* Sequence numbers working

* Fix code formatting

* Rate limiting

* Fix code formatting

* Send client IDs

* Fix code formatting

* Send service name with message

* HTTP announce endpoint

* Allow "lite" announce

* Fix code formatting

* Fix to function info

* Fix code formatting

* Send device messages

* Take methods out of "basic" category

* Route for HTTP responses to IoTScape messages

* Fix code formatting

* Symmetric

---------

Co-authored-by: Format Bot <[email protected]>
  • Loading branch information
gsteinLTU and Format Bot authored Aug 5, 2024
1 parent 1a3a0d5 commit 6bfe78d
Show file tree
Hide file tree
Showing 6 changed files with 1,100 additions and 256 deletions.
33 changes: 27 additions & 6 deletions src/community/device-service.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
const createLogger = require("../procedures/utils/logger");
const IoTScapeServices = require("../procedures/iotscape/iotscape-services");
const IoTScapeDevices = require("../procedures/iotscape/iotscape-devices");
const IoTScape = require("../procedures/iotscape/iotscape");

/**
* Represents a service created for a IoTScape device
Expand All @@ -24,12 +26,13 @@ class DeviceService {

this._docs = {
description: record.description,
categories: [["Community", "Device"]],
categories: [["Community", "Devices"], ["Devices", "Community"]],
getDocFor: (method) => {
let m = record.methods.find((val) => val.name == method);
return {
name: m.name,
description: m.documentation,
categories: m.categories,
args: m.arguments.map((argument) => ({
name: argument.name,
optional: argument.optional,
Expand All @@ -41,10 +44,10 @@ class DeviceService {
}

async _initializeRPC(methodSpec) {
// getDevices and listen have special implementations
// Default methods have special implementations
if (methodSpec.name === "getDevices") {
this[methodSpec.name] = async function () {
return IoTScapeServices.getDevices(this.serviceName);
return IoTScapeDevices.getDevices(this.serviceName);
};
} else if (methodSpec.name === "listen") {
this[methodSpec.name] = async function () {
Expand All @@ -54,12 +57,30 @@ class DeviceService {
...arguments,
);
};
} else if (methodSpec.name === "send") {
this[methodSpec.name] = async function () {
return IoTScape._send(
this.serviceName,
arguments[0],
arguments[1],
this.caller,
);
};
} else if (methodSpec.name === "getMessageTypes") {
this[methodSpec.name] = async function () {
return IoTScapeServices.getMessageTypes(this.serviceName);
};
} else if (methodSpec.name === "getMethods") {
this[methodSpec.name] = async function () {
return IoTScapeServices.getMethods(this.serviceName);
};
} else {
this[methodSpec.name] = async function () {
return await IoTScapeServices.call(
return await IoTScape._send(
this.serviceName,
methodSpec.name,
...arguments,
arguments[0],
[methodSpec.name, ...Object.values(arguments).splice(1)].join(" "),
this.caller,
);
};
}
Expand Down
Loading

0 comments on commit 6bfe78d

Please sign in to comment.