Example code for connecting from a rpi with node.js or python3 #3069
Replies: 7 comments
-
Posted at 2019-08-12 by Robin Mon 2019.08.12 Hello @hansamann, a bit puzzled by your post, you do realize this forum provides support for boards running Espruino Javascript? I don't see how your post applies? |
Beta Was this translation helpful? Give feedback.
-
Posted at 2019-08-12 by @allObjects @robin, @hansamann is aware of that... I confidently assume, because he has puck specific forum posts since quite a while ago. In this conversation he asks about an issue connecting to MDBT42 (on puck, pixl or plain MDBT42) from a raspi using python 2.7 / 3.5. @hansamann, I had some heavy exposure to python in the apple heart study in 2018, but that was 2.7. Did not venture into 3.5. From the error it looks you pass a string ( |
Beta Was this translation helpful? Give feedback.
-
Posted at 2019-08-12 by @gfwilliams Just to be sure, you're using this code? https://www.espruino.com/Interfacing#python As-is, or did you tweak |
Beta Was this translation helpful? Give feedback.
-
Posted at 2019-08-12 by maze1980 Visit google. Type in |
Beta Was this translation helpful? Give feedback.
-
Posted at 2019-08-12 by hansamann Thx all, trying this out next time I am close to my pixl.js, might have a chance to try on a puck earlier. |
Beta Was this translation helpful? Give feedback.
-
Posted at 2019-08-12 by hansamann Hi Gordon, I'll give the python3 recommendations a try back in the office (wed), for now I tried to go with useing node.js - to start with I wanted to use my macbook with mojave. So the whole noble lib seems a mess - as the docs suggest I went with noble-mac now. Interestingly, I was able to use my new pixl.js with the example - the code example found the device, connected, sent the command and disconnected. I did need to switch from : to - in the device address -somehow the devices addresses have - for me... Now at home tried it with a puck, latest version.
All I changed in my code, see below, is the device address. I connected via the web ide, NRF.getAddress() and replace the : with - so the device is found. Really the same code (https://www.espruino.com/Interfacing#node-js) except the address line changed to: var ADDRESS = "ef:22:d8:d6:2e:71".replace(/:/g, "-"); BTW find it super amazing that the browser with web bluetooth now seems to be the most stable BLE api you can find out there :-) |
Beta Was this translation helpful? Give feedback.
-
Posted at 2019-08-27 by @gfwilliams Great, thanks! So you're saying the address format for the node.js code is wrong? If so I'll change that in the docs. It's possible they updated |
Beta Was this translation helpful? Give feedback.
-
Posted at 2019-08-12 by hansamann
I've found the python3 example code by now -but somehow this does not work on my pi:
This is on a pi with python 3.5, bluepi itself seems to work and run. Also I would like to use python3 - but I am really not an expert here. Any ideas?
Beta Was this translation helpful? Give feedback.
All reactions