Skip to content

Commit

Permalink
modify readme.md and sample
Browse files Browse the repository at this point in the history
  • Loading branch information
123ufo committed Sep 2, 2016
1 parent 51c84ee commit 22d3528
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 5 deletions.
21 changes: 16 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,9 @@
一个封装蓝牙4.0的帮助库


//监听设备以通知方式发过来的数据
###1.

//监听设备以通知方式发过来的数据
mBleManager = BleManager.getInstance(this);
mBleManager.receiver("00001950-0000-1000-8000-00805f9b34fb",
"00002a6c-0000-1000-8000-00805f9b34fb", new OnReceiverCallback() {
Expand All @@ -17,7 +19,7 @@
}
});
###2.

//扫描设备
mBleManager.scanBleDevices(0, new OnScanCallback() {
Expand All @@ -38,6 +40,7 @@
}
});
###3.

//连接设备
mBleManager.connection(0, "CB:A5:AF:B8:AD:58", new OnConnectCallback() {
Expand All @@ -52,7 +55,8 @@
}
});
###4.

//设置通知,true为打开通知,false为关
mBleManager.notification("00001950-0000-1000-8000-00805f9b34fb",
"00002a6c-0000-1000-8000-00805f9b34fb",
Expand All @@ -68,7 +72,8 @@
}
});
###5.

//写入数据
mBleManager.writer("00001950-0000-1000-8000-00805f9b34fb",
"00002a6d-0000-1000-8000-00805f9b34fb",
Expand All @@ -83,10 +88,16 @@
Log.d(TAG," 写失败:" + state);
}
});
###6.

//移除接收数据
mBleManager.unReceiver("00001950-0000-1000-8000-00805f9b34fb", "00002a6c-0000-1000-8000-00805f9b34fb");
###7.

//获取一个特征
mBleManager.getBluetoothGattCharacteristic("00001950-0000-1000-8000-00805f9b34fb","00002a6c-0000-1000-8000-00805f9b34fb");
###8.
//断开连接
mBleManager.disConnection();


4 changes: 4 additions & 0 deletions sample/src/main/java/com/ufo/blelibsproject/MainActivity.java
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ protected void onCreate(Bundle savedInstanceState) {
findViewById(R.id.btn_notification).setOnClickListener(this);
findViewById(R.id.btn_write).setOnClickListener(this);
findViewById(R.id.btn_unreceiver).setOnClickListener(this);
findViewById(R.id.btn_character).setOnClickListener(this);

//监听设备以通知方式发过来的数据
mBleManager = BleManager.getInstance(this);
Expand Down Expand Up @@ -118,6 +119,9 @@ public void onFailed(int state) {
} else if (v.getId() == R.id.btn_unreceiver) {
//移除接收数据
mBleManager.unReceiver("00001950-0000-1000-8000-00805f9b34fb", "00002a6c-0000-1000-8000-00805f9b34fb");
}else if(v.getId() == R.id.btn_character){
//获取一个特征
mBleManager.getBluetoothGattCharacteristic("00001950-0000-1000-8000-00805f9b34fb","00002a6c-0000-1000-8000-00805f9b34fb");
}

}
Expand Down
5 changes: 5 additions & 0 deletions sample/src/main/res/layout/activity_main.xml
Original file line number Diff line number Diff line change
Expand Up @@ -37,4 +37,9 @@
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="关闭接收数据"/>
<Button
android:id="@+id/btn_character"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="获取特征"/>
</LinearLayout>

0 comments on commit 22d3528

Please sign in to comment.