小编ber*_*rgo的帖子

Android:蓝牙插座拒绝正确连接

我有一个蓝牙发射器试图连接到我写的基于BluetoothChat(android示例API)的服务.

一旦我运行命令mAdapter.listenUsingInsecureRfcommWithServiceRecord(NAME, MY_UUID),蓝牙就会自动连接(在accept();命令之前,从而使接受阻止流程).有任何想法吗?

我的猜测是有一个套接字在之前的运行中没有正确关闭 - 尽管在这方面的调试没有显示出任何有趣的东西.

代码:

public class BluetoothService extends Service {


    // Unique UUID for this application
    private static final UUID MY_UUID = UUID.fromString("00001101-0000-1000-8000-00805F9B34FB");



    @Override
    public void onCreate() {
        mAdapter = BluetoothAdapter.getDefaultAdapter();
        if (mAdapter == null) {
            Log.e(TAG, "Bluetooth is not available");
            stopSelf();
            return;
        }

        mState = STATE_NONE;
    }
    @Override
    public int onStartCommand(Intent BluetoothService, int flags, int startId ) {
        /**
        * Start the chat service. Specifically start AcceptThread to begin a
        * session …
Run Code Online (Sandbox Code Playgroud)

sockets android bluetooth

5
推荐指数
0
解决办法
1815
查看次数

切换案例有两个变量

我在TI的示例代码中看到以下切换情况,我想知道switch参数接收的第二个变量的含义是什么,

__interrupt void Timer_A(void)
{
  switch (TAIV, 10)        // Efficient switch-implementation
  {
    case  2:  break;                        // TACCR1 not used
    case  4:  break;                        // TACCR2 not used
    case 10:  P1OUT ^= 0x01;                // overflow
              break;
  }
}
Run Code Online (Sandbox Code Playgroud)

我的猜测是首先检查案例值"10"是否优先,但我不确定.

c embedded

3
推荐指数
1
解决办法
1546
查看次数

标签 统计

android ×1

bluetooth ×1

c ×1

embedded ×1

sockets ×1