How to unpair or delete paired bluetooth device programmatically on android?

This code works for me. private void pairDevice(BluetoothDevice device) { try { if (D) Log.d(TAG, “Start Pairing…”); waitingForBonding = true; Method m = device.getClass() .getMethod(“createBond”, (Class[]) null); m.invoke(device, (Object[]) null); if (D) Log.d(TAG, “Pairing finished.”); } catch (Exception e) { Log.e(TAG, e.getMessage()); } } private void unpairDevice(BluetoothDevice device) { try { Method m = device.getClass() … Read more

Get AT command response

If you have not yet read all of chapter 5 in V.250 specification stop reading here and do so immediately, it is an important basis for the rest of this answer, I’ll wait until you’ll come back. Some of the references to alphabets (short version: ignore this/treat it as ASCII) and S-registers might seem cryptic … Read more

Arduino sprintf float not formatting

Due to some performance reasons %f is not included in the Arduino’s implementation of sprintf(). A better option would be to use dtostrf() – you convert the floating point value to a C-style string, Method signature looks like: char *dtostrf(double val, signed char width, unsigned char prec, char *s) Use this method to convert it … Read more

Python to automatically select serial ports (for Arduino)

Use the following code to see all the available serial ports: import serial.tools.list_ports ports = list(serial.tools.list_ports.comports()) for p in ports: print p This gives me the following: (‘COM4’, ‘Arduino Due Programming Port (COM4)’, ‘USB VID:PID=2341:003D SNR=75330303035351300230’) (‘COM11’, ‘RS-232 Port (COM11)’, ‘FTDIBUS\\VID_0856+PID_AC27+BBOPYNPPA\\0000′) To work out if it’s an Arduino you could do something like: if “Arduino” … Read more

PHP serial port data return from Arduino

I assume you work on linux. First setup your serial port: stty -F /dev/ttyACM0 cs8 9600 ignbrk -brkint -imaxbel -opost -onlcr -isig -icanon -iexten -echo -echoe -echok -echoctl -echoke noflsh -ixon -crtscts Then you can use good old fashion fread/fwrite $fp =fopen(“/dev/ttyACM0”, “w+”); if( !$fp) { echo “Error”;die(); } fwrite($fp, $_SERVER[‘argv’][1] . 0x00); echo fread($fp, … Read more

SWIFT – BLE communications

The following code is for Swift 3 (XCode 8 Beta 6). It’s an example using the standard UUIDs for serial ports like the ones on some commercial modules. So the declarations for the service and characteristics should look like this: private let UuidSerialService = “6E400001-B5A3-F393-E0A9-E50E24DCCA9E” private let UuidTx = “6E400002-B5A3-F393-E0A9-E50E24DCCA9E” private let UuidRx = “6E400003-B5A3-F393-E0A9-E50E24DCCA9E” … Read more