java - How to send serial data via Bluetooth to an unspecified device? -


i use following code arduino uno:

#include <softwareserial.h>  softwareserial device(2, 3);   void setup()   {   device.begin(9600); }  void loop()  {   device.println("33,89,156,203,978,0,0;"); } 

no specific device send set.

if want receive data on laptop (running ubuntu 14.04) call:

sudo rfcomm bind rfcomm0 [mac address] 1 

and

screen /dev/rfcomm0  

in terminal instance , works.

how can achieve same behaviour android app? following example code specifies device. cannot find other code. additionally works when listen on laptop incoming connection this:

sudo rfcomm listen rfcomm0 [mac address] 

i want android app work arduino example. how can achieve that?

unfortunately android doesn't appear have low level classic bluetooth apis allow broadcast type behavior. makes sense android intended go power limited devices , active radios use energy. if required use classic bluetooth (3.x) , android handle sending or receiving broadcast type behavior you'll need write custom rom.

however there specification called bluetooth low energy (4.x) allows less energy consumption slower/less data throughput. advertising mode. android devices scanning can pick short advertised data packet broadcasted device called 'beacon'. protocols use mode apple's ibeacon , google's eddystone.

look here sample apps involving advertisements:

also note android devices don't support ble peripheral mode need android device act beacon.

related link: can android device act ibeacon?

and nice list of devices have been tested: http://altbeacon.github.io/android-beacon-library/beacon-transmitter-devices.html

so in case should still able use sony xperia z3 scanner, have buy/build beacon testing.


Comments

Popular posts from this blog

ios - RestKit 0.20 — CoreData: error: Failed to call designated initializer on NSManagedObject class (again) -

laravel - PDOException in Connector.php line 55: SQLSTATE[HY000] [1045] Access denied for user 'root'@'localhost' (using password: YES) -

java - Digest auth with Spring Security using javaconfig -