-
Hi,
I pulled my Bangle.js from back of my drawer after a long resting.
App loader showed invalid json error so I tried "remove all apps" and "Install default apps" from About.
I also tried reset from settings.After playing around with above impatiently, the watch now displays "Updating boot0..." and does nothing... for several hours by now.
I cannot connect to it from App loader... Have I managed to brick it?!
Any suggestions how to get back to normal?
Need to access SWD? -
-
Yes, I'm aware of the swiss railway clock and it's been an inspiration for its simplicity and readability. I hope mine is still different enough.
By the way, I also made a couple of simple widgets:
Pedometer widget and Digital clock widget.
https://aerialist.github.io/BangleApps/ -
Hi,
I just wrote yet another clock app, Bold Clock. I wanted it to be simple, readable and practical analog clock.
So it's drawn with thick lines and turn on LCD when "faceUp" event occurs.You can install it from my github page (look for "Bold Clock")
https://aerialist.github.io/BangleApps/or try it on emulator
https://www.espruino.com/ide/emulator.html?codeurl=https://aerialist.github.io/BangleApps/apps/boldclk/bold_clock.js&uploadThere are still console log messages left for debugging. I'll iterate and may send PR if it deemed usable.
I have been looking for a programmable watch with heart rate monitor for long time. And I'm super happy to get hold of a beta unit.
I used to play around with Ruputer watch from Seiko which run DOS twenty years ago. Bangle.js reminds me of the exciting times ;-)
https://en.wikipedia.org/wiki/Ruputer -
Very interesting to hear about your experience with TI. I hope they have learn lessons and are better now with CC3200/3100. At least they offer free IDE option now.
ESP8266 is indeed very interesting for its price. Although no hardware encryption, its MCU could be good enough to post tweets. There are quite a few discussion threads with mixed outcomes about SSL. I found these most informative:
https://github.com/ParsePlatform/parse-embedded-sdks/issues/5
https://github.com/nodemcu/nodemcu-firmware/issues/134Have to keep an eye on the progress.
-
Well, HTTPS and OAuth seems the de facto standard of web service these days... despite IoT hype. I wonder if a WiFi module with hardware HTTPS and SHA1 capability could come to rescure.
TI's CC3200 has "Hardware Crypto Engine" and also said to include TLS/SSL stacks along side with ARM M4 processor for applications to run.
http://www.ti.com/product/cc3200Would be interesting if Espruino can run on it!
-
Could Espruino handle HTTPS...?
All twitter REST API resource URL are HTTPS, not HTTP...
And I've got this error code returned. Yeah, sure. I called require("http").get() function with a URL starting with "https://"...Response: { "headers": { "content-length": "52", "content-type": "application/json;charset=utf-8", "date": "Sun, 14 Jun 2015 13:38:10 GMT", "server": "tsa_a", "set-cookie": "guest_id=v1%3A143428919094643089; Domain=.twitter.com; Path=/; Expires=Tue, 13-Jun-2017 13:38:10 UTC", "x-connection-hash": "3e91ae650c8rfb6894d0fc7183fae787", "x-response-time": "8" }, "httpVersion": "1.0", "statusCode": "403", "statusMessage": "Forbidden" } --->{"errors":[{"message":"SSL is required","code":92}]} >
Oh, these HTTPS and OAuth security things are so tough for micro controllers! We need a good solution to make IoT inexpensive!
-
I've got oauth.js and sha1.js running on Esprino Pico alright! (Well, at least included test functions run ok.)
1v79 Copyright 2015 G.Williams >echo(0); =undefined >process.memory(); ={ "free": 1323, "usage": 1717, "total": 3040, "history": 1229, "stackEndAddress": 536924840, "flash_start": 134217728, "flash_binary_end": 312536, "flash_code_start": 134234112, "flash_length": 393216 } >sha1_vm_test() =true >testEncode(); =undefined >testGetParameters(); =undefined >testGetBaseString(); =undefined >testGetSignature(); =undefined >
I used minification by Closure Simple Optimisations and have Set Current Time on under Communications setting.
Now I'need to fight with Twitter API and find out what parameters to throw.
This seems to be a good reference to follow.
https://github.com/mogya/tm_twitter_api -
Thanks for your interest, DrAzzy!
This is right after uploading the code in #9 without minify.
1v79 Copyright 2015 G.Williams >echo(0); =undefined >process.memory(); ={ "free": 204, "usage": 2836, "total": 3040, "history": 190, "stackEndAddress": 536924840, "flash_start": 134217728, "flash_binary_end": 312536, "flash_code_start": 134234112, "flash_length": 393216 } >
With minification by Esprima.
>process.memory(); ={ "free": 1242, "usage": 1798, "total": 3040, "history": 1219, "stackEndAddress": 536924840, "flash_start": 134217728, "flash_binary_end": 312536, "flash_code_start": 134234112, "flash_length": 393216 } >
With minification by Closure Simple Optimisation.
>process.memory(); ={ "free": 1333, "usage": 1707, "total": 3040, "history": 1218, "stackEndAddress": 536924840, "flash_start": 134217728, "flash_binary_end": 312536, "flash_code_start": 134234112, "flash_length": 393216 } >
Pretty good improvement ;-) I continue my endeavour.
-
My crude re-mapping of url.parse seems to be doing the job. But...
Ouch! I've faced with ERROR: Out of Memory...Well, as attached, I'm just copying concat codes into Web IDE. I think I'm going to try minify it.
| __|___ ___ ___ _ _|_|___ ___ | __|_ -| . | _| | | | | . | |_____|___| _|_| |___|_|_|_|___| |_| http://espruino.com 1v79 Copyright 2015 G.Williams >echo(0); =undefined >testGetParameters(); ERROR: Out of Memory! =undefined Uncaught Error: Field or method "length" does not already exist, and can't create it on null at line 22 col 29 if (esp_parse.search.length > 0){ ^ in function "" callein function "normalizeUrl" called from line 16 col 74 ...tureMethod.normalizeUrl(URL)) ^ in function "getBaseString" called from line 2 col 69 ...ethod.getBaseString(message); ^ in function "sign" called from line 7 col 69 ...ame, accessor).sign(message); ^ in function "sign" called from line 21 col 53 OAuth.SignatureMethod.sign(message, accessor); ^ in function "completeRequest" called from line 33 col 67 ...sumerKey: 'CK', token: 'T'}); ^ in function "testGetParameters" called from line 1 col 19 testGetParameters(); ^ > Disconnected
-
Thanks again, DrAzzy and Gordon. I've got one step closer.
OAuth URI encoding seem to have some extra ok characters. And it wants to see upper case letters after %. With this modified encodeURIComponent function, Espruino passed testEncode(). Yeah!
function encodeURIComponent(s) { var ok = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_.~"; var r = ""; for (var i=0;i<s.length;i++) { if (ok.indexOf(s[i])>=0) r+=s[i]; else r+= "%"+(256+s.charCodeAt(i)).toString(16).toUpperCase().substr(-2); } return r; }
The next hurdle is regular expression in parseUri function.
parseUri: function parseUri (str) { /* This function was adapted from parseUri 1.2.1 http://stevenlevithan.com/demo/parseuri/js/assets/parseuri.js */ var o = {key: ["source","protocol","authority","userInfo","user","password","host","port","relative","path","directory","file","query","anchor"], parser: {strict: /^(?:([^:\/?#]+):)?(?:\/\/((?:(([^:@\/]*):?([^:@\/]*))?@)?([^:\/?#]*)(?::(\d*))?))?((((?:[^?#\/]*\/)*)([^?#]*))(?:\?([^#]*))?(?:#(.*))?)/ }}; var m = o.parser.strict.exec(str); var uri = {}; var i = 14; while (i--) uri[o.key[i]] = m[i] || ""; return uri; }
Well, Espruino already has url.parse function so I think I could use it with some key re-mapping. I'm going to try...
-
Thanks for your encouragement, Gordon!
I gave it a go and faced that "encodeURIComponent" function is missing.Here's what I did:
Copied sha1.js to Espruino Web IDE and shuffled the order of function definitions a bit, it was sent to Espruino Pico alright. Running sha1_vm_test(); on Pico returned true. Nice ;-)Then I added codes from oath.js. It needed minor change (move open curly bracket to the same line as function declaration). With that, it was sent to Pico alright. But running testGetSignature() returned Error: Function "encodeURIComponent" not found!
I searched around and found that v8 implements it in javascript
http://v8.googlecode.com/svn/trunk/src/uri.jsCopied it to Web IDE but it refused to send to Pico with message:
"A corn parse for plugin/compiler.js failed. Check the editor window for syntax errors."There are quite a few "!" marks and these lines are labeled "x"
if (value < 0x10000) { %_TwoByteSeqStringSetChar(index++, value, result); } else { %_TwoByteSeqStringSetChar(index++, (value >> 10) + 0xd7c0, result); %_TwoByteSeqStringSetChar(index++, (value & 0x3ff) + 0xdc00, result); }
var result = %NewString(array.length, NEW_ONE_BYTE_STRING); for (var i = 0; i < array.length; i++) { %_OneByteSeqStringSetChar(i, array[i], result); }
I'd appreciate any advice to get encodeURIComponent working. I have no idea what these % are doing in javascript...
-
Reading through how tweet is done in Arduino world, there seems to be two ways:
Use intermediate server to hand off the OAuth heavy lifting
http://playground.arduino.cc/Code/TwitterLibrary
This is light weight for Arduino code. But requires 3rd party server or set up your own.Implement OAuth request signing on Arduino
http://www.markkurossi.com/ArduinoTwitter/index.html
Arduino can directly tweet. But the library is big.
Mmm... the second approach is very attractive for independence.
Would getting oauth.js and sha1.js here work on Espruino mean we could do it?
https://code.google.com/p/oauth/source/browse/#svn/code/javascriptI think I just have to give it a try...
-
Has anyone managed to have Espruino post a tweet to Twitter?
Now that I've got Espruino Pico with ESP8266 in hand, I'd like to make a coffee pot that tweets.
I understand I could do simple GET and POST request with arguments using built-in http module. But Twitter requires authentification by OAuth.
Could we use OAuth library like this one?
https://code.google.com/p/oauth/source/browse/#svn%2Fcode%2Fjavascript -
-
Thank you very much for you advice, Gordon!
Doing LoopbackA.setConsole() on onInit works great! Serial1 is quiet now ;-)
you could make a handler for USB.onData that would swap the console
back to USB when you pressed a button.I couldn't fully understand your suggestion.
Do you meanUSB.onData(function (e) { USB.setConsole(); });
?
It seems overkill to on every character received on USB.
Or perhaps you meant assigning USB.setConsole for a press of button?function onInit(){ LoopbackA.setConsole(); setWatch(function(){ USB.setConsole();}, BTN, true); }
Anyway, above onInit function seem to behave as I wanted.
(just have to remember to call onInit or LoopbackA.setConsole(); on WebIDE before unplugging USB.) -
Hi!
How could I stop Espruino to move console or force it to move to Serial6 (which does not exist on Espruino board?) when USB cable is disconnected?
I saw the case to do it after boot by defining onInit function and call setConsole() there.
http://forum.espruino.com/conversations/863/#comment11883Is there event to watch for USB cable disconnected so that I can call Serial6.setConsole()?
I embed Espruino into a keyboard together with Adafruit EZ-Key module. Espruino scan the keyboard and send data which key is pressed to EZ-Key via Serial1(B6, B7). EZ-Key act as a BT Keyboard for iPhone. All USART1-5 enabled ports are used for keyscan excpet B6 and B7. I do want to have console on USB for debug but I also like to use it without USB connected for real use.
-
-
Thank you, Gordon!
Hah, silly me. I completely overlooked the case when uUSB is not plugged in... I shouldn't try to charge the battery with its own power...OK here's updated list to do:
- Mount MAX1555 on SMD proto area
- Wire BAT (MAX1555) to BAT_IN (Espruino's JST PHR-2 2)
- Wire USB (MAX1555) to USB_VBUS (access at D1 1N5819)
- Connect GND (MAX1555) and GND (Espruino)
- Mount MAX1555 on SMD proto area
-
-
Hi,
I love Espruino board and I'd like to embed Espruino together with Lithium Polymer battery into a case, with one opening for uUSB.
I'd like to add battery charger circuit so that battery would be charged when uUSB on Espruino is connected to PC.
Does anyone have recommendation which charger IC to use and how to connect?
Reading Espruino document at
http://www.espruino.com/EspruinoBoard
http://www.espruino.com/BatteryI understood that Espruino board does not have charging IC on board. "An unpopulated resistor that can trickle-charge a battery when fitted" sounds tempting but I feel better not to take risk after reading this tutorial.
https://learn.adafruit.com/li-ion-and-lipoly-batteries?view=allSearching around, it seems easiest to put off-the-shelf charger board into the case.
https://www.sparkfun.com/products/10401
Or MAX1555 charger IC seems simple enough to put on SMD proto area.
https://www.sparkfun.com/products/674Now my question is: how to wire the charger IC between the battery and Espruino, and how to get uUSB 5v supply to the charger IC.
Checking the schematics of this product
https://www.sparkfun.com/products/12711
https://cdn.sparkfun.com/datasheets/Prototyping/USB_LiPolyCharger_SingleCell21.pdf
It looks like I can just connect the battery and Espruino's BAT_IN in parallel to MAX1555's BAT pin. I guess it has to be BAT_IN rather than VBAT. (am I right?)
I think I'd access BAT_IN by soldering a wire to JST PHR-2 2 Pin.Now how should I get power supply to the charger IC? MAX1555 takes 3.7v to 6v so Espruino's 3.3v pin is just under. Mmm, reading Espruino schematics again, VBAT seems to become uUSB's power when it is plugged-in. Then it's easy.
As the conclusion, I think all I need is:
- Mount MAX1555 on SMD proto area
- Wire BAT (MAX1555) to BAT_IN (Espruino's JST PHR-2 2)
- Connect USB (MAX1555) to VBAT
Plugging-in uUSB and battery together is ok thanks for Gordon to implement MOSFET-P-0440210P1 switch. And it also enabled easy access to get uUSB's 5v supply to charger IC. Cool.
I hope someone could confirm above is right before I give it a try and blow up my precious Espruino board...
And I'd appreciate any extra advice ;-)
- Mount MAX1555 on SMD proto area
-
-
Hi,
I have two switches, one connected to A1 and the other to C1.
If I set watch for only one of the pins, it works as expected. But if I set watch for both pins, then the 2nd setWatch seem to kill the 1st.setWatch(onWatch, A1, { repeat:true, edge:"rising" });
setWatch(onWatch, C1, { repeat:true, edge:"rising" });Is this as expected? i.e. there is limitation of pin combinations?
I have tried some other pin combinations and "B8, B4, B3, B2" worked fine.Espruino 1v61
Br, Shunya
It managed to get into DFU mode.
https://www.espruino.com/Bangle.js#firmware-updates
After uploading latest firmware, I could connect to App loader and "Install default apps" worked just fine.
Now I can enjoy Bandgle.js again!