package com.example.blunobasicdemo;
import android.os.Bundle;
import android.content.Intent;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.EditText;
import android.widget.TextView;
public class BlunoActivity extends BlunoLibrary {
private Button buttonScan;
private Button buttonSerialSend;
private EditText serialSendText;
private TextView serialReceivedText;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.bluno);
onCreateProcess(); //onCreate Process by BlunoLibrary
serialBegin(115200); //set the Uart Baudrate on BLE chip to 115200
serialReceivedText=(TextView) findViewById(R.id.serialReveicedText); //initial the EditText of the received data
; //initial the EditText of the sending data
//initial the button for sending the data
buttonScan = (Button) findViewById(R.id.buttonScan); //initial the button for scanning the BLE device
buttonScan.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
// TODO Auto-generated method stub
buttonScanOnClickProcess(); //Alert Dialog for selecting the BLE device
}
});
}
protected void onResume(){
super.onResume();
System.out.println("BlUNOActivity onResume");
onResumeProcess(); //onResume Process by BlunoLibrary
}
@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
onActivityResultProcess(requestCode, resultCode, data); //onActivityResult Process by BlunoLibrary
super.onActivityResult(requestCode, resultCode, data);
}
@Override
protected void onPause() {
super.onPause();
onPauseProcess(); //onPause Process by BlunoLibrary
}
protected void onStop() {
super.onStop();
onStopProcess(); //onStop Process by BlunoLibrary
}
@Override
protected void onDestroy() {
super.onDestroy();
onDestroyProcess(); //onDestroy Process by BlunoLibrary
}
@Override
public void onConectionStateChange(connectionStateEnum theConnectionState) {//Once connection state changes, this function will be called
switch (theConnectionState) { //Four connection state
case isConnected:
buttonScan.setText("Connected");
break;
case isConnecting:
buttonScan.setText("Connecting");
break;
case isToScan:
buttonScan.setText("Scan");
break;
case isScanning:
buttonScan.setText("Scanning");
break;
case isDisconnecting:
buttonScan.setText("isDisconnecting");
break;
default:
break;
}
}
@Override
public void onSerialReceived(String theString) { //Once connection data received, this function will be called
// TODO Auto-generated method stub
serialReceivedText.append(theString); //append the text into the EditText
//The Serial data from the BLUNO may be sub-packaged, so using a buffer to hold the String is a good choice.
}
}
우선 scan 버튼을 누르면 블루투스의 값을 화면에 띄우는것까지는 성공했습니다. 문제는 이 값을 어떻게 db로 저장해야되는지 모르겠습니다. 이 값은 db로 보내서 3000-값 이렇게 할려고 생각중인데요. 어떻게 해야할지 잘 모르겠습니다.