ble 蓝牙在Read方法中读取数据每次只能读取一次,怎么做可以循环读取? 10C

ble蓝牙开发中我们onServicesDiscovered()方法中遍历服务后并且设置数据,然后再onCharacteristicRead()方法中读取数据,然而在读取的方法中每次只能自动读取一次,只有当有数据变化时才会再次读取,但是我想一次读取多个数据,不需要其他的操作,代码怎么实现?下面是我在读取方法中写的,每次只能读取一个数据。求大神帮帮忙?

   List<BluetoothGattService> services = gatt.getServices();
                for (BluetoothGattService s : services) {
                    List<BluetoothGattCharacteristic> gattCharacteristicss = s.getCharacteristics();
                    for (int i = 0; i < gattCharacteristicss.size(); i++) {
                        BluetoothGattCharacteristic gattCharacteristic = gattCharacteristicss.get(i);
                        Log.e("000", "gattCharacteristicss:" + i + ":" + gattCharacteristic.getUuid().toString());
                        if (gattCharacteristic.getUuid().toString().equals(SampleGattAttributes
                                .GAMESIR_BLE_CHARACTERISTICS_X1_Manifacturer)) {

                            try {
                                manifacturer = new String(gattCharacteristic.getValue(), "UTF-8");
                            } catch (UnsupportedEncodingException e) {
                                e.printStackTrace();
                            }
                            Log.e("000", "Manifacturer:" + manifacturer);

                        }

//
                        if (gattCharacteristic.getUuid().toString().equals(SampleGattAttributes
                                .GAMESIR_BLE_CHARACTERISTICS_X1_Software)) {

                            try {
                                software = new String(gattCharacteristic.getValue(), "UTF-8");
                            } catch (UnsupportedEncodingException e) {
                                e.printStackTrace();
                            }
                            Log.e("000", "Software:" + software);
                        }

                        else if (gattCharacteristic.getUuid().toString().equals(SampleGattAttributes
                                .dISHardwareREV_UUID)) {

                            try {
                                hardware = new String(gattCharacteristic.getValue(), "UTF-8");
                            } catch (UnsupportedEncodingException e) {
                                e.printStackTrace();
                            }
                            Log.e("000", "Hardware:" + hardware);
//
                        }
                        else if (gattCharacteristic.getUuid().toString().equals(SampleGattAttributes
                                .GAMESIR_BLE_CHARACTERISTICS_X1_FIRMWARE)) {

                            try {
                                version = new String(gattCharacteristic.getValue(), "UTF-8");
                                Log.e("000", "firmware_version数据1:" + version);
                                UpdateUiUtil.setFirmWare(version);
                            } catch (UnsupportedEncodingException e) {
                                e.printStackTrace();
                            }
////////
                        }
                        else if (gattCharacteristic.getUuid().toString().equals(SampleGattAttributes
                                .dISSerialNR_UUID)) {

                            try {
                                serial = new String(gattCharacteristic.getValue(), "UTF-8");
                            } catch (UnsupportedEncodingException e) {
                                e.printStackTrace();
                            }
                            Log.e("000", "Serial:" + serial);
                        } else if (gattCharacteristic.getUuid().toString().equals(SampleGattAttributes
                                .dISModelNR_UUID)) {

                            try {
                                model = new String(gattCharacteristic.getValue(), "UTF-8");
                            } catch (UnsupportedEncodingException e) {
                                e.printStackTrace();
                            }
                            Log.e("000", "Model:" + model);
//
                        } else if (gattCharacteristic.getUuid().toString().equals(SampleGattAttributes
                                .dISSystemID_UUID)) {

                            try {
                                systemID = new String(gattCharacteristic.getValue(), "UTF-8");
                            } catch (UnsupportedEncodingException e) {
                                e.printStackTrace();
                            }
                            Log.e("000", "SystemID:" + systemID);
                        }

hanfengwuyu
某-某 onCharacteristicChanged,在这个回调里返回数据,可能是多条。我的做法是,在onCharacteristicChanged里面调用readCharacteristic(characteristic);然后把返回的数据,除了第一条都拼一起(第一条是你发送的数据),然后在onCharacteristicRead这个回调里面,吧拼好的byte[],发到你要用的地方,并且清除数据。
9 个月之前 回复

2个回答

onCharacteristicChanged,在这个回调里返回数据,可能是多条。我的做法是,在onCharacteristicChanged里面调用readCharacteristic(characteristic);然后把返回的数据,除了第一条都拼一起(第一条是你发送的数据),然后在onCharacteristicRead这个回调里面,吧拼好的byte[],发到你要用的地方,并且清除数据。

Csdn user default icon
上传中...
上传图片
插入图片
抄袭、复制答案,以达到刷声望分或其他目的的行为,在CSDN问答是严格禁止的,一经发现立刻封号。是时候展现真正的技术了!
其他相关推荐
安卓蓝牙BLE只能发送数据,不能接收数据,求教求教!

用的QN9021蓝牙模块,串口助手监控; ![图片说明](https://img-ask.csdn.net/upload/201602/16/1455633053_721235.png) 找到能够发送数据的characteristic,发送数据,串口助手收到数据 ![图片说明](https://img-ask.csdn.net/upload/201602/16/1455633137_465921.png) ![图片说明](https://img-ask.csdn.net/upload/201602/16/1455633201_988068.png) 串口助手发送数据,接收数据总是null或者0,接收不到数据 ![图片说明](https://img-ask.csdn.net/upload/201602/16/1455633298_320514.png) 所有的characteristic都试过了,还是不能读到数据,十分困惑,求教!!!

Android BLE 在不知道蓝牙设备的Notify特征的情况下如何接收数据

之前有个设备,使用nRFConnect工具扫描出了所有的UUID,然后通过Notify的特征值实现了接收数据。今天忽然换了个不知道从哪儿找来的设备,居然扫描不出Notify。但是用nRFConnect工具依然可以收到数据,而且还是通过Notify的方式。这就很懵了,现在这个设备用我自己的代码是能发数据,但是不能接收数据。可否给个思路,图在下面~~~然后多句嘴,这个设备是老板(兼硬件)不知道从哪儿翻出来的,估计是很久以前的库存,为了节约成本已经决定用这款设备了,问他一问三不知……![图片说明](https://img-ask.csdn.net/upload/201911/07/1573127036_174409.png)

关于蓝牙4.0 BLE读取电量的问题

private void displayGattServices(List<BluetoothGattService> gattServices){ if(gattServices == null) return; String uuid = null; for(BluetoothGattService gattService : gattServices){ uuid = gattService.getUuid().toString(); if(uuid.equalsIgnoreCase(BATTERY_SERVICE)){ String uuid_charas = null; List<BluetoothGattCharacteristic> gattCharacteristics = gattService.getCharacteristics(); for(BluetoothGattCharacteristic gattCharacteristic : gattCharacteristics){ uuid_charas = gattCharacteristic.getUuid().toString(); if(uuid_charas.equalsIgnoreCase(BATTERY_CHARATERISTIC)){ final int charaProp = gattCharacteristic.getProperties(); if ((charaProp | BluetoothGattCharacteristic.PROPERTY_READ) > 0) { if (mNotifyCharacteristic != null) { mBluetoothLeService.setCharacteristicNotification(mNotifyCharacteristic, false); mNotifyCharacteristic = null; } mBluetoothLeService.readCharacteristic(gattCharacteristic); } if ((charaProp | BluetoothGattCharacteristic.PROPERTY_NOTIFY) > 0) { mNotifyCharacteristic = gattCharacteristic; mBluetoothLeService.setCharacteristicNotification(gattCharacteristic, true); } } } } } } private void broadcastUpdate(String action,BluetoothGattCharacteristic characteristic){ final Intent intent = new Intent(action); if(UUID_HEART_RATE_MEASUREMENT.equals(characteristic .getUuid())){ int flag = characteristic.getProperties(); int format = -1; if((flag&0x01) != 0){ format = BluetoothGattCharacteristic.FORMAT_UINT16; }else { format = BluetoothGattCharacteristic.FORMAT_UINT8; } final int heartRate = characteristic.getIntValue(format,1); intent.putExtra(EXTRA_DATA,String.valueOf(heartRate)); }else { final byte[] data = characteristic.getValue(); if(data != null && data.length >0){ final StringBuilder stringBuilder = new StringBuilder(data.length); for(byte byteChar: data) stringBuilder.append(String.format("%02X",byteChar)); intent.putExtra(EXTRA_DATA,new String(data)+"\n"+stringBuilder.toString()); } } sendBroadcast(intent); } 读取到了电量的特征值,但是显示d 64,怎么让它解析成百分比的形式显示在text文本?求各位大侠拔刀相助!~

android ble蓝牙广播问题!!!!!!!!!!!!!!!!!!

使用ble蓝牙开发 在写入数据之后 设备返回的数据证明发送成功了 但是在广播中也会返回数据,我这边接收不到 使用别人的demo 可以接收到数据 这里有demo 哪位大哥帮忙看看代码有没有什么问题。 ``` package com.example.andysong.nuclearradiation.Ble; import android.bluetooth.BluetoothAdapter; import android.bluetooth.BluetoothDevice; import android.bluetooth.BluetoothGatt; import android.bluetooth.BluetoothGattCallback; import android.bluetooth.BluetoothGattCharacteristic; import android.bluetooth.BluetoothGattDescriptor; import android.bluetooth.BluetoothGattService; import android.bluetooth.BluetoothProfile; import android.companion.BluetoothDeviceFilter; import android.os.Bundle; import android.support.v7.app.AppCompatActivity; import android.support.v7.widget.LinearLayoutManager; import android.support.v7.widget.RecyclerView; import android.util.Log; import android.view.View; import android.widget.Button; import android.widget.LinearLayout; import android.widget.Toast; import com.example.andysong.nuclearradiation.Ble.Adapter.MyAdapter; import com.example.andysong.nuclearradiation.Ble.BleTool.MyBluetoothDevice; import com.example.andysong.nuclearradiation.Ble.Entity.BleData; import com.example.andysong.nuclearradiation.R; import com.example.andysong.nuclearradiation.Uitl.Progess.DialProgress; import java.io.UnsupportedEncodingException; import java.util.HashMap; import java.util.List; import java.util.Map; import java.util.Set; import java.util.UUID; public class BleActivityTest extends AppCompatActivity implements View.OnClickListener, MyAdapter.OnScan { private static final String TAG = BleActivityTest.class.getName(); private Button btn_scan; private Button btn_w; private RecyclerView rv_list; private MyAdapter myAdapter; private BluetoothAdapter bAdapter; private BluetoothGatt bluetoothGatt; private Map<String, UUID> uuidMap; //private UUID uNotify = UUID.fromString("6e400003-b5a3-f393-e0a9-e50e24dcca9e"); //private UUID N_Notify = UUID.fromString("0000ffe0-0000-1000-8000-00805f9b34fb"); private UUID N_Notify = UUID.fromString("00001000-0000-1000-8000-00805f9b34fb"); //private UUID uNotify = UUID.fromString("0000ffe4-0000-1000-8000-00805f9b34fb"); private UUID uNotify = UUID.fromString("00001002-0000-1000-8000-00805f9b34fb"); //private UUID uRead = UUID.fromString("6e400003-b5a3-f393-e0a9-e50e24dcca9e"); //private UUID uWrite = UUID.fromString("6e400003-b5a3-f393-e0a9-e50e24dcca9e"); //private UUID N_Write = UUID.fromString("0000ffe5-0000-1000-8000-00805f9b34fb"); private UUID N_Write = UUID.fromString("00001000-0000-1000-8000-00805f9b34fb"); private static final UUID CLIENT_CHARACTERISTIC_CONFIG = UUID.fromString( "00002902-0000-1000-8000-00805f9b34fb"); //private UUID uWrite = UUID.fromString("0000ffe9-0000-1000-8000-00805f9b34fb"); private UUID uWrite = UUID.fromString("00001001-0000-1000-8000-00805f9b34fb"); private String READ = "read"; private String WRITE = "write"; private String NOTICE = "notice"; private Button btn_r; private Button btn_n; private Button btn_c; private DialProgress dialProgress; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_ble); initView(); initData(); } private void initView() { btn_scan = findViewById(R.id.btn_scan); btn_w = findViewById(R.id.btn_w); btn_r = findViewById(R.id.btn_r); btn_n = findViewById(R.id.btn_n); btn_c = findViewById(R.id.btn_c); btn_scan.setOnClickListener(this); btn_w.setOnClickListener(this); btn_r.setOnClickListener(this); btn_n.setOnClickListener(this); btn_c.setOnClickListener(this); rv_list = findViewById(R.id.rv_list); rv_list.setLayoutManager(new LinearLayoutManager(this, LinearLayout.VERTICAL, false)); myAdapter = new MyAdapter(this); myAdapter.setOnScan(this); rv_list.setAdapter(myAdapter); dialProgress = findViewById(R.id.dialprog); } private void initData() { bAdapter = BluetoothAdapter.getDefaultAdapter(); uuidMap = new HashMap<>(); } @Override public void onClick(View v) { switch (v.getId()) { case R.id.btn_scan: scan(); break; case R.id.btn_w: writeData(); break; case R.id.btn_r: readData(); break; case R.id.btn_n: notifyData(); break; case R.id.btn_c: closeNotifyData(); break; } } /*关闭广播通知*/ private void closeNotifyData() { BluetoothGattCharacteristic characteristic = bluetoothGatt.getService(N_Notify).getCharacteristic(uNotify); BluetoothGattDescriptor descriptor = characteristic.getDescriptor(UUID.fromString("00002902-0000-1000-8000-00805f9b34fb")); descriptor.setValue(BluetoothGattDescriptor.DISABLE_NOTIFICATION_VALUE); bluetoothGatt.writeDescriptor(descriptor); } /*打开广播通知*/ private void notifyData() { BluetoothGattCharacteristic characteristic = bluetoothGatt.getService(N_Notify).getCharacteristic(uNotify); boolean b = bluetoothGatt.setCharacteristicNotification(characteristic, true); int originalWriteType = characteristic.getWriteType(); BluetoothGattDescriptor descriptor = characteristic.getDescriptor(CLIENT_CHARACTERISTIC_CONFIG); descriptor.setValue(BluetoothGattDescriptor.ENABLE_NOTIFICATION_VALUE); boolean b1 = bluetoothGatt.writeDescriptor(descriptor); characteristic.setWriteType(originalWriteType); } /*read 读取数据 返回的数据需要在监听事件接收*/ private void readData() { if (bluetoothGatt == null) { return; } BluetoothGattCharacteristic characteristic = bluetoothGatt.getService(UUID.fromString("00001000-0000-1000-8000-00805f9b34fb")). getCharacteristic(UUID.fromString("00001001-0000-1000-8000-00805f9b34fb")); bluetoothGatt.readCharacteristic(characteristic); } /*扫描设备*/ private void scan() { if (!bAdapter.isEnabled()) { Toast.makeText(this, "请打开蓝牙", Toast.LENGTH_SHORT).show(); return; } bAdapter.startLeScan(scanCallback); btn_scan.setText("扫描中"); btn_scan.setEnabled(false); } /*扫描到新的设备*/ private BluetoothAdapter.LeScanCallback scanCallback = new BluetoothAdapter.LeScanCallback() { @Override public void onLeScan(BluetoothDevice device, int rssi, byte[] scanRecord) { MyBluetoothDevice bluetoothDevice = new MyBluetoothDevice(device, rssi); addDevice(bluetoothDevice); // Log.e(TAG, "onLeScan: " + device.getAddress() + device.getName()); if (device.getAddress().equals("F6:6D:83:80:D6:8D")) { conn(bluetoothDevice); } //F6:6D:83:80:D6:8D } }; /*添加扫描的新设备*/ private void addDevice(MyBluetoothDevice bluetoothDevice) { List<MyBluetoothDevice> devices = myAdapter.getDevices(); for (MyBluetoothDevice device : devices) { if (device.getDevice().getAddress().equals(bluetoothDevice.getDevice().getAddress())) { return; } } myAdapter.upDate(bluetoothDevice); } /*item点击链接的方法*/ @Override public void conn(MyBluetoothDevice device) { bluetoothGatt = device.getDevice().connectGatt(this, false, mBluetoothGattCallback); } /*写数据 数据不会直接返回 需要在监听事件中回调*/ public void writeData() { if (bluetoothGatt == null) { return; } // bluetoothGatt.readRemoteRssi(); BluetoothGattCharacteristic characteristic = bluetoothGatt.getService(N_Write).getCharacteristic(uWrite); //characteristic.setValue("E5015101003420"); characteristic.setValue("EF52FFFAFFFF"); //characteristic.setWriteType(BluetoothGattCharacteristic.WRITE_TYPE_NO_RESPONSE); bluetoothGatt.writeCharacteristic(characteristic); } /*链接状态—ready—write-*/ BluetoothGattCallback mBluetoothGattCallback = new BluetoothGattCallback() { //链接状态更改时 @Override public void onConnectionStateChange(BluetoothGatt gatt, int status, int newState) { super.onConnectionStateChange(gatt, status, newState); if (newState == BluetoothProfile.STATE_CONNECTED) { gatt.discoverServices(); //查询支持的服务 bluetoothGatt = gatt; BleActivityTest.this.runOnUiThread(new Runnable() { @Override public void run() { btn_scan.setVisibility(View.GONE); btn_w.setVisibility(View.VISIBLE); btn_r.setVisibility(View.VISIBLE); btn_n.setVisibility(View.VISIBLE); btn_c.setVisibility(View.VISIBLE); } }); } else if (newState == BluetoothProfile.STATE_DISCONNECTED) { Log.e(TAG, "onConnectionStateChange: 断开"); BleActivityTest.this.runOnUiThread(new Runnable() { @Override public void run() { btn_scan.setEnabled(true); } }); } btn_scan.setText("扫描"); } //读取数据 @Override public void onCharacteristicRead(BluetoothGatt gatt, BluetoothGattCharacteristic characteristic, int status) { super.onCharacteristicRead(gatt, characteristic, status); bluetoothGatt = gatt; if (status == BluetoothGatt.GATT_SUCCESS) { Log.e(TAG, "读取成功"); printALL(characteristic.getValue()); } else { Log.e(TAG, "读取失败"); } } //写出数据返回状态 @Override public void onCharacteristicWrite(BluetoothGatt gatt, BluetoothGattCharacteristic characteristic, int status) { super.onCharacteristicWrite(gatt, characteristic, status); bluetoothGatt = gatt; if (status == BluetoothGatt.GATT_SUCCESS) { Log.e(TAG, "onCharacteristicWrite发送成功"); printALL(characteristic.getValue()); } else { Log.e(TAG, "onCharacteristicWrite发送失败"); } } /*一般情况是 给设备发送指令使用应该*/ @Override public void onDescriptorRead(BluetoothGatt gatt, BluetoothGattDescriptor descriptor, int status) { super.onDescriptorRead(gatt, descriptor, status); bluetoothGatt = gatt; if (status == BluetoothGatt.GATT_SUCCESS) { Log.e(TAG, "onDescriptorRead读取成功"); printALL(descriptor.getValue()); } else { Log.e(TAG, "onDescriptorRead读取失败"); } } /*一般情况是 给设备发送指令使用应该*/ @Override public void onDescriptorWrite(BluetoothGatt gatt, BluetoothGattDescriptor descriptor, int status) { super.onDescriptorWrite(gatt, descriptor, status); bluetoothGatt = gatt; if (status == BluetoothGatt.GATT_SUCCESS) { Log.e(TAG, "onDescriptorWrite发送成功"); printALL(descriptor.getValue()); } else { Log.e(TAG, "onDescriptorWrite发送失败"); } } /*接收通知 广播后 接收到的数据在这里*/ @Override public void onCharacteristicChanged(BluetoothGatt gatt, BluetoothGattCharacteristic characteristic) { //super.onCharacteristicChanged(gatt, characteristic); //bluetoothGatt = gatt; byte[] value = characteristic.getValue(); try { String s=new String(value,"UTF-8"); Log.e(TAG, "onCharacteristicChanged: "+s); } catch (UnsupportedEncodingException e) { e.printStackTrace(); } printNotify(value); } //返回信号强度的 @Override public void onReadRemoteRssi(BluetoothGatt gatt, int rssi, int status) { super.onReadRemoteRssi(gatt, rssi, status); bluetoothGatt = gatt; Log.e(TAG, "onReadRemoteRssi: " + rssi); } //返回支持的服务滴 @Override public void onServicesDiscovered(BluetoothGatt gatt, int status) { super.onServicesDiscovered(gatt, status); bluetoothGatt = gatt; read(gatt); } }; public void read(BluetoothGatt gatt) { List<BluetoothGattService> services = gatt.getServices(); for (BluetoothGattService service : services) { Log.e(TAG, "服务: " + service.getUuid() + "-----"); List<BluetoothGattCharacteristic> characteristics = service.getCharacteristics(); for (BluetoothGattCharacteristic characteristic : characteristics) { if ((characteristic.getProperties() & BluetoothGattCharacteristic.PROPERTY_READ) > 0) { uuidMap.put(READ, characteristic.getUuid()); Log.e(TAG, "读写属性: " + characteristic.getUuid()); for (BluetoothGattDescriptor bluetoothGattDescriptor:characteristic.getDescriptors()){ Log.e(TAG, "蓝牙描述符+++: " + bluetoothGattDescriptor.getUuid()); } } if ((characteristic.getProperties() & BluetoothGattCharacteristic.PROPERTY_WRITE) > 0) { uuidMap.put(WRITE, characteristic.getUuid()); Log.e(TAG, "写属性: " + characteristic.getUuid()); } if ((characteristic.getProperties() & BluetoothGattCharacteristic.PROPERTY_NOTIFY) > 0) { uuidMap.put(NOTICE, characteristic.getUuid()); Log.e(TAG, "通知属性: " + characteristic.getUuid()); for (BluetoothGattDescriptor bluetoothGattDescriptor : characteristic.getDescriptors()) { Log.e(TAG, "蓝牙描述符: " + bluetoothGattDescriptor.getUuid()); } } } } Set<String> strings = uuidMap.keySet(); for (String key : strings) { UUID uuid = uuidMap.get(key); Log.e(TAG, "list: " + uuid.toString()); } } private void printALL(byte[] b) { StringBuffer sb = new StringBuffer(); for (int i = 0; i < b.length; i++) { sb.append(Integer.toHexString(b[i]) + " "); } Log.e(TAG, "printALL--------: " + sb.toString()); } private void printALL2(final byte[] b) { Log.e(TAG, "printALL2--------: " + byteToString(b)); BleActivityTest.this.runOnUiThread(new Runnable() { @Override public void run() { dialProgress.setValue2(Double.parseDouble(formatString(byteToString(b)).getData())); } }); } private void printNotify(final byte[] b) { Log.e(TAG, "printNotify--------: " + byteToString(b)); BleActivityTest.this.runOnUiThread(new Runnable() { @Override public void run() { dialProgress.setValue2(Double.parseDouble(formatString(byteToString(b)).getData())); } }); } /*显示给客户*/ private String byteToString(byte[] b) { StringBuffer sb = new StringBuffer(); for (int i = 0; i < b.length; i++) { String s = String.valueOf(b[i]).replace("-", ""); String s1 = Integer.toHexString(Integer.valueOf(s)); if (i == 0 || i == 1) { char c = asciiToChar(Integer.valueOf(s)); sb.append(c + " "); continue; } else if (s1.length() == 1) { sb.append("0" + s1 + " "); continue; } sb.append(s1 + " "); } return sb.toString(); } /*ascii 转 字符*/ private char asciiToChar(int a) { return (char) a; } /*代码用来计算的数据*/ private BleData formatString(String v) { String value = v.replace(" ", ""); String command = value.substring(0, 2); String date = value.substring(2, 8); String company = value.substring(8, 10); String d = value.substring(10, 18); StringBuffer data = new StringBuffer(); boolean flag = true; for (int i = 0; i < d.length(); i++) { if (i == 0) { continue; } if (i % 2 != 0) { if (flag) { data.append(Integer.valueOf(d.substring(0, i + 1)) + "."); flag = false; } else { data.append(Integer.valueOf(d.substring(i - 1, i + 1))); } } } String crc = value.substring(18, value.length()); return new BleData(command, date, company, data.toString(), crc); } }; ```

关于Android通过蓝牙接收的数据发生丢失的问题

背景:我现在在做手机端与单片机通过蓝牙进行数据传递。 问题:在我通过蓝牙接收单片机通过串口发来的数据的时候,出现了: 1:大量为0的无用数据; 2:缺失部分数据; 接收代码如下。 ``` while(true){ try { num = inputStream.read(buffer_z); n=0; for(i=0;i<num;i++){ buffer_z_new[n] = buffer_z[i]; n++; } String s =bytesToHexString(buffer_z_new); smsg+=s.trim(); if(inputStream.available()==0)break; } catch (IOException e) { e.printStackTrace(); } } StringBuffer stringBuffer = new StringBuffer(); String a = smsg.replace("FB0000",","); String[] b = a.split(","); String c = b[1].replace("1000",","); String[] d = c.split(","); stringBuffer.append(d[1]); String ends = stringBuffer.toString(); Message msg = new Message(); Bundle data = new Bundle(); data.putByteArray("bytes",ends.getBytes()); msg.what = MainActivity.ACCEPT_MESSAGE; msg.setData(data); handler.sendMessage(msg); ``` 我该如何解决呢?

android蓝牙串口接收数据

最近在做android手机蓝牙和单片机通信,一直被接收数据完整性这个问题困扰。 为了使一次通信的包保持完整,我就构思了发送12位的包,包头(1)+数据(8)+校验(2)+包尾(1),校验为求和校验。单片机发送数据的函数如下 void SendString(uchar *dat) //发送12位的包 包头(1)+数据(8)+校验(2)+包尾(1) { uchar i,j; uint check=0; //求和校验 SendChar(0x01); //0x01 SOH --> start of heading i=strlen(dat); for(j=0;j<i;j++) //发送数据 { SendChar(dat[j]); check+=dat[j]; } for(j=8-i;j>0;j--) { SendChar(0x20); //用0x20 space 补齐未满数据位 check+=0x20; } SendChar((uchar)(check>>8)); //校验位高位 SendChar((uchar)(check&0x00ff)); //校验位低位 SendChar(0x04); //0x04 EOT --> end of transmission } 这段是单片机间隔一段时间发送包,已在电脑端串口助手里测试过了,发送正常 while(1) { delay_ms(1000); SendString("test1234"); } 然后接收包的java代码 public void run() { Log.i(TAG, "BEGIN mConnectedThread"); StringBuffer buffer = new StringBuffer(); int SumCheck = 0, SumRec; int i = 0, j, dat; while (true) { try { int count = mmInStream.available(); while (count < 12) { count = mmInStream.available(); } int SOH = mmInStream.read(); Log.i(TAG, "SOH=" + SOH); while (SOH != 1) { i++; if (i >10) { break; } SOH = mmInStream.read(); Log.i(TAG, "SOH=" + SOH); } count = mmInStream.available(); if ((i < 11) && (count <=11)) { while (count < 11) { count = mmInStream.available(); } } else { continue; } for (j = 0; j < 8; j++) { dat = mmInStream.read(); buffer.append(dat); SumCheck += dat; } SumRec = mmInStream.read(); SumRec = (SumRec << 8) | (mmInStream.read()); Log.i(TAG, "SumCheck=" + SumCheck + "\nSumRec" + SumRec); if ((SumCheck == SumRec) && (mmInStream.read() == 4)) { String s = buffer.toString(); byte[] bits = s.getBytes("UTF-8"); mHandler.obtainMessage(BluetoothChat.MESSAGE_READ, 8, -1, bits).sendToTarget(); // 送入消息池 Log.i(TAG, "buffer=" + s); } buffer.delete(0, 7); SumCheck = 0; i = 0; } catch (IOException e) { Log.e(TAG, "disconnected", e); connectionLost(); break; } } } (其他部分的代码参考了android example API-9 bluetoothchat) 但是这段按照包头(1)+数据(8)+校验(2)+包尾(1)来接受校验数据,运行不正常 logcat输出如下 05-16 23:31:21.360: D/BluetoothChatService(17686): create ConnectedThread 05-16 23:31:21.360: I/BluetoothChatService(17686): END mAcceptThread 05-16 23:31:21.400: D/BluetoothChatService(17686): setState() 2 -> 3 05-16 23:31:21.400: I/BluetoothChatService(17686): BEGIN mConnectedThread 05-16 23:31:21.410: I/BluetoothChat(17686): MESSAGE_STATE_CHANGE: 3 05-16 23:31:21.480: I/BluetoothChatService(17686): SOH=1 05-16 23:31:21.490: I/BluetoothChatService(17686): SOH=116 05-16 23:31:21.490: I/BluetoothChatService(17686): SOH=101 05-16 23:31:21.490: I/BluetoothChatService(17686): SOH=115 05-16 23:31:21.490: I/BluetoothChatService(17686): SOH=116 05-16 23:31:21.490: I/BluetoothChatService(17686): SOH=49 05-16 23:31:21.500: I/BluetoothChatService(17686): SOH=50 05-16 23:31:21.500: I/BluetoothChatService(17686): SOH=51 05-16 23:31:21.500: I/BluetoothChatService(17686): SOH=52 05-16 23:31:21.530: I/BluetoothChatService(17686): SOH=2 05-16 23:31:21.530: I/BluetoothChatService(17686): SOH=138 05-16 23:31:21.530: I/BluetoothChatService(17686): SOH=4 05-16 23:31:21.530: I/BluetoothChatService(17686): SOH=1 05-16 23:31:21.530: I/BluetoothChatService(17686): SOH=116 05-16 23:31:21.530: I/BluetoothChatService(17686): SOH=101 05-16 23:31:21.540: I/BluetoothChatService(17686): SOH=115 05-16 23:31:21.540: I/BluetoothChatService(17686): SOH=116 05-16 23:31:21.540: I/BluetoothChatService(17686): SOH=49 05-16 23:31:21.540: I/BluetoothChatService(17686): SOH=50 05-16 23:31:21.540: I/BluetoothChatService(17686): SOH=51 05-16 23:31:21.540: I/BluetoothChatService(17686): SOH=52 05-16 23:31:21.540: I/BluetoothChatService(17686): SOH=2 05-16 23:31:21.540: I/BluetoothChatService(17686): SOH=138 05-16 23:31:21.540: I/BluetoothChatService(17686): SOH=4 05-16 23:31:21.540: I/BluetoothChatService(17686): SOH=1 05-16 23:31:21.540: I/BluetoothChatService(17686): SOH=116 05-16 23:31:21.540: I/BluetoothChatService(17686): SOH=101 05-16 23:31:21.540: I/BluetoothChatService(17686): SOH=115 05-16 23:31:21.540: I/BluetoothChatService(17686): SOH=116 05-16 23:31:21.540: I/BluetoothChatService(17686): SOH=49 05-16 23:31:21.540: I/BluetoothChatService(17686): SOH=50 05-16 23:31:21.540: I/BluetoothChatService(17686): SOH=51 05-16 23:31:21.540: I/BluetoothChatService(17686): SOH=52 05-16 23:31:21.540: I/BluetoothChatService(17686): SOH=2 05-16 23:31:21.540: I/BluetoothChatService(17686): SOH=138 05-16 23:31:21.540: I/BluetoothChatService(17686): SOH=4 05-16 23:31:21.540: I/BluetoothChatService(17686): SOH=1 05-16 23:31:21.540: I/BluetoothChatService(17686): SOH=116 05-16 23:31:21.540: I/BluetoothChatService(17686): SOH=101 05-16 23:31:21.540: I/BluetoothChatService(17686): SOH=115 05-16 23:31:21.540: I/BluetoothChatService(17686): SOH=116 05-16 23:31:21.540: I/BluetoothChatService(17686): SOH=49 05-16 23:31:21.540: I/BluetoothChatService(17686): SOH=50 05-16 23:31:21.540: I/BluetoothChatService(17686): SOH=51 05-16 23:31:21.540: I/BluetoothChatService(17686): SOH=52 05-16 23:31:21.540: I/BluetoothChatService(17686): SOH=2 05-16 23:31:21.540: I/BluetoothChatService(17686): SOH=138 05-16 23:31:21.540: I/BluetoothChatService(17686): SOH=4 05-16 23:31:21.540: I/BluetoothChatService(17686): SOH=1 05-16 23:31:21.540: I/BluetoothChatService(17686): SOH=116 05-16 23:31:21.540: I/BluetoothChatService(17686): SOH=101 05-16 23:31:21.540: I/BluetoothChatService(17686): SOH=115 05-16 23:31:21.540: I/BluetoothChatService(17686): SOH=116 05-16 23:31:21.540: I/BluetoothChatService(17686): SOH=49 05-16 23:31:21.540: I/BluetoothChatService(17686): SOH=50 05-16 23:31:21.550: I/BluetoothChatService(17686): SOH=51 05-16 23:31:21.550: I/BluetoothChatService(17686): SOH=52 05-16 23:31:21.550: I/BluetoothChatService(17686): SOH=2 05-16 23:31:21.550: I/BluetoothChatService(17686): SOH=138 05-16 23:31:21.550: I/BluetoothChatService(17686): SOH=4 05-16 23:31:21.550: I/BluetoothChatService(17686): SOH=1 05-16 23:31:21.550: I/BluetoothChatService(17686): SOH=116 05-16 23:31:21.550: I/BluetoothChatService(17686): SOH=101 05-16 23:31:21.550: I/BluetoothChatService(17686): SOH=115 05-16 23:31:21.550: I/BluetoothChatService(17686): SOH=116 05-16 23:31:21.550: I/BluetoothChatService(17686): SOH=49 05-16 23:31:21.550: I/BluetoothChatService(17686): SOH=50 05-16 23:31:21.550: I/BluetoothChatService(17686): SOH=51 05-16 23:31:21.550: I/BluetoothChatService(17686): SOH=52 05-16 23:31:21.550: I/BluetoothChatService(17686): SOH=2 05-16 23:31:21.550: I/BluetoothChatService(17686): SOH=138 05-16 23:31:21.550: I/BluetoothChatService(17686): SOH=4 05-16 23:31:21.550: I/BluetoothChatService(17686): SOH=1 05-16 23:31:21.550: I/BluetoothChatService(17686): SOH=116 05-16 23:31:21.550: I/BluetoothChatService(17686): SOH=101 05-16 23:31:21.550: I/BluetoothChatService(17686): SOH=115 05-16 23:31:21.550: I/BluetoothChatService(17686): SOH=116 05-16 23:31:21.550: I/BluetoothChatService(17686): SOH=49 05-16 23:31:21.550: I/BluetoothChatService(17686): SOH=50 05-16 23:31:21.550: I/BluetoothChatService(17686): SOH=51 05-16 23:31:21.550: I/BluetoothChatService(17686): SOH=52 05-16 23:31:21.550: I/BluetoothChatService(17686): SOH=2 05-16 23:31:21.550: I/BluetoothChatService(17686): SOH=138 05-16 23:31:21.560: I/BluetoothChatService(17686): SOH=4 05-16 23:31:21.560: I/BluetoothChatService(17686): SOH=1 05-16 23:31:21.560: I/BluetoothChatService(17686): SOH=116 05-16 23:31:21.560: I/BluetoothChatService(17686): SOH=101 05-16 23:31:21.560: I/BluetoothChatService(17686): SOH=115 05-16 23:31:21.560: I/BluetoothChatService(17686): SOH=116 05-16 23:31:21.560: I/BluetoothChatService(17686): SOH=49 05-16 23:31:21.560: I/BluetoothChatService(17686): SOH=50 05-16 23:31:21.560: I/BluetoothChatService(17686): SOH=51 05-16 23:31:21.560: I/BluetoothChatService(17686): SOH=52 05-16 23:31:21.560: I/BluetoothChatService(17686): SOH=2 05-16 23:31:21.560: I/BluetoothChatService(17686): SOH=138 05-16 23:31:21.560: I/BluetoothChatService(17686): SOH=4 05-16 23:31:21.560: I/BluetoothChatService(17686): SOH=1 05-16 23:31:21.560: I/BluetoothChatService(17686): SOH=116 05-16 23:31:21.560: I/BluetoothChatService(17686): SOH=101 05-16 23:31:21.570: I/BluetoothChatService(17686): SOH=115 05-16 23:31:21.570: I/BluetoothChatService(17686): SOH=116 05-16 23:31:21.570: I/BluetoothChatService(17686): SOH=49 05-16 23:31:21.570: I/BluetoothChatService(17686): SOH=50 05-16 23:31:21.570: I/BluetoothChatService(17686): SOH=51 05-16 23:31:21.570: I/BluetoothChatService(17686): SOH=52 05-16 23:31:21.570: I/BluetoothChatService(17686): SOH=2 05-16 23:31:21.570: I/BluetoothChatService(17686): SOH=138 05-16 23:31:21.570: I/BluetoothChatService(17686): SOH=4 05-16 23:31:21.570: I/BluetoothChatService(17686): SOH=1 05-16 23:31:21.570: I/BluetoothChatService(17686): SOH=116 05-16 23:31:21.580: I/BluetoothChatService(17686): SOH=101 05-16 23:31:21.580: I/BluetoothChatService(17686): SOH=115 05-16 23:31:21.580: I/BluetoothChatService(17686): SOH=116 05-16 23:31:21.580: I/BluetoothChatService(17686): SOH=49 05-16 23:31:21.580: I/BluetoothChatService(17686): SOH=50 05-16 23:31:21.580: I/BluetoothChatService(17686): SOH=51 logcat到此停了。。。内容可能有些多,但跪求各位帮忙看看,问题出在哪儿

NRF52840 自定义UUID read属性问题

我现在调试nrf52840用的官方ble_app_blink这个例程,例程中定义的LBS_UUID_LED_CHAR 属性为read和write,app可以给nrf52840发送数据。但是没有找到app读取nrf52840数据的流程,请问当app发起读取请求的时候,nrf52840中处理流程是什么样的。 ![图片说明](https://img-ask.csdn.net/upload/201908/15/1565841916_510182.png)

iOS 8 BLE readRSSI delegate call back not firing

如题。 http://www.openradar.me/18476971 问题大概是这样的: Summary: There seems to be an issue in the CoreBluetooth framework that us causing all readRSSI() requests to never trigger the new iOS 8 delegate peripheral(peripheral: CBPeripheral!, didReadRSSI RSSI: NSNumber!, error: NSError!) This issue only occurs once the application has successfully connected to this device once. Upon disconnection and reconnection the application never receives this callback again. 问题的重现过程: 1. connect to BLE device. 2. attempt to read the RSSI value with the method readRSSI() 3. disconnect from BLE device. 4. reconnect to BLE device. 5. attempt to read the RSSI value with the method readRSSI() 在步骤5之后,再无法正常读取rssi值。 还请大神帮忙!

大学课程设计,编写蓝牙透传app时候,再发送一个信息蓝牙就断开连接

如题,我最近在做课程设计,题目是基于STM32的一个猫屋设计,主要是一个PWM风扇控制,和一个远程投喂功能。 再加个基于BT05的蓝牙透传APP。APP做到一半,PWM风扇做好了,但是想加个定时远程投喂加不上,思路是定时中断STM32,从而达到投喂功能。 1. 遇到的问题:APP能设置温度的上下限,读取实时温度,上下限温度。但是再想读取一个投喂间隔或者设置投喂间隔就会自动断开蓝牙连接![图片说明](https://img-ask.csdn.net/upload/201905/07/1557219048_675317.jpg) 这是我的APP界面。就是如果读取投喂间隔或者按最后一个按钮——设置投喂间隔,就会断开蓝牙,返回扫描蓝牙界面。 请各位前辈指教。我不知道怎么修改。 下面是我的DeviceCnotrolActivity.java的代码。谢谢。 ``` /* * Copyright (C) 2013 The Android Open Source Project * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package com.example.bluetooth.le; import java.util.ArrayList; import java.util.List; import java.util.Timer; import java.util.TimerTask; import android.app.Activity; import android.bluetooth.BluetoothGattCharacteristic; import android.bluetooth.BluetoothGattService; import android.content.BroadcastReceiver; import android.content.ComponentName; import android.content.Context; import android.content.Intent; import android.content.IntentFilter; import android.content.ServiceConnection; import android.os.Bundle; import android.os.Handler; import android.os.IBinder; import android.os.Message; import android.util.Log; import android.view.Gravity; import android.view.Menu; import android.view.MenuItem; import android.view.View; import android.widget.Button; import android.widget.EditText; import android.widget.ExpandableListView; import android.widget.TextView; import android.widget.Toast; /** * For a given BLE device, this Activity provides the user interface to connect, display data, * and display GATT services and characteristics supported by the device. The Activity * communicates with {@code BluetoothLeService}, which in turn interacts with the * Bluetooth LE API. */ public class DeviceControlActivity extends Activity { private final static String TAG = DeviceControlActivity.class.getSimpleName(); public static final String EXTRAS_DEVICE_NAME = "DEVICE_NAME"; public static final String EXTRAS_DEVICE_ADDRESS = "DEVICE_ADDRESS"; private TextView mConnectionState; private TextView mDataField; private TextView mDataTemptured;//显示温度 private TextView mSetTemptured;//设置温度 private TextView mSetLTemptured;//设置温度 下限 private TextView mFenSuRang;//风扇档位 private String mDeviceName; private String mDeviceAddress; private ExpandableListView mGattServicesList; private BluetoothLeService mBluetoothLeService; private ArrayList<ArrayList<BluetoothGattCharacteristic>> mGattCharacteristics = new ArrayList<ArrayList<BluetoothGattCharacteristic>>(); private boolean mConnected = false; private BluetoothGattCharacteristic mNotifyCharacteristic; boolean connect_status_bit=false; private final String LIST_NAME = "NAME"; private final String LIST_UUID = "UUID"; private final String g_TitleName = "智能温度控制设计"; private final String g_EndByte= "0E"; private final String g_SetHADDR = "0A0B02"; private final String g_SetLADDR = "0A0B03"; private Handler mHandler; // Stops scanning after 10 seconds. private static final long SCAN_PERIOD = 1000; private int i = 0; private int TIME = 1000; // Code to manage Service lifecycle. private final ServiceConnection mServiceConnection = new ServiceConnection() { @Override public void onServiceConnected(ComponentName componentName, IBinder service) { mBluetoothLeService = ((BluetoothLeService.LocalBinder) service).getService(); if (!mBluetoothLeService.initialize()) { Log.e(TAG, "Unable to initialize Bluetooth"); finish(); } // Automatically connects to the device upon successful start-up initialization. mBluetoothLeService.connect(mDeviceAddress); } @Override public void onServiceDisconnected(ComponentName componentName) { mBluetoothLeService = null; } }; // Handles various events fired by the Service. // ACTION_GATT_CONNECTED: connected to a GATT server. // ACTION_GATT_DISCONNECTED: disconnected from a GATT server. // ACTION_GATT_SERVICES_DISCOVERED: discovered GATT services. // ACTION_DATA_AVAILABLE: received data from the device. This can be a result of read // or notification operations. private final BroadcastReceiver mGattUpdateReceiver = new BroadcastReceiver() { @Override public void onReceive(Context context, Intent intent) { final String action = intent.getAction(); if (BluetoothLeService.ACTION_GATT_CONNECTED.equals(action)) { //mConnected = true; connect_status_bit=true; invalidateOptionsMenu(); } else if (BluetoothLeService.ACTION_GATT_DISCONNECTED.equals(action)) { mConnected = false; updateConnectionState(R.string.disconnected); connect_status_bit=false; show_view(false); invalidateOptionsMenu(); clearUI(); } else if (BluetoothLeService.ACTION_GATT_SERVICES_DISCOVERED.equals(action)) { // Show all the supported services and characteristics on the user interface. displayGattServices(mBluetoothLeService.getSupportedGattServices()); } else if (BluetoothLeService.ACTION_DATA_AVAILABLE.equals(action)) { displayData(intent.getStringExtra(BluetoothLeService.EXTRA_DATA)); } } }; // If a given GATT characteristic is selected, check for supported features. This sample // demonstrates 'Read' and 'Notify' features. See // http://d.android.com/reference/android/bluetooth/BluetoothGatt.html for the complete // list of supported characteristic features. private final ExpandableListView.OnChildClickListener servicesListClickListner = new ExpandableListView.OnChildClickListener() { @Override public boolean onChildClick(ExpandableListView parent, View v, int groupPosition, int childPosition, long id) { return false; } }; private void clearUI() { //mGattServicesList.setAdapter((SimpleExpandableListAdapter) null); mDataField.setText(R.string.no_data); } Button send_button; //发送上限温度按键 Button send_Lowbutton; //发送下限温度按键 Button send_feedbutton; //发送投喂按键 Button enable_button; Button IBeacon_set_button; EditText txd_txt,uuid_1001_ed; EditText txd_txtLowTempture; //下限显示文本 EditText txd_txtfeedtime; //投喂间隔显示文本 EditText ibeacon_uuid; EditText mayjor_txt,minor_txt; EditText dev_Name; Button name_button; EditText password_ed;//密码值 Button password_enable_bt;//密码开关 Button password_wrt;//密码写入Button Button adv_time1,adv_time2,adv_time3,adv_time4; boolean pass_en=false; Button clear_button; private Button IO_H_button,IO_L_button;//out io Timer timer = new Timer(); void show_view( boolean p ) { if(p){ send_button.setEnabled(true); send_Lowbutton.setEnabled(true); send_feedbutton.setEnabled(true); }else{ send_button.setEnabled(false); send_Lowbutton.setEnabled(false); send_feedbutton.setEnabled(false); } } public void delay(int ms){ try { Thread.currentThread(); Thread.sleep(ms); } catch (InterruptedException e) { e.printStackTrace(); } } @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.gatt_services_characteristics); final Intent intent = getIntent(); mDeviceName = intent.getStringExtra(EXTRAS_DEVICE_NAME); mDeviceAddress = intent.getStringExtra(EXTRAS_DEVICE_ADDRESS); // Sets up UI references. ((TextView) findViewById(R.id.device_address)).setText(mDeviceAddress); //mGattServicesList = (ExpandableListView) findViewById(R.id.gatt_services_list); // mGattServicesList.setOnChildClickListener(servicesListClickListner); mConnectionState = (TextView) findViewById(R.id.connection_state); // mDataField = (TextView) findViewById(R.id.data_value); mDataTemptured = (TextView) findViewById(R.id.rx_Tempture); mSetTemptured= (TextView) findViewById(R.id.ARM_Tempture); mSetLTemptured= (TextView) findViewById(R.id.L_Tempture); mFenSuRang= (TextView) findViewById(R.id.rx_FenRang); send_button=(Button)findViewById(R.id.tx_SetHbutton);//send data 1002 send_button.setOnClickListener(listener);//设置监听 send_Lowbutton = (Button)findViewById(R.id.tx_SetLbutton);//send data 1002 send_Lowbutton.setOnClickListener(listener);//设置监听 send_feedbutton=(Button)findViewById(R.id.tx_SetFbutton);//send data 1002 send_feedbutton.setOnClickListener(listener);//设置监听 // clear_button=(Button)findViewById(R.id.clear_button);//send data 1002 // clear_button.setOnClickListener(listener);//设置监听 txd_txt=(EditText)findViewById(R.id.tx_text);//1002 data txd_txt.setText("28"); txd_txtLowTempture=(EditText)findViewById(R.id.tx_dispLTemptuer);//1002 data txd_txtLowTempture.setText("15"); // rx_data_id_1=(EditText)findViewById(R.id.rx_data_id_1);//1002 data // rx_data_id_1.setText(""); show_view(false); mHandler = new Handler(); timer.schedule(task, 1000, 1000); // 1s后执行task,经过1s再次执行 boolean sg; getActionBar().setTitle(g_TitleName); // getActionBar().setDisplayHomeAsUpEnabled(true); Intent gattServiceIntent = new Intent(this, BluetoothLeService.class); sg = bindService(gattServiceIntent, mServiceConnection, BIND_AUTO_CREATE); //getActionBar().setTitle( "="+BluetoothLeService ); //mDataField.setText("="+sg ); updateConnectionState(R.string.connecting);//更新连接状态 } Handler handler = new Handler() { public void handleMessage(Message msg) { if (msg.what == 1) { //tvShow.setText(Integer.toString(i++)); //scanLeDevice(true); if (mBluetoothLeService != null) { if( mConnected==false ) { updateConnectionState(R.string.connecting); final boolean result = mBluetoothLeService.connect(mDeviceAddress); Log.d(TAG, "Connect request result=" + result); } } } super.handleMessage(msg); }; }; TimerTask task = new TimerTask() { @Override public void run() { // 需要做的事:发送消息 Message message = new Message(); message.what = 1; handler.sendMessage(message); } }; Button.OnClickListener listener = new Button.OnClickListener(){//创建监听对象 public void onClick(View v){ //String strTmp="点击Button02"; //Ev1.setText(strTmp); switch( v.getId()) { case R.id.tx_SetHbutton ://uuid1002 数传通道发送数据 设置上限按钮 if( connect_status_bit ) { String tx_string=txd_txt.getText().toString().trim(); //去掉有空格 mBluetoothLeService.txxx(g_SetHADDR+tx_string+g_EndByte); }else{ //Toast.makeText(this, "Deleted Successfully!", Toast.LENGTH_LONG).show(); Toast toast = Toast.makeText(DeviceControlActivity.this, "设备没有连接!", Toast.LENGTH_SHORT); toast.show(); } break; case R.id.tx_SetLbutton ://uuid1002 数传通道发送数据 设置下限按钮 if( connect_status_bit ) { String tx_string=txd_txtLowTempture.getText().toString().trim(); //去掉有空格 mBluetoothLeService.txxx(g_SetLADDR+tx_string+g_EndByte); }else{ //Toast.makeText(this, "Deleted Successfully!", Toast.LENGTH_LONG).show(); Toast toast = Toast.makeText(DeviceControlActivity.this, "设备没有连接!", Toast.LENGTH_SHORT); toast.show(); } break; case R.id.tx_SetFbutton ://uuid1002 数传通道发送数据 设置上限按钮 if( connect_status_bit ) { String tx_string=txd_txtfeedtime.getText().toString().trim(); //去掉有空格 mBluetoothLeService.txxx(g_SetHADDR+tx_string+g_EndByte); }else{ //Toast.makeText(this, "Deleted Successfully!", Toast.LENGTH_LONG).show(); Toast toast = Toast.makeText(DeviceControlActivity.this, "设备没有连接!", Toast.LENGTH_SHORT); toast.show(); } break; // case R.id.clear_button: // { //// len_g =0; //// da = ""; //// rx_data_id_1.setText( da ); //// mDataField.setText( ""+len_g ); // }break; default : break; } } }; @Override protected void onResume() { super.onResume(); registerReceiver(mGattUpdateReceiver, makeGattUpdateIntentFilter()); if (mBluetoothLeService != null) { final boolean result = mBluetoothLeService.connect(mDeviceAddress); Log.d(TAG, "Connect request result=" + result); } } @Override protected void onPause() { super.onPause(); unregisterReceiver(mGattUpdateReceiver); } @Override protected void onDestroy() { super.onDestroy(); unbindService(mServiceConnection); mBluetoothLeService = null; timer.cancel(); timer=null; } @Override public boolean onCreateOptionsMenu(Menu menu) { getMenuInflater().inflate(R.menu.gatt_services, menu); if (mConnected) { menu.findItem(R.id.menu_connect).setVisible(false); menu.findItem(R.id.menu_disconnect).setVisible(true); } else { menu.findItem(R.id.menu_connect).setVisible(true); menu.findItem(R.id.menu_disconnect).setVisible(false); } return true; } @Override public boolean onOptionsItemSelected(MenuItem item) { switch(item.getItemId()) { case R.id.menu_connect: mBluetoothLeService.connect(mDeviceAddress); return true; case R.id.menu_disconnect: mBluetoothLeService.disconnect(); return true; case android.R.id.home: onBackPressed(); return true; } return super.onOptionsItemSelected(item); } private void updateConnectionState(final int resourceId) { runOnUiThread(new Runnable() { @Override public void run() { mConnectionState.setText(resourceId); } }); } String da=""; int len_g = 0; private void displayData( String data1 ) { //String head1,data_0; /* head1=data1.substring(0,2); data_0=data1.substring(2); */ //da = da+data1+"\n"; if( data1!=null&&data1.length()>0) { //mDataField.setText( data1 ); //len_g += data1.length()/2; //da = data1+da; //rx_data_id_1.setText( data1 ); // mDataField.setText( ""+len_g ); mDataTemptured.setText(data1.substring(4, 6)+"℃"); mSetTemptured.setText(data1.substring(6, 8)+"℃"); mSetLTemptured.setText(data1.substring(8, 10)+"℃"); mFenSuRang.setText(data1.substring(10, 12)+"档"); //rx_data_id_1.setGravity(Gravity.BOTTOM); //rx_data_id_1.setSelection(rx_data_id_1.getText().length()); } } // Demonstrates how to iterate through the supported GATT Services/Characteristics. // In this sample, we populate the data structure that is bound to the ExpandableListView // on the UI. private void displayGattServices(List<BluetoothGattService> gattServices) { if (gattServices == null) return; if( gattServices.size()>0&&mBluetoothLeService.get_connected_status( gattServices )>=4 ) { if( connect_status_bit ) { mConnected = true; show_view( true ); mBluetoothLeService.enable_JDY_ble(true); try { Thread.currentThread(); Thread.sleep(100); } catch (InterruptedException e) { e.printStackTrace(); } mBluetoothLeService.enable_JDY_ble(true); updateConnectionState(R.string.connected); }else{ //Toast.makeText(this, "Deleted Successfully!", Toast.LENGTH_LONG).show(); Toast toast = Toast.makeText(DeviceControlActivity.this, "设备没有连接!", Toast.LENGTH_SHORT); toast.show(); } } // SimpleExpandableListAdapter gattServiceAdapter = new SimpleExpandableListAdapter( // this, // gattServiceData, // android.R.layout.simple_expandable_list_item_2, // new String[] {LIST_NAME, LIST_UUID}, // new int[] { android.R.id.text1, android.R.id.text2 }, // gattCharacteristicData, // android.R.layout.simple_expandable_list_item_2, // new String[] {LIST_NAME, LIST_UUID}, // new int[] { android.R.id.text1, android.R.id.text2 } // ); // // mGattServicesList.setAdapter(gattServiceAdapter); } private static IntentFilter makeGattUpdateIntentFilter() { final IntentFilter intentFilter = new IntentFilter(); intentFilter.addAction(BluetoothLeService.ACTION_GATT_CONNECTED); intentFilter.addAction(BluetoothLeService.ACTION_GATT_DISCONNECTED); intentFilter.addAction(BluetoothLeService.ACTION_GATT_SERVICES_DISCOVERED); intentFilter.addAction(BluetoothLeService.ACTION_DATA_AVAILABLE); return intentFilter; } } ```

通过Handler实现Service和Activity的数据交互,与onbind返回Binder对象冲突,我该如何解决?

在做service和activity通讯,需要服务能够控制活动的运行,同时能够实时进行数据传输 我通过Handler实现Service和Activity的数据交互,但尴尬的是onBind已经用于传递BleBind的一个实例了,没办法return messenger.getBinder(); ``` package com.example.bluserver; import android.app.Service; import android.bluetooth.BluetoothAdapter; import android.bluetooth.BluetoothDevice; import android.bluetooth.BluetoothSocket; import android.content.Context; import android.content.Intent; import android.os.Binder; import android.os.Handler; import android.os.IBinder; import android.os.Message; import android.os.Messenger; import android.util.Log; import android.widget.TextView; import android.widget.Toast; import java.io.IOException; import java.io.InputStream; import java.io.OutputStream; import java.util.UUID; public class bluService extends Service { public static final int MSG = 123; private static final String TAG = "BleService"; private BluetoothAdapter mBA; private Context mContext; private final UUID MY_UUID = UUID.fromString("00001101-0000-1000-8000-00805F9B34FB");//这是蓝牙透传的uuid // 这里本身即是服务端也是客户端,需要如下类 private BluetoothSocket mSocket; private BluetoothDevice mOldDevice; private BluetoothDevice mCurDevice; // 输出流_客户端需要往服务端输出 private OutputStream os; private Messenger mActivityMessenger; private BleBinder bleBinder=new BleBinder(); @Override public IBinder onBind(Intent intent) { Messenger messenger=new Messenger(handler); //return messenger.getBinder();//Handler实现Service和Activity的数据交互 return bleBinder;//返回BleBinder实例供活动调用 } class BleBinder extends Binder{//以下是以供调用的公共方法 //开始读取传感器数据 public void startread(){ { new Thread(new Runnable() { @Override public void run() { try { Log.d(TAG,"开始运行run()函数"); InputStream is = mSocket.getInputStream(); Log.d(TAG,"已获取输入流"); while (true) { synchronized (this) { //Log.d(TAG,"已获取锁"); //Thread.sleep(50); byte[] tt = new byte[is.available()]; if (tt.length > 0) { is.read(tt, 0, tt.length); Message msg = new Message(); msg.obj = new String(tt, "GBK"); //大概在这里要获取整个字符串,字符串以回车分割,如此才能准确识别 Log.e(TAG, "客户端:" + msg.obj); showToast("客户端:" + msg.obj); mActivityMessenger.send(msg); //handler.sendMessage(msg); } } } } catch (Exception e) { e.printStackTrace(); } } }).start(); } } public void stopread(){}//停止读取传感器数据 /** * 弹出Toast窗口 * * @param message */ private void showToast(String message) { if (mContext != null) { Toast.makeText(mContext, message, Toast.LENGTH_LONG).show(); } else { Log.e(TAG, "message:" + message); } } /** * 主动连接蓝牙 * * @param device */ public void connectDevice(BluetoothDevice device) { // 判断是否在搜索,如果在搜索,就取消搜索 if (mBA.isDiscovering()) { mBA.cancelDiscovery(); } try { // 获得远程设备 Log.e(TAG, "开始检索"); if (mCurDevice == null || mCurDevice != mOldDevice) { mCurDevice = mBA.getRemoteDevice(device.getAddress()); Log.e(TAG, device.getAddress()); mOldDevice = mCurDevice; Log.e(TAG, "device:" + mCurDevice); mSocket = mCurDevice.createRfcommSocketToServiceRecord(MY_UUID); // 连接 mSocket.connect(); // 获得输出流 os = mSocket.getOutputStream(); Log.e(TAG, "获取输入流"); startread(); Log.e(TAG, "开启读线程"); //intent流转byte数组 // byte[] input=ByteToInputStream.input2byte(mSocket.getInputStream()); // Intent intent=new Intent(); // intent.putExtra("inputstream",input); // mContext.startActivity(intent); } // 如果成功获得输出流 Log.e(TAG, "3"); } catch (IOException e) { e.printStackTrace(); } } /** * 判断是否打开蓝牙 * * @return */ public boolean isEnabled() { if (mBA.isEnabled()) { return true; } return false; } /** * 传输数据 * * @param message */ public void write(String message) { try { if (os != null) { os.write(message.getBytes("GBK")); } Log.e(TAG, "write:" + message); } catch (IOException e) { e.printStackTrace(); } } public BluetoothDevice getCurDevice() { return mCurDevice; } } public bluService() { mBA = BluetoothAdapter.getDefaultAdapter(); } private Handler handler = new Handler() { public void handleMessage(Message msg) { //Toast.makeText(this,String.valueOf(msg.obj),Toast.LENGTH_LONG); //将在此处向主线程发送信息,用于更新界面(已废弃) //将在此处处理来自活动的消息,发送消息在线程内 // 参考代码 https://blog.csdn.net/CodeNoodles/article/details/51679532 switch (msg.what){ case MSG: mActivityMessenger = msg.replyTo; break; } Log.e(TAG, "服务端:" + msg.obj); super.handleMessage(msg); } }; @Override public void onDestroy() { Log.d(TAG,"服务已销毁"); super.onDestroy(); } @Override public int onStartCommand(Intent intent, int flags, int startId) { Log.d(TAG,"服务已启动"); return super.onStartCommand(intent, flags, startId); } @Override public void onCreate() { super.onCreate(); Log.d(TAG,"服务已创建"); } } ```

大学四年自学走来,这些私藏的实用工具/学习网站我贡献出来了

大学四年,看课本是不可能一直看课本的了,对于学习,特别是自学,善于搜索网上的一些资源来辅助,还是非常有必要的,下面我就把这几年私藏的各种资源,网站贡献出来给你们。主要有:电子书搜索、实用工具、在线视频学习网站、非视频学习网站、软件下载、面试/求职必备网站。 注意:文中提到的所有资源,文末我都给你整理好了,你们只管拿去,如果觉得不错,转发、分享就是最大的支持了。 一、电子书搜索 对于大部分程序员...

在中国程序员是青春饭吗?

今年,我也32了 ,为了不给大家误导,咨询了猎头、圈内好友,以及年过35岁的几位老程序员……舍了老脸去揭人家伤疤……希望能给大家以帮助,记得帮我点赞哦。 目录: 你以为的人生 一次又一次的伤害 猎头界的真相 如何应对互联网行业的「中年危机」 一、你以为的人生 刚入行时,拿着傲人的工资,想着好好干,以为我们的人生是这样的: 等真到了那一天,你会发现,你的人生很可能是这样的: ...

程序员请照顾好自己,周末病魔差点一套带走我。

程序员在一个周末的时间,得了重病,差点当场去世,还好及时挽救回来了。

ArrayList源码分析(入门篇)

ArrayList源码分析 前言: 写这篇博客的主要原因是,在我上一次参加千牵科技Java实习生面试时,有被面试官问到ArrayList为什么查找的速度较快,插入和删除的速度较慢?当时我回答得不好,很大的一部分原因是因为我没有阅读过ArrayList源码,虽然最后收到Offer了,但我拒绝了,打算寒假学得再深入些再广泛些,下学期开学后再去投递其他更好的公司。为了更加深入理解ArrayList,也为

我以为我学懂了数据结构,直到看了这个导图才发现,我错了

数据结构与算法思维导图

String s = new String(" a ") 到底产生几个对象?

老生常谈的一个梗,到2020了还在争论,你们一天天的,哎哎哎,我不是针对你一个,我是说在座的各位都是人才! 上图红色的这3个箭头,对于通过new产生一个字符串(”宜春”)时,会先去常量池中查找是否已经有了”宜春”对象,如果没有则在常量池中创建一个此字符串对象,然后堆中再创建一个常量池中此”宜春”对象的拷贝对象。 也就是说准确答案是产生了一个或两个对象,如果常量池中原来没有 ”宜春” ,就是两个。...

技术大佬:我去,你写的 switch 语句也太老土了吧

昨天早上通过远程的方式 review 了两名新来同事的代码,大部分代码都写得很漂亮,严谨的同时注释也很到位,这令我非常满意。但当我看到他们当中有一个人写的 switch 语句时,还是忍不住破口大骂:“我擦,小王,你丫写的 switch 语句也太老土了吧!” 来看看小王写的代码吧,看完不要骂我装逼啊。 private static String createPlayer(PlayerTypes p...

和黑客斗争的 6 天!

互联网公司工作,很难避免不和黑客们打交道,我呆过的两家互联网公司,几乎每月每天每分钟都有黑客在公司网站上扫描。有的是寻找 Sql 注入的缺口,有的是寻找线上服务器可能存在的漏洞,大部分都...

讲一个程序员如何副业月赚三万的真实故事

loonggg读完需要3分钟速读仅需 1 分钟大家好,我是你们的校长。我之前讲过,这年头,只要肯动脑,肯行动,程序员凭借自己的技术,赚钱的方式还是有很多种的。仅仅靠在公司出卖自己的劳动时...

上班一个月,后悔当初着急入职的选择了

最近有个老铁,告诉我说,上班一个月,后悔当初着急入职现在公司了。他之前在美图做手机研发,今年美图那边今年也有一波组织优化调整,他是其中一个,在协商离职后,当时捉急找工作上班,因为有房贷供着,不能没有收入来源。所以匆忙选了一家公司,实际上是一个大型外包公司,主要派遣给其他手机厂商做外包项目。**当时承诺待遇还不错,所以就立马入职去上班了。但是后面入职后,发现薪酬待遇这块并不是HR所说那样,那个HR自...

女程序员,为什么比男程序员少???

昨天看到一档综艺节目,讨论了两个话题:(1)中国学生的数学成绩,平均下来看,会比国外好?为什么?(2)男生的数学成绩,平均下来看,会比女生好?为什么?同时,我又联想到了一个技术圈经常讨...

副业收入是我做程序媛的3倍,工作外的B面人生是怎样的?

提到“程序员”,多数人脑海里首先想到的大约是:为人木讷、薪水超高、工作枯燥…… 然而,当离开工作岗位,撕去层层标签,脱下“程序员”这身外套,有的人生动又有趣,马上展现出了完全不同的A/B面人生! 不论是简单的爱好,还是正经的副业,他们都干得同样出色。偶尔,还能和程序员的特质结合,产生奇妙的“化学反应”。 @Charlotte:平日素颜示人,周末美妆博主 大家都以为程序媛也个个不修边幅,但我们也许...

MySQL数据库面试题(2020最新版)

文章目录数据库基础知识为什么要使用数据库什么是SQL?什么是MySQL?数据库三大范式是什么mysql有关权限的表都有哪几个MySQL的binlog有有几种录入格式?分别有什么区别?数据类型mysql有哪些数据类型引擎MySQL存储引擎MyISAM与InnoDB区别MyISAM索引与InnoDB索引的区别?InnoDB引擎的4大特性存储引擎选择索引什么是索引?索引有哪些优缺点?索引使用场景(重点)...

如果你是老板,你会不会踢了这样的员工?

有个好朋友ZS,是技术总监,昨天问我:“有一个老下属,跟了我很多年,做事勤勤恳恳,主动性也很好。但随着公司的发展,他的进步速度,跟不上团队的步伐了,有点...

我入职阿里后,才知道原来简历这么写

私下里,有不少读者问我:“二哥,如何才能写出一份专业的技术简历呢?我总感觉自己写的简历太烂了,所以投了无数份,都石沉大海了。”说实话,我自己好多年没有写过简历了,但我认识的一个同行,他在阿里,给我说了一些他当年写简历的方法论,我感觉太牛逼了,实在是忍不住,就分享了出来,希望能够帮助到你。 01、简历的本质 作为简历的撰写者,你必须要搞清楚一点,简历的本质是什么,它就是为了来销售你的价值主张的。往深...

玩转springboot启动banner定义所得

最近接手了一个springboot项目,不是不熟悉这个框架,启动时打印的信息吸引了我。 这不是我熟悉的常用springboot的打印信息啊,我打开自己的项目: 还真是的,不用默认的感觉也挺高大上的。一时兴起,就去研究了一下源代码,还正是有些收获,稍后我会总结一下。正常情况下做为一个老程序员,是不会对这种小儿科感兴趣的,不就是一个控制台打印嘛。哈哈! 于是出于最初的好奇,研究了项目的源代码。看到

带了6个月的徒弟当了面试官,而身为高级工程师的我天天修Bug......

即将毕业的应届毕业生一枚,现在只拿到了两家offer,但最近听到一些消息,其中一个offer,我这个组据说客户很少,很有可能整组被裁掉。 想问大家: 如果我刚入职这个组就被裁了怎么办呢? 大家都是什么时候知道自己要被裁了的? 面试软技能指导: BQ/Project/Resume 试听内容: 除了刷题,还有哪些技能是拿到offer不可或缺的要素 如何提升面试软实力:简历, 行为面试,沟通能...

离职半年了,老东家又发 offer,回不回?

有小伙伴问松哥这个问题,他在上海某公司,在离职了几个月后,前公司的领导联系到他,希望他能够返聘回去,他很纠结要不要回去? 俗话说好马不吃回头草,但是这个小伙伴既然感到纠结了,我觉得至少说明了两个问题:1.曾经的公司还不错;2.现在的日子也不是很如意。否则应该就不会纠结了。 老实说,松哥之前也有过类似的经历,今天就来和小伙伴们聊聊回头草到底吃不吃。 首先一个基本观点,就是离职了也没必要和老东家弄的苦...

男生更看重女生的身材脸蛋,还是思想?

往往,我们看不进去大段大段的逻辑。深刻的哲理,往往短而精悍,一阵见血。问:产品经理挺漂亮的,有点心动,但不知道合不合得来。男生更看重女生的身材脸蛋,还是...

为什么程序员做外包会被瞧不起?

二哥,有个事想询问下您的意见,您觉得应届生值得去外包吗?公司虽然挺大的,中xx,但待遇感觉挺低,马上要报到,挺纠结的。

当HR压你价,说你只值7K,你该怎么回答?

当HR压你价,说你只值7K时,你可以流畅地回答,记住,是流畅,不能犹豫。 礼貌地说:“7K是吗?了解了。嗯~其实我对贵司的面试官印象很好。只不过,现在我的手头上已经有一份11K的offer。来面试,主要也是自己对贵司挺有兴趣的,所以过来看看……”(未完) 这段话主要是陪HR互诈的同时,从公司兴趣,公司职员印象上,都给予对方正面的肯定,既能提升HR的好感度,又能让谈判气氛融洽,为后面的发挥留足空间。...

面试:第十六章:Java中级开发(16k)

HashMap底层实现原理,红黑树,B+树,B树的结构原理 Spring的AOP和IOC是什么?它们常见的使用场景有哪些?Spring事务,事务的属性,传播行为,数据库隔离级别 Spring和SpringMVC,MyBatis以及SpringBoot的注解分别有哪些?SpringMVC的工作原理,SpringBoot框架的优点,MyBatis框架的优点 SpringCould组件有哪些,他们...

面试阿里p7,被按在地上摩擦,鬼知道我经历了什么?

面试阿里p7被问到的问题(当时我只知道第一个):@Conditional是做什么的?@Conditional多个条件是什么逻辑关系?条件判断在什么时候执...

终于懂了TCP和UDP协议区别

终于懂了TCP和UDP协议区别

你打算用Java 8一辈子都不打算升级到Java 14,真香

我们程序员应该抱着尝鲜、猎奇的心态,否则就容易固步自封,技术停滞不前。

无代码时代来临,程序员如何保住饭碗?

编程语言层出不穷,从最初的机器语言到如今2500种以上的高级语言,程序员们大呼“学到头秃”。程序员一边面临编程语言不断推陈出新,一边面临由于许多代码已存在,程序员编写新应用程序时存在重复“搬砖”的现象。 无代码/低代码编程应运而生。无代码/低代码是一种创建应用的方法,它可以让开发者使用最少的编码知识来快速开发应用程序。开发者通过图形界面中,可视化建模来组装和配置应用程序。这样一来,开发者直...

面试了一个 31 岁程序员,让我有所触动,30岁以上的程序员该何去何从?

最近面试了一个31岁8年经验的程序猿,让我有点感慨,大龄程序猿该何去何从。

大三实习生,字节跳动面经分享,已拿Offer

说实话,自己的算法,我一个不会,太难了吧

程序员垃圾简历长什么样?

已经连续五年参加大厂校招、社招的技术面试工作,简历看的不下于万份 这篇文章会用实例告诉你,什么是差的程序员简历! 疫情快要结束了,各个公司也都开始春招了,作为即将红遍大江南北的新晋UP主,那当然要为小伙伴们做点事(手动狗头)。 就在公众号里公开征简历,义务帮大家看,并一一点评。《启舰:春招在即,义务帮大家看看简历吧》 一石激起千层浪,三天收到两百多封简历。 花光了两个星期的所有空闲时...

《经典算法案例》01-08:如何使用质数设计扫雷(Minesweeper)游戏

我们都玩过Windows操作系统中的经典游戏扫雷(Minesweeper),如果把质数当作一颗雷,那么,表格中红色的数字哪些是雷(质数)?您能找出多少个呢?文中用列表的方式罗列了10000以内的自然数、质数(素数),6的倍数等,方便大家观察质数的分布规律及特性,以便对算法求解有指导意义。另外,判断质数是初学算法,理解算法重要性的一个非常好的案例。

《Oracle Java SE编程自学与面试指南》最佳学习路线图(2020最新版)

正确选择比瞎努力更重要!

Java岗开发3年,公司临时抽查算法,离职后这几题我记一辈子

前几天我们公司做了一件蠢事,非常非常愚蠢的事情。我原以为从学校出来之后,除了找工作有测试外,不会有任何与考试有关的事儿。 但是,天有不测风云,公司技术总监、人事总监两位大佬突然降临到我们事业线,叫上我老大,给我们组织了一场别开生面的“考试”。 那是一个风和日丽的下午,我翘着二郎腿,左手端着一杯卡布奇诺,右手抓着我的罗技鼠标,滚动着轮轴,穿梭在头条热点之间。 “淡黄的长裙~蓬松的头发...

面试官:你连SSO都不懂,就别来面试了

大厂竟然要考我SSO,卧槽。

终于,月薪过5万了!

来看几个问题想不想月薪超过5万?想不想进入公司架构组?想不想成为项目组的负责人?想不想成为spring的高手,超越99%的对手?那么本文内容是你必须要掌握的。本文主要详解bean的生命...

我说我懂多线程,面试官立马给我发了offer

不小心拿了几个offer,有点烦

爬虫(九十七)不爬妹子图的爬虫不是一只好爬虫

不爬妹子图的爬虫不是一只好爬虫。----鲁迅还是一样,我们在爬取妹子图片的时候,首先要分析一下 DOM这里的img是就封面,如果只抓取封面的话,到这就可以了,但是我们取的是所有图片,所...

自从喜欢上了B站这12个UP主,我越来越觉得自己是个废柴了!

不怕告诉你,我自从喜欢上了这12个UP主,哔哩哔哩成为了我手机上最耗电的软件,几乎每天都会看,可是吧,看的越多,我就越觉得自己是个废柴,唉,老天不公啊,不信你看看…… 间接性踌躇满志,持续性混吃等死,都是因为你们……但是,自己的学习力在慢慢变强,这是不容忽视的,推荐给你们! 都说B站是个宝,可是有人不会挖啊,没事,今天咱挖好的送你一箩筐,首先啊,我在B站上最喜欢看这个家伙的视频了,为啥 ,咱撇...

代码注释如此沙雕,会玩还是你们程序员!

某站后端代码被“开源”,同时刷遍全网的,还有代码里的那些神注释。 我们这才知道,原来程序员个个都是段子手;这么多年来,我们也走过了他们的无数套路… 首先,产品经理,是永远永远吐槽不完的!网友的评论也非常扎心,说看这些代码就像在阅读程序员的日记,每一页都写满了对产品经理的恨。 然后,也要发出直击灵魂的质问:你是尊贵的付费大会员吗? 这不禁让人想起之前某音乐app的穷逼Vip,果然,穷逼在哪里都是...

2020春招面试了10多家大厂,我把问烂了的数据库事务知识点总结了一下

2020年截止目前,我面试了阿里巴巴、腾讯、美团、拼多多、京东、快手等互联网大厂。我发现数据库事务在面试中出现的次数非常多。

立即提问
相关内容推荐