Skip to content
This repository was archived by the owner on Aug 5, 2022. It is now read-only.
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
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -360,7 +360,7 @@ upload the K64F [hello world application](https://developer.mbed.org/platforms/F
Then, you could try the Zephyr OS `hello_world` sample to narrow down the
problem:
```bash
cd deps/zephyr/samples/hello_world/nanokernel
cd deps/zephyr/samples/hello_world/
make pristine && make BOARD=frdm_k64f
cp outdir/frdm_k64f/zephyr.bin /media/<USERNAME>/MBED/
```
Expand Down
2 changes: 1 addition & 1 deletion docs/console.md
Original file line number Diff line number Diff line change
Expand Up @@ -54,4 +54,4 @@ difference to `stdout`.

Sample Apps
-----------
* [Console sample](../samples/Console.js)
* [Console sample](../samples/tests/Console.js)
46 changes: 46 additions & 0 deletions samples/OcfSensorClient.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
// Copyright (c) 2017, Intel Corporation.

// Sample client that works with OcfSensorServer.js

var client = require('ocf').client;

console.log("Started OCF client");

client.on('error', function(error) {
if (error.deviceId)
console.log("Error for device: " + error.deviceId);
});

function onupdate(resource) {
console.log("Resource updated:");
console.log(" deviceId: " + resource.deviceId);
console.log(" resourcePath: " + resource.resourcePath);
if (resource.properties != undefined) {
console.log("Resource property 'sensor' is " + resource.properties.sensor);
} else {
console.log("resource.properties not found");
}
}

client.on('update', onupdate);

var lightOn = true;

// TODO: Must save away the timer handle or else GC will destroy it after a few iterations
var t1 = null;

function onfound(resource) {
t1 = setInterval(function() {
client.retrieve(resource.deviceId, { observable: false }).then(function(res) {
console.log("retrieve() was successful, deviceId=" + res.deviceId);
}).catch(function(error) {
console.log("retrieve() returned an error: " + error.name);
});
}, 1000);
}

client.findResources({ resourceType:"core.sensor" }, onfound).then(function(resource) {
console.log("findResources() was successful, deviceId=" + resource.deviceId);
}).catch(function(error) {
console.log("findResources() returned an error: " + error.name);
});