Android BLE外围模式(peripheral)开发

前言:

蓝牙是一种短距离的无线通信技术,可以实现固定设备、移动设备之间的数据交换。一般将蓝牙分为两大类,蓝牙3.0规范之前的版本称为传统蓝牙,蓝牙4.0规范之后的版本称为低功耗蓝牙,也就是常说的BLE(Bluetooth Low Energy)。

BLE分主模式和从模式(外围模式),Android从API 18(4.0)开始支持BLE功能的主模式,但是从API 21(5.0)开始才提供了对外围设备相关的API支持。此文就简单分享一下BLE外围模式(peripheral)的开发;

外围模式的工作流程:从机开启蓝牙 ——>从机初始化参数并发送带有service和characteristic的广播——>主机开启蓝牙扫描BLE设备-->主机和从机通过约定好的service下的characteristic进行通讯;

BLE权限:

    <uses-permission android:name="android.permission.BLUETOOTH" />
    <uses-permission android:name="android.permission.BLUETOOTH_ADMIN" />
  

上代码:

简单粗暴点,直接上代码:
1:创建一个BlePeripheralCallback回调类:
package com.roy.www.ble_peripheral_api;

import android.bluetooth.BluetoothDevice;
import android.bluetooth.BluetoothGattCharacteristic;
import android.bluetooth.le.AdvertiseSettings;

import com.roy.www.ble_peripheral_api.protocol.BleCommPack;


/**
 * Created by Roy.lee
 * On 2021/6/27
 * Email: 631934797@qq.com
 * Description:
 */
public interface BlePeripheralCallback {

    /**
     * Connection status callback
     *
     * @param device
     * @param status
     * @param newState
     */
    void onConnectionStateChange(BluetoothDevice device, int status, int newState);

    /**
     *  Advertise success callback
     *
     * @param settingsInEffect
     */
    void onStartAbSuccess(AdvertiseSettings settingsInEffect);

    /**
     *  Advertise failure callback
     *
     * @param errorCode
     */
    void onStartAbFailure(int errorCode);

    /**
     *  Receive new data callback
     *
     * @param device
     * @param requestId
     * @param characteristic
     */
    void onReceiveNewBytes(BluetoothDevice device, int requestId, BluetoothGattCharacteristic characteristic, byte[] reqeustBytes);

    /**
     * Send data status callback
     * @param status
     * @param bytes
     */
    void onWriteBytesAndStatus(boolean status, byte[] bytes);

}

2:封装一个BlePeripheralHelper工具类:
package com.roy.www.ble_peripheral_api;

import android.bluetooth.BluetoothA2dp;
import android.bluetooth.BluetoothAdapter;
import android.bluetooth.BluetoothDevice;
import android.bluetooth.BluetoothGatt;
import android.bluetooth.BluetoothGattCharacteristic;
import android.bluetooth.BluetoothGattDescriptor;
import android.bluetooth.BluetoothGattServer;
import android.bluetooth.BluetoothGattServerCallback;
import android.bluetooth.BluetoothGattService;
import android.bluetooth.BluetoothManager;
import android.bluetooth.le.AdvertiseCallback;
import android.bluetooth.le.AdvertiseData;
import android.bluetooth.le.AdvertiseSettings;
import android.bluetooth.le.BluetoothLeAdvertiser;
import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.content.IntentFilter;
import android.os.ParcelUuid;
import android.os.SystemClock;
import android.util.Log;
import com.roy.www.ble_peripheral_api.protocol.BleCommPack;
import com.roy.www.ble_peripheral_api.protocol.BleCommand;
import com.roy.www.ble_peripheral_api.utils.CRC16;
import com.roy.www.ble_peripheral_api.utils.HexDump;

import java.util.Arrays;
import java.util.UUID;

/**
 * Created by Roy.lee
 * On 2021/6/27
 * Email: 631934797@qq.com
 * Description:
 */
public class BlePeripheralHelper {

    private static final String TAG = "@@@ ===> " + BlePeripheralHelper.class.getSimpleName();

// 这里的参数可自行定义
    private static String BLE_NAME = "SmartBox";
    private static final UUID UUID_SERVER = UUID.fromString("0000fff0-0000-1000-8000-00805f9b34fb");
    private static final UUID UUID_CHARREAD = UUID.fromString("0000fff1-0000-1000-8000-00805f9b34fb");
    private static final UUID UUID_CHARWRITE = UUID.fromString("0000fff2-0000-1000-8000-00805f9b34fb");
    private static final UUID UUID_DESCRIPTOR = UUID.fromString("00002902-0000-1000-8000-00805f9b34fb");
    private BluetoothGattCharacteristic mCharacteristicRead;

