wearscript / wearscript-android

JavaScript with Batteries Included for Google Glass
wearscript.com
216 stars 55 forks source link

BTLE Support #225

Closed kurtisnelson closed 10 years ago

kurtisnelson commented 10 years ago

I know discover works fine, but I'm not sure about read as I don't have any good devices here.

<html style="width:100%; height:100%; overflow:hidden">
<head>
<!-- You can include external scripts here like so... -->
<!--<script src="https://cdnjs.cloudflare.com/ajax/libs/zepto/1.0/zepto.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/underscore.js/1.5.2/underscore-min.js"></script>-->
</head>
<body style="width:100%; height:100%; overflow:hidden; margin:0" bgcolor="#000">
<canvas id="canvas" width="640" height="360" style="display:block"></canvas>
<script>
function server() {
    WS.log('Welcome to WearScript');
    WS.say('Welcome to WearScript');

    WS.sensorOn("btle", 1);

    WS.subscribe("btle", function(name, address) {
        WS.log(name + "@" + address);
        WS.sensorOff();
        WSRAW.bluetoothLeRead(address, function(data) {
            WS.log("got data: " + data);
        })
    })

}
function main() {
    if (WS.scriptVersion(1)) return;
    ctx = document.getElementById('canvas').getContext("2d");
    WS.serverConnect('{{WSUrl}}', server);
}
window.onload = main;
</script>
</body>
</html>
bwhite commented 10 years ago

I think it shouldn't be part of the sensor stack (WS.sensorOn), it should have it's own commands.

On Fri, May 9, 2014 at 11:13 AM, Kurt Nelson notifications@github.comwrote:

I know discover works fine, but I'm not sure about read as I don't have any good devices here.


You can merge this Pull Request by running

git pull https://github.com/kurtisnelson/wearscript-android ble

Or view, comment on, or merge it at:

https://github.com/wearscript/wearscript-android/pull/225 Commit Summary

  • Add iBeacon library and ws manager
  • Add iBeacon service
  • Instantiate iBeacon service if we have btle support
  • Add subscription for iBeacons
  • Use ranging for multiple iBeacons
  • Manifest merging renders unneeded
  • Turn on ibeacons as a sensor, and add enter region callbacks
  • Give useful data
  • Put UUID in the channel
  • Beacon stability
  • /me slaps connerb around with a trout
  • support for loading script from assets in custom package
  • Merge pull request #221 from scottgwald/apk-assets
  • Merge pull request #215 from kurtisnelson/ibeacons
  • Add BTLE support

File Changes

  • M WearScript/build.gradlehttps://github.com/wearscript/wearscript-android/pull/225/files#diff-0(6)
  • A WearScript/libs/AndroidIBeaconLibrary-0.7.6.aarhttps://github.com/wearscript/wearscript-android/pull/225/files#diff-1(0)
  • M WearScript/src/main/AndroidManifest.xmlhttps://github.com/wearscript/wearscript-android/pull/225/files#diff-2(3)
  • M WearScript/src/main/java/com/dappervision/wearscript/BackgroundService.javahttps://github.com/wearscript/wearscript-android/pull/225/files#diff-3(26)
  • M WearScript/src/main/java/com/dappervision/wearscript/Utils.javahttps://github.com/wearscript/wearscript-android/pull/225/files#diff-4(5)
  • M WearScript/src/main/java/com/dappervision/wearscript/WearScript.javahttps://github.com/wearscript/wearscript-android/pull/225/files#diff-5(8)
  • A WearScript/src/main/java/com/dappervision/wearscript/dataproviders/BTLEDataProvider.javahttps://github.com/wearscript/wearscript-android/pull/225/files#diff-6(10)
  • A WearScript/src/main/java/com/dappervision/wearscript/dataproviders/IBeaconDataProvider.javahttps://github.com/wearscript/wearscript-android/pull/225/files#diff-7(10)
  • M WearScript/src/main/java/com/dappervision/wearscript/launcher/MainActivity.javahttps://github.com/wearscript/wearscript-android/pull/225/files#diff-8(10)
  • A WearScript/src/main/java/com/dappervision/wearscript/managers/BluetoothLEManager.javahttps://github.com/wearscript/wearscript-android/pull/225/files#diff-9(137)
  • M WearScript/src/main/java/com/dappervision/wearscript/managers/DataManager.javahttps://github.com/wearscript/wearscript-android/pull/225/files#diff-10(6)
  • A WearScript/src/main/java/com/dappervision/wearscript/managers/IBeaconManager.javahttps://github.com/wearscript/wearscript-android/pull/225/files#diff-11(133)
  • M WearScript/src/main/java/com/dappervision/wearscript/managers/ManagerManager.javahttps://github.com/wearscript/wearscript-android/pull/225/files#diff-12(5)

Patch Links:

— Reply to this email directly or view it on GitHubhttps://github.com/wearscript/wearscript-android/pull/225 .

kurtisnelson commented 10 years ago

New syntax https://gist.github.com/kurtisnelson/6cde29c0a2202840034a