1.0.0-alpha.12 • Published 5 years ago

@kano/devices-sdk-uwp v1.0.0-alpha.12

Weekly downloads
1
License
ISC
Repository
github
Last release
5 years ago

@kano/devices-sdk-uwp

UWP implementation of the Kano devices SDK. Uses the JS UWP bindings to access the Windows Bluetooth API. Use in your JS UWP projects.

Usage

Create a new project in Visual Studio, choose Javascript > Progressive Web App.

Open the package.appxmanifest file and set the main URL to the URl of your web server. Make sure you enable Bluetooth in the Capabilities.

In a JS module in your project, insert the following (You must have server side module resolution or bundling):

import Devices from '@kano/devices-sdk-uwp/index.js';

Devices.searchForClosestDevice('wand', 5000)
    .then((dev) => {
        return dev.getSoftwareVersion()
            .then((v) => {
                console.log(v);
                return dev.setLed(1, 0x00ff00);
            })
            .then(dev.getAdvertisementName())
            .then((name) => {
                console.log(name)
                dev.on('position', (p) => {
                    console.log(p)
                });
                return dev.subscribePosition();
            });
    })
    .catch(e => console.error(e.message));

Demo

To run the demo, start the web server with node ./demo/wand/server.js. Then open the solution KanoDevicesSdk.sln in visual studio and start the project on your local machine.