Skip to content

Commit

Permalink
Merge pull request #5 from srenauld/gateway-data-fixes
Browse files Browse the repository at this point in the history
Gateway `ws` event clarification fixes
  • Loading branch information
srenauld authored Oct 26, 2019
2 parents 3c7c060 + d937c1b commit 4d2dc26
Show file tree
Hide file tree
Showing 5 changed files with 959 additions and 44 deletions.
20 changes: 16 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -97,15 +97,27 @@ delivery. The following snippet highlights both of those:
import SDK from 'loriot-sdk';
let client = SDK({
server: 'eu2',
applicationId: 'foo',
token: 'bar'
token: {
applicationId: 'foo',
id: 'bar'
}
});

client.Data.device('FOOBAR', async (message) => {
let data = await client.Data;
data.device('FOOBAR', async (message) => {
console.log("Received message for device EUI FOOBAR");
// We're going to send a confirmed message
await client.Data.send("FOOBAR", "01", true);
})
});
// You can also listen for events related to a sensor as picked up by
// a gateway:
data.gateway('FOOBAR', async (message) => {
console.log('Received gateway message for device EUI FOOBAR');
});
// Or for all gateways
data.all_events(async (message) => {
console.log('Received gateway event')
});

Websocket reconnection is handled internally; do not forget to call
`close()`. A limit of one connection attempt per second is also built in,
Expand Down
Loading

0 comments on commit 4d2dc26

Please sign in to comment.