Page 91 - 2020학년도 MDP과제발표회 자료집 (통신과) (3)
P. 91

import  android.support.v7.widget.Toolbar;
            import  android.util.Log;
            import  android.view.View;
            import  android.view.View.OnClickListener;

            import  android.widget.Button;
            import  android.widget.EditText;
            import  android.widget.ImageButton;
            import  android.widget.ImageView;
            import  android.widget.TextView;

            import  android.widget.Toast;
            import  com.example.user.bluetoothservice.R;
            public  class  MainActivity  extends  AppCompatActivity  {


                    //  사용자  정의  함수로  블루투스  활성  상태의  변경  결과를  App                으로  알려줄때  식별자로  사

            용됨 보다  커야함(0      )
                    static  final  int  REQUEST_ENABLE_BT  =  10;
                    int  mPariedDeviceCount  =  0;
                    Set<BluetoothDevice>  mDevices;



                    //   폰의  블루투스  모듈을  사용하기  위한  오브젝트.
                    BluetoothAdapter  mBluetoothAdapter;
                    /**
                      *  BluetoothDevice   로  기기의  장치정보를  알아낼  수  있는  자세한  메소드  및  상태값을  알
            아낼  수  있다.

                      *   연결하고자  하는  다른  블루투스  기기의  이름 주소 연결  상태  등의  정보를  조회할  수 ,   ,
            있는  클래스.
                      *   현재  기기가  아닌  다른  블루투스  기기와의  연결  및  정보를  알아낼  때  사용.
                      */
                    BluetoothDevice  mRemoteDevie;



                    EditText  mEditReceive;
                    //   스마트폰과  페어링  된  디바이스간  통신  채널에  대응  하는  BluetoothSocket
                    BluetoothSocket  mSocket  =  null;
                    OutputStream  mOutputStream  =  null;

                    InputStream  mInputStream  =  null;
                    String  mStrDelimiter  =  "\n";
                    char  mCharDelimiter  =  '\n';


                    Thread  mWorkerThread  =  null;

                    byte[]  readBuffer;
                    int  readBufferPosition;


                                                         -  94  -
   86   87   88   89   90   91   92   93   94   95   96