    //BluetoothHelper
    private static BlePeripheralHelper mBlePeripheralHelper;
    private BluetoothManager mBluetoothManager;
    private BluetoothAdapter mBluetoothAdapter;
    private static Context mContext;
    private BluetoothLeAdvertiser mBluetoothLeAdvertiser;
    private BluetoothGattServer mBluetoothGattServer;
    private BlePeripheralCallback mBlePeripheralCallback;

    private BlePeripheralHelper() {
        initPeripheral(mContext);
    }

    /**
     * 获取BleController实例对象
     * @return
     */
    public synchronized static BlePeripheralHelper getInstance(Context context) {
        mContext = context;
        if (null == mBlePeripheralHelper) {
            mBlePeripheralHelper = new BlePeripheralHelper();

        }
        return mBlePeripheralHelper;
    }

    /**
     * 初始化BLE相关参数
     *
     * @param context
     */
    private void initPeripheral(Context context) {
        // 初始化mBluetoothManager
        mBluetoothManager = getBleManager(mContext);
        // 初始化mBluetoothAdapter
        mBluetoothAdapter = getBluetoothAdapter();

        if (isBleEnabled()){
            mBluetoothLeAdvertiser = getBluetoothLeAdvertiser();
        }else {
            if (setBleEnabled(true)){
                SystemClock.sleep(1000);
                mBluetoothLeAdvertiser = getBluetoothLeAdvertiser();
            }
        }

        if (mBluetoothLeAdvertiser == null){
           Log.e(TAG, "== The device not support peripheral ==");
        }

        // 注册BLE的状态变化广播
        context.registerReceiver(mBluetoothReceiver, makeGattUpdateIntentFilter());

    }

    /**
     * 初始化BLE广播
     */
    public void initGATTServer() {
        initGATTServer(null);
    }

    /**
     * 初始化BLE广播并设置BEL_NAME
     * @param bleName
     */
    public void initGATTServer(String bleName) {

        if (bleName != null && !bleName.isEmpty())
            BLE_NAME = bleName;
        AdvertiseSettings settings = new AdvertiseSettings.Builder()
                .setConnectable(true) //是否被连接
                .setTimeout(0)        //超时时间
                .setAdvertiseMode(AdvertiseSettings.ADVERTISE_MODE_BALANCED)  //广播模式
                .setTxPowerLevel(AdvertiseSettings.ADVERTISE_TX_POWER_HIGH)   //发射功率
                .build();

        AdvertiseData advertiseData = new AdvertiseData.Builder()
                .setIncludeDeviceName(true)    //是否在广播中携带设备的名称
                .setIncludeTxPowerLevel(true)  //是否在广播中携带信号强度
                .build();

        AdvertiseData scanResponseData = new AdvertiseData.Builder()
                .addServiceUuid(new ParcelUuid(UUID_SERVER))
                .setIncludeTxPowerLevel(true)
                .build();

        //设置BLE设备的名称
        mBluetoothAdapter.setName(BLE_NAME);

        /**
         * 开启广播的结果callback
         */
        AdvertiseCallback mAdCallback = new AdvertiseCallback() {

            @Override
            public void onStartSuccess(AdvertiseSettings settingsInEffect) {
                Log.d(TAG, "BLE advertisement added successfully");

                // TODO 初始化服务
                initServices();
                if (mBlePeripheralCallback != null)
                    mBlePeripheralCallback.onStartAbSuccess(settingsInEffect);

            }

            @Override
            public void onStartFailure(int errorCode) {
                Log.e(TAG, "Failed to add BLE advertisement, reason: " + errorCode);
                if (mBlePeripheralCallback != null)
                    mBlePeripheralCallback.onStartAbFailure(errorCode);
            }
        };

        //开启广播
        if (mBluetoothLeAdvertiser != null)
            mBluetoothLeAdvertiser.startAdvertising(settings, advertiseData, scanResponseData, mAdCallback);

    }

