Most recent activity
-
Button can be defined in board file, see other boards for BTN1. this 'check button and skip load' is there for nrf52 too so that's basically all boards except ESP. could be added here https://github.com/espruino/Espruino/blob/master/targets/esp32/main.c#L69
-
Normally this should not happen, maybe you have HID enabled so windows detect it as keyboard mouse? In such case try to disable HID if it helps. there is similar issue described here https://stackoverflow.com/questions/68997468/web-bluetooth-connection-problems-in-chrome-on-windows-10
-
you say I need to write 'LED1.set()\n' - do I need to add true\false ?
no, https://www.espruino.com/Reference#Pin
after I have connected to the device , why can't I see the data I'm sending to him , is there any way to write something to log in order to see where is the problem ?
all I can see is -> Bluetooth
I'm sending sample data once every 10 seconds , and I can't see anything - why?-> Bluetooth
is printed when output console is switched to bluetooth, this indeed happens by default when you connect. When you disconnect you will probably see -> 'name your previous console'. Often this is what you want when you connect to the device via https://www.espruino.com/ide/ or espruino cli command. You can override this behaviour as per https://www.espruino.com/Reference#l_E_setConsole but if you keep console as it was you cannot send commands like theLED1.set()
to console via bluetooth connection.and I can't see anything - why?
output goes to bluetooth console but you probably don't read it at all
do you have an example\guide for it?
I think I linked more than enough guides already and it doesn't look like it helped
-
can you show an example code to put on the mdb42q
You don't need any code on mdb42q at all to do this. You also don't need to 'wait' on MDBT42 side for anything.
You just need to connect from the pi to the MDBT42 and send JS code to set the GPIO as shown in example https://www.espruino.com/Web+Bluetooth that is the easiest way to do this. There are other ways with custom service on MDBT42 - see e.g. this https://www.espruino.com/BLE+Communications but this is more complicated. Since you are struggling even with the basics there is no point in doing that as step 1.
As I see it, the biggest issue for you is how to write code on Pi side to connect and send string like
'LED1.set();\n'
to Nordic UART service on MDBT42 (or any custom service if you go for the more complicated solution) . In both cases the Pi side will be similar - connect, write data to some characteristics. If you want reply back then also subscribe to notifications and get output back.As for refusing connection from unknown devices check https://www.espruino.com/BLE+Security but I wouldn't worry about that in step 1.
I think we misunderstanding each other.... :-)
Yes, there seems to be a lot of misunderstanding on your side in both how BLE works and also what you exactly want to do and how :-)
And BTW here is example of getting battery via (already suggested) espruino cli command
http://forum.espruino.com/conversations/297357/#13369180 -
can Espruino be used as client? meaning can I send data to it?
or they are ony used as "server" and send data to other devcies?Espruino can be used on both sides quite easily. It is the linux on the Pi that is more complicated. Just found tutorial that may help a bit and describes various options , check https://www.espruino.com/BLE+Advertising
-
-
connecting the opposite way does not help you in any way, you need example for the Pi which connects the other way, not this piece of JS code for MDBT42. Then you would just send piece of javascript to toggle GPIO. As a start you can use web page in Chromium on the PI as per https://www.espruino.com/Web+Bluetooth - this is the easiest thing and web bluetooth works on the Pi
otherwise bluetooth in linux is a mess, there are many ways, maybe search raspberry forum or check this https://elinux.org/RPi_Bluetooth_LE#Using_Bluetooth_LE_with_Python or node.js via https://github.com/noble/noble or dierctly via https://www.npmjs.com/package/espruino which is using noble
-
I want to connect to the mdb42q from my pi
your code example is doing it the other way - from Espruino to the Pi, so which one you want and which device has GPIO connected to something?
On Espruino side you can hook into incoming connection event and refuse any connection so you can filter by mac address even without secure connection if you wish.
I can see it in bluetooth and ble scan from my phone
so what is wrong?Try also connection over BLE from the phone (e.g. via nrfConnect), does it work? What are you next steps if connection works? How do you plan to receive GPIO toggle command on Pi side (if this is the right direction)?
-
I added the active: true but it made no difference.
It makes a difference when data (like device name, or basically anything) is in scan response packet and not directly in advertisement packet. Packet size is very limited so sometimes the less important data is in scan response, which is asked for only with active scan. Anyway, great you got it working.
Unfortunately Brave developers disabled web bluetooth intentionally because of their privacy focus. For more details see https://github.com/brave/brave-browser/issues/9586#issuecomment-840743917 and https://github.com/brave/brave-browser/issues/15637