user100558
Member since May 2019 • Last active Jul 2019Most recent activity
-
Hi Guys,
I was having issues to connect with the espruino, but I was using the wrong code. So, I got how it works create my code, but now I'm receiving a return that my bluetooth is disconnected after connect. It is too weird. Do you know why?
Follow below my code and the response in chromeCode:
$scope.btnstatus = function(action) { var connection; if(action == 'on') { Puck.write('LED1.set();\n',function(callback) { console.log(callback); Puck.write('Puck.getBatteryPercentage();\n',function(baterry) { console.log(callback); initMap(); }) }); } else { Puck.write('LED1.reset();\n',function() { Puck.write('Puck.magOff();\n',function() { }) }); } };
Response:
Web Bluetooth is experimental on this platform. See https://github.com/WebBluetoothCG/web-bluetooth/blob/gh-pages/implementation-status.md puck.js:318 <BLE> Device Name: Puck.js f0b5 puck.js:318 <BLE> Device ID: vtZGyU35qoD8K6UJmjRSEg== puck.js:318 <BLE> Connected puck.js:318 <BLE> Disconnected (gattserverdisconnected)
-
-
- 7 comments
- 3,353 views
-
Hi Guys, sorry for my mistake and didn't place the code.
I'm using cordova with angular v 1.*.
Follow:
my head
<!DOCTYPE html> <html> <head> <!-- Customize this policy to fit your own app's needs. For more guidance, see: https://github.com/apache/cordova-plugin-whitelist/blob/master/README.md#content-security-policy Some notes: * gap: is required only on iOS (when using UIWebView) and is needed for JS->native communication * https://ssl.gstatic.com is required only on Android and is needed for TalkBack to function properly * Disables use of inline scripts in order to mitigate risk of XSS vulnerabilities. To change this: * Enable inline JS: add 'unsafe-inline' to default-src --> <meta name="format-detection" content="telephone=no"> <meta name="msapplication-tap-highlight" content="no"> <meta name="viewport" content="user-scalable=no, initial-scale=1, maximum-scale=1, minimum-scale=1, width=device-width"> <link rel="stylesheet" type="text/css" href="js/bootstrap/css/bootstrap.min.css"> <link rel="stylesheet" href="css/angular-material.min.css"> <link rel="stylesheet" type="text/css" href="css/index.css"> <link rel="stylesheet" type="text/css" href="css/specialinputs.css"> <script type="text/javascript" src="js/jquery-2.2.1.min.js"></script> <script type="text/javascript" src="js/bootstrap/js/bootstrap.min.js"></script> <script src="js/angular.js"></script> <script src="js/angular-route.js"></script> <script src="js/angular-animate.js"></script> <script src="js/angular-aria.min.js"></script> <script src="js/angular-messages.min.js"></script> <script src="js/angular-material.min.js"></script> <script src="https://www.puck-js.com/puck.js"></script> <script src="https://maps.googleapis.com/maps/api/js?key=AIzaSyDKO91w7TH8iP4MN1ziQT0BOqjsWtJtpqk&libraries=places,drawing,geometry" async defer></script> <title>Myspot</title>
Then, my code in the angular file.
scope.btnstatus = function(action) { if(action == 'on') { Puck.write('LED1.set();\n',function() { alert(Puck.getBatteryPercentage()); initMap(); }); } else { Puck.write('LED1.reset();\n',function() { //Puck.magOff(); }); } }; $scope.magOn = function() { Puck.magOn(); Puck.on('mag', function(xyz) { console.log(xyz); }); }
-
Hi Ollie, thanks for you answer. Yes, my note was connected to the puck. However, I still not figure out how to use the functions to handle the puck features.
I know that I have to use Puck.write and describe the function that I wanna use in the puck and than the callback. However, I cant for example call 'Puck.on('mag',function(xyv) {' using write. Can I? I saw in examples on internet connecting through IDE that the pages call the functions of puck directly. Like
How I can use javascript like that in my code? Can I?
Thanks Again