    /**
     * 初始化广播服务参数
     */
    private void initServices() {
        mBluetoothGattServer = getBluetoothGattServer(mBluetoothGattServerCallback);
        BluetoothGattService service = new BluetoothGattService(UUID_SERVER, BluetoothGattService.SERVICE_TYPE_PRIMARY);

        //add a read characteristic.
        mCharacteristicRead = new BluetoothGattCharacteristic(UUID_CHARREAD, BluetoothGattCharacteristic.PROPERTY_READ, BluetoothGattCharacteristic.PERMISSION_READ);
        //add a descriptor
        BluetoothGattDescriptor descriptor = new BluetoothGattDescriptor(UUID_DESCRIPTOR, BluetoothGattCharacteristic.PERMISSION_WRITE);
        mCharacteristicRead.addDescriptor(descriptor);
        service.addCharacteristic(mCharacteristicRead);

        //add a write characteristic.
        BluetoothGattCharacteristic characteristicWrite = new BluetoothGattCharacteristic(UUID_CHARWRITE,
                BluetoothGattCharacteristic.PROPERTY_WRITE |
                        BluetoothGattCharacteristic.PROPERTY_READ |
                        BluetoothGattCharacteristic.PROPERTY_NOTIFY,
                BluetoothGattCharacteristic.PERMISSION_WRITE);
        service.addCharacteristic(characteristicWrite);

        mBluetoothGattServer.addService(service);
        Log.e(TAG, "2. initServices ok");

    }

    /**
     * 获取BluetoothLeAdvertiser
     *
     */
    private BluetoothLeAdvertiser getBluetoothLeAdvertiser() {
        return  mBluetoothAdapter == null ? null : mBluetoothAdapter.getBluetoothLeAdvertiser();
    }

    /**
     * 获取BluetoothGattServer
     *
     */
    private BluetoothGattServer getBluetoothGattServer(BluetoothGattServerCallback bluetoothGattServerCallback){
       return mBluetoothManager == null ? null : mBluetoothManager.openGattServer(mContext, bluetoothGattServerCallback);
    }

    /**
     * 获取BluetoothManager
     *
     * @param context
     * @return
     */
    private BluetoothManager getBleManager(Context context) {
        return context == null ? null : (BluetoothManager) context.getSystemService(Context.BLUETOOTH_SERVICE);
    }

    /**
     * 获取BluetoothAdapter
     *
     * @return
     */
    private BluetoothAdapter getBluetoothAdapter(){
        return mBluetoothManager == null ? null : mBluetoothManager.getAdapter();
    }

    /**
     *
     * 开启/关闭BLE
     *
     * @param enabled
     * @return
     */
    public boolean setBleEnabled(boolean enabled){

        if (enabled){
            return  mBluetoothAdapter == null ? false : mBluetoothAdapter.enable();
        }else {
            return  mBluetoothAdapter == null ? false : mBluetoothAdapter.disable();
        }

    }

    /**
     * 获取BLE状态
     * @return
     */
    public boolean isBleEnabled(){
        return  mBluetoothAdapter == null ? false : mBluetoothAdapter.isEnabled();
    }


// ========================================================BluetoothGattServerCallback=========================================


