Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cant use HTTPProxy with puck #1

Closed
otbe opened this issue Dec 9, 2016 · 6 comments
Closed

Cant use HTTPProxy with puck #1

otbe opened this issue Dec 9, 2016 · 6 comments

Comments

@otbe
Copy link
Contributor

otbe commented Dec 9, 2016

Hi,

I try to setup my pi as an espruino hub to allow my pucks to do some http requests, but for some reason it wont work :/

From your basic example I get this on the puck:

Connected
Got service
Got characteristic
Set URI
Uncaught Error: Unhandled promise rejection: No Characteristics found

and on my pi I get:

Config loaded
MQTT Connected
<HTTPProxy> Bleno State poweredOn
<HTTPProxy> Bleno.startAdvertising Success
<HTTPProxy> Bleno.setServices Success
Scanning started...
<HTTPProxy> c9:88:f0:97:da:57 connected (whitelisted: undefined)
BLE broken? No advertising packets in 10 seconds - restarting!

Fri Dec 09 2016 20:58:39 GMT+0100 (CET)

47:4d:3d:fd:7b:07 - ? (RSSI -64)
7a:3f:6d:0d:d0:bf - ? (RSSI -72)
ac:bc:32:d2:90:e0 - ? (RSSI -71)
d0:4f:7e:19:13:7d - ? (RSSI -54)
puck1 - Puck.js da57 (RSSI -75)

After some time the process exits. This is my config.json

{
  "// If a device's address is here, it'll be given a human-readable name":0,
  "known_devices" : {
    "c9:88:f0:97:da:57" : "puck1"
  },

  "// Set this to enable the HTTP proxy - it's off by default for safety":0,
  "// since it would be possible to spoof MAC addresses and use your":0,
  "// connection":0,
  "http_proxy" : true,

  "// If there are any addresses here, they are given access to the HTTP proxy":0,
  "http_whitelist" : [
    "c9:88:f0:97:da:57"
  ]
}

Any hints? :)

Thanks!

@gfwilliams
Copy link
Member

Can you check the pi with your phone and 'nrf connect'? My guess is it doesn't have services.

I don't have my pc handy at the moment, but have a look at bleno's NPM docs. I seem to recall you have to do something like disabling the Bluetooth service - I may have missed that out of the docs

@otbe
Copy link
Contributor Author

otbe commented Dec 9, 2016

You're correct. I forgot to:

# Stop the bluetooth service
sudo service bluetooth stop
# Start Bluetooth but without bluetoothd
sudo hciconfig hci0 up

But there is another problem, because my requests are blocked :)
I guess the config.js don't read http_proxy and it seems to me that it is not used anywhere in the code except for this.
I created #2 to solve this problem and all seems to work very well 👍

Thanks!

P.S.: Is there any way to do a PUT/POST request?

@gfwilliams
Copy link
Member

Thanks! Sorry, totally my fault there :)

Yeah, you'd have to change the code in the Puck module http://www.espruino.com/modules/ble_http.js

There's a comment that says 'http get' - just change the number 1 to one of the values from the http proxy spec

@otbe
Copy link
Contributor Author

otbe commented Dec 9, 2016

Thanks :)

Its a bit pointless because of the 20 bytes limit. Even the urls are too large :)

Will close this issue now, thank you very much :)

@otbe otbe closed this as completed Dec 9, 2016
@gfwilliams
Copy link
Member

No problem. I think BLE 5 handles up to 512 bytes, which makes it a lot more useful. Support for that will come eventually

@otbe
Copy link
Contributor Author

otbe commented Dec 10, 2016

Nice. Please let me know if I can do something to get BLE5 alive :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants