Bangle.js emulator: Module http not found #5039
Replies: 1 comment
-
Posted at 2020-02-05 by Robin Tue 2020.02.04 Is it possible that HTTP over Wifi is being confused with Bluetooth BLE?
Module reference The link to the code extraction from post #1 refers to chips that have built in WiFi. Was there some documentation that leads one to believe this is possible? please provide link Posted at 2020-02-05 by @gfwilliams Bangle.js doesn't support HTTP or TCP/IP, which is why you're getting the error. Bluetooth LE doesn't support networking properly, so if you want to connect to the internet, you'll need some kind of 'bridge' that has both BLE and a network connection - like a phone, PC, or Raspberry Pi. Posted at 2020-02-05 by ArthurTent So do I understand it correct, that the issue with my code is, that the Bangle.js emulator does not support network connections? Posted at 2020-02-05 by @gfwilliams Yes - if you ran that code on a device with a network connection it'd be fine Posted at 2020-02-05 by ArthurTent Thank you for pointing that out. I'll be looking forward to get my hands on the Bangle.js :) Posted at 2020-02-11 by ArthurTent I've just received the Puck.js and ran the code on the device. I guess one approach would be to run puck.js code in the browser? I've also have a weird behaviour on my linux maschine. I've activated the chrome flag for web bluetooth and was capable to transfer code from the browser IDE to the device. However, when I run the first example code from here: http://www.espruino.com/Web+Bluetooth I'm a little bit confused at the moment. Maybe somebody can point me into the right direction how i can do http get requests? Thank's in advance Posted at 2020-02-11 by @gfwilliams
No, I'm afraid that's not the case. There is no proper support for HTTP or Networking in Bluetooth LE, so there's nothing that 'just works'. There is the Bluetooth LE HTTP proxy that you can use with EspruinoHub but it's extremely limited in terms of the data that you can transfer: http://www.espruino.com/BLE+HTTP+Proxy
Web Bluetooth would be the best bet as you suggest. It's easy to develop and multiplatform, but you could write an Android App to handle it too if you want something always-on. Basically there's no easy way to do an HTTP request direct from Puck.js. The best way is to do the HTTP request on your 'bridge' device and just send the data you need back to the Puck.js over Bluetooth. It's a pain, but Bluetooth LE just doesn't have support for networking in it - it's not what it's meant for.
Are you using HTTPS? Web Bluetooth only gets enabled for HTTPS sites, not HTTP. (ahh - I just read at the bottom that you figured this out). Posted at 2022-07-29 by @gfwilliams Web request support is now implemented in Gadgetbridge: https://www.espruino.com/Gadgetbridge#http-requests |
Beta Was this translation helpful? Give feedback.
-
Posted at 2020-02-04 by ArthurTent
I've tried the Emulator and tried a simple http request.
I've checked this (http://www.espruino.com/Internet) site and the following code:
But the emulator throws an error: Module http not found.
Does Bangle.js support http get requests?
I also had the same error message when i've tried WebSocket. Then it's complaining about missing module "http" and "net".
What am I doing wrong?
Does actually Bangle.js support making simple http requests?
What about WebSocket connections?
Best regards and thanks for any kind of help in advance.
ArthurT
Beta Was this translation helpful? Give feedback.
All reactions