    /**
     * 服务事件的回调
     */
    private BluetoothGattServerCallback mBluetoothGattServerCallback = new BluetoothGattServerCallback() {

        /**
         * 1.连接状态发生变化时
         * @param device
         * @param status
         * @param newState
         */
        @Override
        public void onConnectionStateChange(BluetoothDevice device, int status, int newState) {
            Log.w(TAG,"onConnectionStateChange  [ status : " + status + " |  newState : " + newState + "]");

            Log.e(TAG, String.format("1.onConnectionStateChange:device name = %s, address = %s", device.getName(), device.getAddress()));
            Log.e(TAG, String.format("1.onConnectionStateChange:status = %s, newState =%s ", status, newState));
            super.onConnectionStateChange(device, status, newState);
            if (mBlePeripheralCallback != null)
                mBlePeripheralCallback.onConnectionStateChange(device, status, newState);
        }

        @Override
        public void onServiceAdded(int status, BluetoothGattService service) {
            super.onServiceAdded(status, service);
            Log.e(TAG, String.format("onServiceAdded:status = %s", status));
        }

        @Override
        public void onCharacteristicReadRequest(BluetoothDevice device, int requestId, int offset, BluetoothGattCharacteristic characteristic) {
            Log.e(TAG, String.format("onCharacteristicReadRequest:device name = %s, address = %s", device.getName(), device.getAddress()));
            Log.e(TAG, String.format("onCharacteristicReadRequest:requestId = %s, offset = %s", requestId, offset));

            mBluetoothGattServer.sendResponse(device, requestId, BluetoothGatt.GATT_SUCCESS, offset, characteristic.getValue());
//            super.onCharacteristicReadRequest(device, requestId, offset, characteristic);
        }

        /**
         * 3. onCharacteristicWriteRequest,接收具体的字节
         * @param device
         * @param requestId
         * @param characteristic
         * @param preparedWrite
         * @param responseNeeded
         * @param offset
         * @param requestBytes
         */
        @Override
        public void onCharacteristicWriteRequest(BluetoothDevice device, int requestId, BluetoothGattCharacteristic characteristic, boolean preparedWrite, boolean responseNeeded, int offset, byte[] requestBytes) {
            Log.e(TAG, String.format("3.onCharacteristicWriteRequest:device name = %s, address = %s", device.getName(), device.getAddress()));
            Log.e(TAG, String.format("3.onCharacteristicWriteRequest:requestId = %s, preparedWrite=%s, responseNeeded=%s, offset=%s, value=%s", requestId, preparedWrite, responseNeeded, offset, HexDump.byteTo16String(requestBytes)));
            mBluetoothGattServer.sendResponse(device, requestId, BluetoothGatt.GATT_SUCCESS, offset, requestBytes);
            //  TODO 4.处理响应内容
            onResponseToClient( device, requestId, characteristic,requestBytes);
        }

        /**
         * 2.描述被写入时,在这里执行 bluetoothGattServer.sendResponse(device, requestId, BluetoothGatt.GATT_SUCCESS...  收,触发 onCharacteristicWriteRequest
         * @param device
         * @param requestId
         * @param descriptor
         * @param preparedWrite
         * @param responseNeeded
         * @param offset
         * @param value
         */
        @Override
        public void onDescriptorWriteRequest(BluetoothDevice device, int requestId, BluetoothGattDescriptor descriptor, boolean preparedWrite, boolean responseNeeded, int offset, byte[] value) {
            Log.e(TAG, String.format("2.onDescriptorWriteRequest:device name = %s, address = %s", device.getName(), device.getAddress()));
            Log.e(TAG, String.format("2.onDescriptorWriteRequest:requestId = %s, preparedWrite = %s, responseNeeded = %s, offset = %s, value = %s,", requestId, preparedWrite, responseNeeded, offset, HexDump.byteTo16String(value)));

            // now tell the connected device that this was all successfull
            mBluetoothGattServer.sendResponse(device, requestId, BluetoothGatt.GATT_SUCCESS, offset, value);
        }

        /**
         * 5.特征被读取。当回复响应成功后,客户端会读取然后触发本方法
         * @param device
         * @param requestId
         * @param offset
         * @param descriptor
         */
        @Override
        public void onDescriptorReadRequest(BluetoothDevice device, int requestId, int offset, BluetoothGattDescriptor descriptor) {
            Log.e(TAG, String.format("onDescriptorReadRequest:device name = %s, address = %s", device.getName(), device.getAddress()));
            Log.e(TAG, String.format("onDescriptorReadRequest:requestId = %s", requestId));
//            super.onDescriptorReadRequest(device, requestId, offset, descriptor);
            mBluetoothGattServer.sendResponse(device, requestId, BluetoothGatt.GATT_SUCCESS, offset, null);
        }

        @Override
        public void onNotificationSent(BluetoothDevice device, int status) {
            super.onNotificationSent(device, status);
            Log.e(TAG, String.format("5.onNotificationSent:device name = %s, address = %s", device.getName(), device.getAddress()));
            Log.e(TAG, String.format("5.onNotificationSent:status = %s", status));
        }

        @Override
        public void onMtuChanged(BluetoothDevice device, int mtu) {
            super.onMtuChanged(device, mtu);
            Log.e(TAG, String.format("onMtuChanged:mtu = %s", mtu));
        }

        @Override
        public void onExecuteWrite(BluetoothDevice device, int requestId, boolean execute) {
            super.onExecuteWrite(device, requestId, execute);
            Log.e(TAG, String.format("onExecuteWrite:requestId = %s", requestId));
        }
    };

    /**
     * 4.处理响应内容
     *
     * @param reqeustBytes
     * @param device
     * @param requestId
     * @param characteristic
     */
    private void onResponseToClient(BluetoothDevice device, int requestId, BluetoothGattCharacteristic characteristic, byte[] reqeustBytes) {
        Log.e(TAG, String.format("4.onResponseToClient:device name = %s, address = %s", device.getName(), device.getAddress()));
        Log.e(TAG, String.format("4.onResponseToClient:requestId = %s", requestId));

        if (mBlePeripheralCallback != null){
            // 数据回调
            mBlePeripheralCallback.onReceiveNewBytes(device, requestId, characteristic, reqeustBytes);
 
        }

    }


    /**
     * 发送数据
     * @param device
     * @param data
     * @return
     */

    public boolean transfer(BluetoothDevice device, byte[] data){
       if (notify(device,mCharacteristicRead,data)){
           if (mBlePeripheralCallback != null)
                mBlePeripheralCallback.onWriteBytesAndStatus(true, data);
           return true;
       }else {
           if (mBlePeripheralCallback != null)
               mBlePeripheralCallback.onWriteBytesAndStatus(false, data);
           return false;
       }
    }


    /**
     * 发送通知给主机
     *
     * @param device         :发送的目标设备
     * @param characteristic :用来通知的characteristic
     * @param data           :通知的内容
     */
    private boolean notify(BluetoothDevice device, BluetoothGattCharacteristic characteristic, byte[] data) {
        if (device != null && characteristic != null && data != null) {
            //设置写操作的类型 WRITE_TYPE_DEFAULT的情况选  底层会自动分包 不用人为分包
            characteristic.setWriteType(BluetoothGattCharacteristic.WRITE_TYPE_DEFAULT);
            //把要设置的数据装进characteristic
            characteristic.setValue(data);
            //发送出去
            return mBluetoothGattServer.notifyCharacteristicChanged(device, characteristic, false);
        } else {
            return false;
        }

    }


    /**
     *
     * @return
     */
    public BlePeripheralCallback getBlePeripheralCallback() {
        return mBlePeripheralCallback;
    }

    public void setBlePeripheralCallback(BlePeripheralCallback blePeripheralCallback) {
        this.mBlePeripheralCallback = blePeripheralCallback;
    }


    //========================================================BluetoothReceiver======================================================


    private static IntentFilter makeGattUpdateIntentFilter() {
        final IntentFilter intentFilter = new IntentFilter();
        intentFilter.addAction(BluetoothAdapter.ACTION_STATE_CHANGED);

        intentFilter.addAction(BluetoothA2dp.ACTION_CONNECTION_STATE_CHANGED);
        intentFilter.addAction(BluetoothA2dp.ACTION_PLAYING_STATE_CHANGED);
        intentFilter.addAction(BluetoothDevice.ACTION_FOUND);
        intentFilter.addAction(BluetoothDevice.ACTION_BOND_STATE_CHANGED);
        intentFilter.addAction(BluetoothAdapter.ACTION_STATE_CHANGED);
        return intentFilter;
    }

