小编ck1*_*221的帖子

Android BluetoothGatt - 状态133 - 注册回调

首先我读了解答:GATT回调无法注册并采取该帖子中建议的步骤来解决此问题但没有成功.如果你还没有阅读它,那里的推荐修复是直接从主线程或使用处理程序进行所有BLE调用.

我正在开发一个BLE应用程序,希望运行一项执行以下任务的服务(每10秒调用一次活动):

1)Gets list of our products available to connect to (done, works)

2)For each available device:

          2a)connect to device
          2b)discover services
          2c)read 5 characteristics in this fashion:
             2c1)read characteristic
             2c2)onCharacteristicRead parse data
             2c3)when finished with data read next characteristic
             2c4)repeat until all are read (this is done using a state var and switch statement)
         2d)disconnect from device
         2e)connect to next device
         2f)repeat until all devices are read from
         2g)stopSelf()
Run Code Online (Sandbox Code Playgroud)

所以这个问题......一切都很有效.我可以执行整个服务启动{startService(...); 在mainActivity中完成{stopSelf(); 在服务中} 6次.

在第7次我得到BluetoothGatt无法注册回调.我不知道为什么我能成功运行6次然后在第7次失败. …

android bluetooth-lowenergy gatt

39
推荐指数
3
解决办法
5万
查看次数

Odd Java String []问题,包含值,但在插入List <String []>时的行为类似于null

我遇到String数组的问题,并尝试将其添加到列表(List).以下是使用和创建问题的代码.

程序在第一次循环运行时失败,我已经使用OpenCSV验证了来自CSV的输入.

List<String[]> output = null;
String[] temp;

for(int i = 0; i < 13; i++)
{               
    temp = reader.readNext();                           //read next line into temp
    System.out.println(temp[0]+temp[1]+temp[2]);        //temp output
    temp[2] = String.valueOf((values[i])/100);          //assign new value
    System.out.println(temp[0]+temp[1]+temp[2]);        //temp output
    output.add(temp);
}
Run Code Online (Sandbox Code Playgroud)

当此代码运行时输出为.

VANCBULLET0.311
VANCBULLET0.308
Exception in thread "AWT-EventQueue-0" java.lang.NullPointerException
    at Main.updateCSV(Main.java:951)
    at Main.start(Main.java:863)
    at Main.access$23(Main.java:853)
    at Main$23.actionPerformed(Main.java:520)
    at javax.swing.AbstractButton.fireActionPerformed(Unknown Source)
    at javax.swing.AbstractButton$Handler.actionPerformed(Unknown Source)
    at javax.swing.DefaultButtonModel.fireActionPerformed(Unknown Source)
    at javax.swing.DefaultButtonModel.setPressed(Unknown Source)
Run Code Online (Sandbox Code Playgroud)

前两行是正确的,分为:temp [0] temp [1] temp [2] VANC BULLET 0.311 VANC BULLET 0.308

问题是(如错误读取): …

java csv arrays string

0
推荐指数
1
解决办法
257
查看次数

标签 统计

android ×1

arrays ×1

bluetooth-lowenergy ×1

csv ×1

gatt ×1

java ×1

string ×1