omaraflak / Bluetooth-Android

This is an android class that allows you to communicate simply using a bluetooth connection.
8 stars 2 forks source link

Question #1

Open neox994 opened 6 years ago

neox994 commented 6 years ago

Hello did anyone got problem with receiving data from bluetooth modul on arduino?! arduino serial monitor print normally,but when i got to receive data via bluetooth,method onMessage() don't trigger. it's connected to bluetooth modul.

omaraflak commented 6 years ago

Hi, be sure to add a "\n" at the end of each line

matijagorsek commented 6 years ago

include

SoftwareSerial BT(10, 11); int i =0; void setup() { // put your setup code here, to run once: BT.begin(9600); }

void loop() { // put your main code here, to run repeatedly: BT.println(i); i++; delay(1000); }

this code would every second send data,but didnt get anything in android.

bt = new Bluetooth(getActivity()); bt.enableBluetooth();

    /**GET Paired Devices**/
    List<BluetoothDevice> devices = bt.getPairedDevices();

    /**Listeners**/
    bt.setDiscoveryCallback(this);
    bt.setCommunicationCallback(this);

    /**Scan**/
    bt.scanDevices();
    if(bt.isConnected()){

    }else{
        bt.connectToAddress("00:21:13:01:5A:7A");
    } 

this is code with every listener implemented.

matijagorsek commented 6 years ago

@Override public void onMessage(String message) { Toast.makeText(getActivity(), message, Toast.LENGTH_LONG).show(); Log.d("test",message); }

on this line i should get data from bluetooth,but it's not happening.