    // 监听BLE状态变化
    private BroadcastReceiver mBluetoothReceiver = new BroadcastReceiver() {
        @Override
        public void onReceive(Context context, Intent intent) {
            Log.i(TAG,"=========蓝牙接收处理广播========"+intent.getAction());
            BluetoothDevice device;

            switch (intent.getAction()){
                case BluetoothAdapter.ACTION_STATE_CHANGED:
                    int bleState = intent.getIntExtra(BluetoothAdapter.EXTRA_STATE, -1);
                    switch (bleState) {
                        case BluetoothAdapter.STATE_TURNING_OFF:
                            Log.i(TAG, "...正在关闭蓝牙...");
                            break;
                        case BluetoothAdapter.STATE_OFF:
                            Log.i(TAG, "...蓝牙已关闭!");
                            break;
                        case BluetoothAdapter.STATE_TURNING_ON:
                            Log.i(TAG, "...正在开启蓝牙...");
                            break;
                        case BluetoothAdapter.STATE_ON:
                            Log.i(TAG, "...蓝牙已开启...");

                            if (mBlePeripheralHelper != null)
                                initPeripheral(mContext);
                                initGATTServer();
                            break;
                    }
                    break;

                case BluetoothA2dp.ACTION_CONNECTION_STATE_CHANGED:
                    switch (intent.getIntExtra(BluetoothA2dp.EXTRA_STATE, -1)) {

                        case BluetoothA2dp.STATE_CONNECTING:
                            device = intent.getParcelableExtra(BluetoothDevice.EXTRA_DEVICE);
                            Log.i(TAG,"device: " + device.getName() +" connecting");
                            break;
                        case BluetoothA2dp.STATE_CONNECTED:
                            device = intent.getParcelableExtra(BluetoothDevice.EXTRA_DEVICE);
                            Log.i(TAG,"device: " + device.getName() +" connected");

                            break;
                        case BluetoothA2dp.STATE_DISCONNECTING:
                            device = intent.getParcelableExtra(BluetoothDevice.EXTRA_DEVICE);
                            Log.i(TAG,"device: " + device.getName() +" disconnecting");
                            break;
                        case BluetoothA2dp.STATE_DISCONNECTED:
                            device = intent.getParcelableExtra(BluetoothDevice.EXTRA_DEVICE);
                            Log.i(TAG,"device: " + device.getName() +" disconnected");
                            break;
                        default:
                            break;
                    }
                    break;

                case BluetoothA2dp.ACTION_PLAYING_STATE_CHANGED:
                    int state = intent.getIntExtra(BluetoothA2dp.EXTRA_STATE, -1);
                    switch (state) {
                        case BluetoothA2dp.STATE_PLAYING:
                            Log.i(TAG,"state: playing.");
                            break;
                        case BluetoothA2dp.STATE_NOT_PLAYING:
                            Log.i(TAG,"state: not playing");
                            break;
                        default:
                            Log.i(TAG,"state: unkown");
                            break;
                    }
                    break;



                case BluetoothDevice.ACTION_BOND_STATE_CHANGED:
                    int bondState = intent.getIntExtra(BluetoothDevice.EXTRA_BOND_STATE, BluetoothDevice.BOND_NONE);
                    device = intent.getParcelableExtra(BluetoothDevice.EXTRA_DEVICE);
                    switch (bondState){
                        case BluetoothDevice.BOND_BONDED:  //配对成功
                            Log.i(TAG,"Device:"+device.getName()+" bonded.");
                            //取消搜索,连接蓝牙设备
                            break;
                        case BluetoothDevice.BOND_BONDING:
                            Log.i(TAG,"Device:"+device.getName()+" bonding.");
                            break;
                        case BluetoothDevice.BOND_NONE:
                            Log.i(TAG,"Device:"+device.getName()+" not bonded.");

                            break;
                        default:
                            break;
                    }
                    break;


                default:
                    break;
            }
        }
    };

}


3:使用方式:
 BlePeripheralHelper  mBlePeripheralHelper = BlePeripheralHelper.getInstance(this);
  if (mBlePeripheralHelper.isEnabled()){
            // 设置回调
          mBlePeripheralHelper.setBlePeripheralCallback(new BlePeripheralCallback() {
                            //连接状态回调
                            @Override
                            public void onConnectionStateChange(BluetoothDevice bluetoothDevice, int i, int i1) {
                                
                            }

                            //开启广播成功回调
                            @Override
                            public void onStartAbSuccess(AdvertiseSettings advertiseSettings) {

                            }

                             //开启广失败的功回调
                            @Override
                            public void onStartAbFailure(int i) {
                                    
                            }
                            //收到BLE数据回调
                            @Override
                            public void onReceiveNewBytes(BluetoothDevice bluetoothDevice, int i, BluetoothGattCharacteristic bluetoothGattCharacteristic, byte[] bytes) {
                            
                            }

                            //发送BLE数据回调
                            @Override
                            public void onWriteBytesAndStatus(boolean b, byte[] bytes) {

                            }
                        });


            // 初始化广播
            mBlePeripheralHelper.initGATTServer();
   }

