Connecting to Web Bluetooth - bluetooth

I'm trying to connect a bluetooth device (ESP32, peripheral) with Web Bluetooth (central). I send an addvertising packet and I can see the device on the web page, but I fail to connect to it. My code for the ESP32 looks like this: (MicroPython)
ble.gap_advertise(interval_us=100, adv_data=bytearray(b'\x02\x01\x06\x06\x08\x45\x53\x50\x33\x32\x11\x07\x26\x6c\x34\x7f\xb2\x38\x61\x82\xbe\x4d\x1d\x64\xf1\xf7\x93\x16\x02\x19\x80'),resp_data=None, connectable=True)
In Web Bluetooth (JavaScript) I just request a device and try to connect to the gatt.
Can anyone help me out?
Thanks in advance!

The JavaScript does work with another bluetooth peripheral. (RN4678)
And in JavaScript I can find the peripheral (ESP32) after filtering, but I can't connect to it.
JavaScirpt:
server = await device.gatt.connect()
The code stops at that point.
MicroPython:
The GATT is defined using:
ble.gatts.register.services()
I'm trying to use my own service, not a SIG defined one. So I advertise b'(x...') which contains the flags, the service and the device name. And it works with the nRF Connect App. I can send and recive data. But it doesn't work with the bluetooth enabled web browser.
Thanks for your help!

Related

Can webusb connect a website to a Kmtronic Usb one relay device in a ChromeOs chromebox?

Hi I am trying to give a website direct on/off control of a usb relay on a chrome os device. In the past I just used some terminal scripts to run on start-up on a ubuntu device but chrome os is giving me a hard time making this work.
Based on the sample Linux code it looks like these devices are using an FTDI USB serial chip and support a very simple set of commands to turn the relays on and off. The FTDI chips are supported by ChromeOS and so you can use the Web Serial API to control the device like this:
let port = navigator.serial.requestPort();
await port.open({ baudRate: 9600 });
let writer = port.writable.getWriter();
writer.write(new Uint8Array([0xff, 0x01, 0x01]); // Turn relay on command.
await writer.close();
await port.close();
This is a very minimal example. You can improve this by passing a filter to requestPort() to select only the USB devices you want. You also don't need to request permission every time. You can call navigator.serial.getPorts() to get a list of ports that your site already has permission to access.
See https://web.dev/serial and https://wicg.github.io/serial for more information about how to use this API.

ESP32 smart wifi configuration via esp32 wifi AP(Access Point)

I want to make a React-Native application to provide wifi-credentials to esp32 module via esp32 wifi access point.
I see there are some library of npm that we use to provisioning wifi config to esp32.
For ex.
react-native-esp32-idf
react-native-esp-idf-ble-provisioning-rn
But i'm confuse how to use them and may be these are provide credentials via BLE or Bluetooth but I want to provide SSID and PASS via wifi.
Means, I have a esp32 module and at begining i use it as a wifi-access-point then my application would be connected to esp32 by wifi automatiically then by communition through wifi-hotspot b/w app and device i provide cred. to device-esp32.
Thats it!
So how i make this application in react-native?
A simple approach would be like the following:
ESP32 is powered up
ESP32 opens a Wi-Fi access point
ESP32 starts an HTTP server acting as REST API
Any HTTP/REST client (including the react native app) can set the
Wi-Fi password and SSID using via the REST API
Once the Wi-Fi password and SSID are set, ESP32 restarts as a Wi-Fi
station and tries to connect to the configured Wi-Fi password and
SSID.
This way on your react native app you'll only need to use a simple HTTP/REST client

Web Sockets communication using nodejs for connection between a web app and a charging device

I want to create an application in which my web app will work as remote , a node based web socket server will work as CMS(central management system) and an electric vehicle charger which will be my device. I want help in how to send instruction to my device according to the commands i receive from it.
You can use socket.io on your server, it is easy to use and has a socket client implementation in almost languages that exist.

Connecting to Pebble watch using Arduino

I am curently looking to find out wheter it is possible to Bluetooth connect an arduino or similar micro controller to the pebble watch using the RN-42 Sparkfun RN-42 adapter
I currently am having difficulty connecting to the pebble, as the board just times out.
Thanks
The RN-42 can, using bluetooth. The following will get you paired, and the watch MAY accept a ping:
SF,1 //factory reset
SP,9999 //takes care of the pairing code
SM,6 //pairing
SA,4
SY,0000 //power
SW,0640 //sniff mode
R,1 //reset so settings are saved/active and pebble should ask to connect
To pass app messages you need to pass some information to the watch, see http://dexwatch.blogspot.com/2015/12/more-on-pebble.html for the full details.

J2ME SMS Server on mobile phone

Is it possible to have a j2me app on a mobile to act as a "SMS gateway" that will handle incommming messages, do a query on a database via GPRS and reply the user back?
This is entirely possible on any J2ME handset that supports JSR 120 (i.e.: most of them). However as Wonil said, you can't just process ANY incoming SMS message. It has to be an SMS sent to a port number on which your app is listening (using a server connection as Wonil explained).
It wouldn't be automatic unless the app was signed (as confirmation is generally required for sending SMS and network access).
Another approach is to tether your phone to a PC using a USB cable/bluetooth/IR, open a serial connection using the phone as a modem, and write a program to listen for new SMSs using AT+CGML as described here. This would allow ANY incoming SMS to be processed (no port number required), and without any annoying confirmation prompts.
HTH
I think you should check about JSR-120 documentation to confirm.
But, in my thought it might be impossible. If you want to receive message by using JSR-120, you should assign specific end point(port number) to listen as like below:
serverConn = (MessageConnection)Connector.open("sms://:5000");
So, you can't catch all SMS messages. It can't be a gateway then.
It probably depends if your phone supports it. Have a look at the J2ME Wireless Messaging API:
The Wireless Messaging API (WMA) is an optional package for the Java 2
Platform, Mobile Edition (J2ME) that
provides platform-independent access
to wireless communication resources
like Short Message Service (SMS).
http://java.sun.com/products/wma/overview.html
This article has some examples which can probably serve as a starting point for what you want to achieve: http://www.ibm.com/developerworks/wireless/library/wi-extendj2me/
Edit: as others have pointed out, you might not be able to receive all messages.

Resources