akexorcist / BluetoothSPPLibrary

[UNMAINTAINED][Android] Bluetooth Serial Port Profile which comfortable to developer application to communication with microcontroller via bluetooth
Apache License 2.0
1.7k stars 572 forks source link

Cannot Received Data #70

Open coniocharles opened 7 years ago

coniocharles commented 7 years ago

I have tested My BLuetooth using BT Simple Terminal, And it can received my bluetooth data from my arduino.. But using this,I didnt received any data from bluetooth

I Assumed that I supposed to read it here in this line with SPP Library Under TerminalActivity. But nothing received.

 bt.setOnDataReceivedListener(new BluetoothSPP.OnDataReceivedListener() {
            public void onDataReceived(byte[] data, String message) {
                textRead.append(message + "\n");
            }
        });  

And for my arduino code,

#include <LiquidCrystal.h>
#include <Keypad.h>
#include <SoftwareSerial.h>
const byte ROWS = 4; // Four rows
const byte COLS = 3; // Three columns
// Define the Keymap
char keys[ROWS][COLS] = {
  {'1','2','3'},
  {'4','5','6'},
  {'7','8','9'},
  {'*','0','#'}
};
// Connect keypad ROW0, ROW1, ROW2 and ROW3 to these Arduino pins.
byte rowPins[ROWS] = { 22, 24, 26, 28 };
// Connect keypad COL0, COL1 and COL2 to these Arduino pins.
byte colPins[COLS] = { 30, 32, 34 }; 
int row=0;
int col=0;
// Create the Keypad
Keypad kpd = Keypad( makeKeymap(keys), rowPins, colPins, ROWS, COLS );
// Create the LCD
LiquidCrystal lcd(7, 6, 5, 4, 3, 2);
SoftwareSerial BTSerial(10, 11);

void setup() {

  pinMode(9, OUTPUT);
  digitalWrite(9, HIGH);
  lcd.begin(16, 2);
  lcd.print("[1]Attendance");
  lcd.setCursor(0, 2);
  lcd.print("[2]Get Finger ID");

  Serial.begin(9600);
  Serial.println("Enter AT commands:");
  BTSerial.begin(38400);
}

void loop()
{
  char key = kpd.getKey();
  if(key){
    if(col>=16){
      col=0;
      row=1;
    }
    lcd.setCursor(col, row);
    lcd.print(key);
    col++;
    if(key=='*'){
        BTSerial.write("TEST");
    }  
 }
}
swallowsonny commented 7 years ago

hello,How do you connect to the device? My devices are not connected,Have you modified the code?

coniocharles commented 7 years ago

On Wed, 22 Mar 2017 at 5:28 PM swallowsonny notifications@github.com wrote:

hello,How do you connect to the device? My devices are not connected,Have you modified the code?

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/akexorcist/Android-BluetoothSPPLibrary/issues/70#issuecomment-288343189, or mute the thread https://github.com/notifications/unsubscribe-auth/AOQet4Ng12DioG2urwAkDkot0iIm1ZUEks5roOnTgaJpZM4MdXfH .

I just cloned the repository then test if will work. Then fortunately it work then apply it to my own project.

371280835 commented 7 years ago

I could reaceive too, my BluetoothState is DEVICE_OTHER