最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
禁止转载,如需转载请通过简信或评论联系作者。
  • 序言:七十年代末,一起剥皮案震惊了整个滨河市,随后出现的几起案子,更是在滨河造成了极大的恐慌,老刑警刘岩,带你破解...
    沈念sama阅读 203,772评论 6 477
  • 序言:滨河连续发生了三起死亡事件,死亡现场离奇诡异,居然都是意外死亡,警方通过查阅死者的电脑和手机,发现死者居然都...
    沈念sama阅读 85,458评论 2 381
  • 文/潘晓璐 我一进店门,熙熙楼的掌柜王于贵愁眉苦脸地迎上来,“玉大人,你说我怎么就摊上这事。” “怎么了?”我有些...
    开封第一讲书人阅读 150,610评论 0 337
  • 文/不坏的土叔 我叫张陵,是天一观的道长。 经常有香客问我,道长,这世上最难降的妖魔是什么? 我笑而不...
    开封第一讲书人阅读 54,640评论 1 276
  • 正文 为了忘掉前任,我火速办了婚礼,结果婚礼上,老公的妹妹穿的比我还像新娘。我一直安慰自己,他们只是感情好,可当我...
    茶点故事阅读 63,657评论 5 365
  • 文/花漫 我一把揭开白布。 她就那样静静地躺着,像睡着了一般。 火红的嫁衣衬着肌肤如雪。 梳的纹丝不乱的头发上,一...
    开封第一讲书人阅读 48,590评论 1 281
  • 那天,我揣着相机与录音,去河边找鬼。 笑死,一个胖子当着我的面吹牛,可吹牛的内容都是我干的。 我是一名探鬼主播,决...
    沈念sama阅读 37,962评论 3 395
  • 文/苍兰香墨 我猛地睁开眼,长吁一口气:“原来是场噩梦啊……” “哼!你这毒妇竟也来了?” 一声冷哼从身侧响起,我...
    开封第一讲书人阅读 36,631评论 0 258
  • 序言:老挝万荣一对情侣失踪,失踪者是张志新(化名)和其女友刘颖,没想到半个月后,有当地人在树林里发现了一具尸体,经...
    沈念sama阅读 40,870评论 1 297
  • 正文 独居荒郊野岭守林人离奇死亡,尸身上长有42处带血的脓包…… 初始之章·张勋 以下内容为张勋视角 年9月15日...
    茶点故事阅读 35,611评论 2 321
  • 正文 我和宋清朗相恋三年,在试婚纱的时候发现自己被绿了。 大学时的朋友给我发了我未婚夫和他白月光在一起吃饭的照片。...
    茶点故事阅读 37,704评论 1 329
  • 序言:一个原本活蹦乱跳的男人离奇死亡,死状恐怖,灵堂内的尸体忽然破棺而出,到底是诈尸还是另有隐情,我是刑警宁泽,带...
    沈念sama阅读 33,386评论 4 319
  • 正文 年R本政府宣布,位于F岛的核电站,受9级特大地震影响,放射性物质发生泄漏。R本人自食恶果不足惜,却给世界环境...
    茶点故事阅读 38,969评论 3 307
  • 文/蒙蒙 一、第九天 我趴在偏房一处隐蔽的房顶上张望。 院中可真热闹,春花似锦、人声如沸。这庄子的主人今日做“春日...
    开封第一讲书人阅读 29,944评论 0 19
  • 文/苍兰香墨 我抬头看了看天上的太阳。三九已至,却和暖如春,着一层夹袄步出监牢的瞬间,已是汗流浃背。 一阵脚步声响...
    开封第一讲书人阅读 31,179评论 1 260
  • 我被黑心中介骗来泰国打工, 没想到刚下飞机就差点儿被人妖公主榨干…… 1. 我叫王不留,地道东北人。 一个月前我还...
    沈念sama阅读 44,742评论 2 349
  • 正文 我出身青楼,却偏偏与公主长得像,于是被迫代替她去往敌国和亲。 传闻我的和亲对象是个残疾皇子,可洞房花烛夜当晚...
    茶点故事阅读 42,440评论 2 342

推荐阅读更多精彩内容

  • 转载请注明出处:http://blog.csdn.net/vnanyesheshou/article/detail...
    皮子熙阅读 1,937评论 0 0
  • 因为自己的项目中有用到了蓝牙相关的功能,所以之前也断断续续地针对蓝牙通信尤其是BLE通信进行了一番探索,整理出了一...
    陈利健阅读 113,473评论 172 294
  • 1.前言 随着智能穿戴的普及,蓝牙开发也火热起来。不过与传统蓝牙开发不一样的是,由于考虑到穿戴设备的电量问题和使用...
    lanceJin阅读 2,230评论 0 9
  • BLE 即 Bluetooth Low Energy,蓝牙低功耗技术,是蓝牙4.0引入的新技术。现在越来越多的智能...
    fengmlo阅读 8,072评论 3 10
  • 最近入职一家公司做物联网模块,我负责手机蓝牙和设备通信模块。经过几天的摸索与实践,做一下笔记和分享。 一、理解BL...
    Ayres阅读 1,818评论 0 2