Sorry I forgot to attach my code for reference. Please find below.
var accelOn = false; var batteryLevel = Puck.getBatteryPercentage(); NRF.nfcURL("Puck.js 9e03"); setWatch(function() { if (accelOn) { Puck.accelOff(); accelOn = false; NRF.nfcRaw(new Uint8Array([193, 1, 0, 0, 0, 13, 85, 3, 80, 117, 99, 107, 46, 106, 115, 32, 57, 101, 48, 51])); batteryLevel = Puck.getBatteryPercentage(); } else { Puck.accelOn(1660); accelOn = true; } }, BTN, {edge:"rising", repeat:1, debounce:20}); NRF.setServices({ 0x2713: { "e482a929-e02a-4e8a-8296-cca819ebe0c6": { value: String(Puck.getTemperature()), maxLen: 20, broadcast: true, // optional, default is false readable: true, // optional, default is false writable: false, // optional, default is false notify: true, // optional, default is false indicate: true, // optional, default is false description: "Accelerometer X", // optional, default is null, }, "cad35f0b-8a1a-442c-b249-4698e582fcf4": { value: String(Puck.getTemperature()), maxLen: 20, broadcast: true, // optional, default is false readable: true, // optional, default is false writable: false, // optional, default is false notify: true, // optional, default is false indicate: true, // optional, default is false description: "Accelerometer Y", // optional, default is null, }, "4249a4c7-9a03-428d-818a-24a7c5aefb4a": { value: String(Puck.getTemperature()), maxLen: 20, broadcast: true, // optional, default is false readable: true, // optional, default is false writable: false, // optional, default is false notify: true, // optional, default is false indicate: true, // optional, default is false description: "Accelerometer Z", // optional, default is null, }, "54e832b7-714e-4aa5-ada9-e21dd2006844": { value: String(Puck.getTemperature()), maxLen: 20, broadcast: true, // optional, default is false readable: true, // optional, default is false writable: false, // optional, default is false notify: true, // optional, default is false indicate: true, // optional, default is false description: "Gyroscope X", // optional, default is null, }, "cbbb698d-878e-473a-9625-fbe0243ac8e1": { value: String(Puck.getTemperature()), maxLen: 20, broadcast: true, // optional, default is false readable: true, // optional, default is false writable: false, // optional, default is false notify: true, // optional, default is false indicate: true, // optional, default is false description: "Gyroscope Y", // optional, default is null, }, "6db27825-05fa-4984-9fed-568edd9f1fe8": { value: String(Puck.getTemperature()), maxLen: 20, broadcast: true, // optional, default is false readable: true, // optional, default is false writable: false, // optional, default is false notify: true, // optional, default is false indicate: true, // optional, default is false description: "Gyroscope Z", // optional, default is null, }, "1bdf76b4-006a-4e20-8a09-fb87b8f4b29d": { value: String(batteryLevel), maxLen: 20, broadcast: true, // optional, default is false readable: true, // optional, default is false writable: false, // optional, default is false notify: true, // optional, default is false indicate: true, // optional, default is false description: "Battery Level", // optional, default is null, } } }); NRF.setAdvertising({ 0x2713: undefined }); Puck.on('accel', function(a) { NRF.updateServices({ 0x2713: { "e482a929-e02a-4e8a-8296-cca819ebe0c6": { value: String(a.acc.x), notify: true, readable: true }, "cad35f0b-8a1a-442c-b249-4698e582fcf4": { value: String(a.acc.y), notify: true, readable: true }, "4249a4c7-9a03-428d-818a-24a7c5aefb4a": { value: String(a.acc.z), notify: true, readable: true }, "54e832b7-714e-4aa5-ada9-e21dd2006844": { value: String(a.gyro.x), notify: true, readable: true }, "cbbb698d-878e-473a-9625-fbe0243ac8e1": { value: String(a.gyro.y), notify: true, readable: true }, "6db27825-05fa-4984-9fed-568edd9f1fe8": { value: String(a.gyro.z), notify: true, readable: true }, "1bdf76b4-006a-4e20-8a09-fb87b8f4b29d": { value: String(batteryLevel), notify: true, readable: true } } }); });
@mc9311 started
Espruino is a JavaScript interpreter for low-power Microcontrollers. This site is both a support community for Espruino and a place to share what you are working on.
Sorry I forgot to attach my code for reference. Please find below.