当前位置: 首页>>代码示例>>Java>>正文


Java BITalinoDevice类代码示例

本文整理汇总了Java中com.bitalino.comm.BITalinoDevice的典型用法代码示例。如果您正苦于以下问题:Java BITalinoDevice类的具体用法?Java BITalinoDevice怎么用?Java BITalinoDevice使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


BITalinoDevice类属于com.bitalino.comm包,在下文中一共展示了BITalinoDevice类的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: doInBackground

import com.bitalino.comm.BITalinoDevice; //导入依赖的package包/类
@Override
protected Void doInBackground(Void... paramses) {
  try {
    // Let's get the remote Bluetooth device
    final String remoteDevice = macAddress;

    final BluetoothAdapter btAdapter = BluetoothAdapter.getDefaultAdapter();
    dev = btAdapter.getRemoteDevice(remoteDevice);

/*
 * Establish Bluetooth connection
 *
 * Because discovery is a heavyweight procedure for the Bluetooth adapter,
 * this method should always be called before attempting to connect to a
 * remote device with connect(). Discovery is not managed by the Activity,
 * but is run as a system service, so an application should always call
 * cancel discovery even if it did not directly request a discovery, just to
 * be sure. If Bluetooth state is not STATE_ON, this API will return false.
 *
 * see
 * http://developer.android.com/reference/android/bluetooth/BluetoothAdapter
 * .html#cancelDiscovery()
 */
    Log.d(TAG, "Stopping Bluetooth discovery.");
    btAdapter.cancelDiscovery();

    sock = dev.createRfcommSocketToServiceRecord(MY_UUID);
    sock.connect();

    BITalinoDevice bitalino = new BITalinoDevice(1000, new int[]{0, 1, 2, 3, 4, 5});
    Log.i(TAG, "Connecting to BITalino [" + remoteDevice + "]..");
    bitalino.open(sock.getInputStream(), sock.getOutputStream());
    Log.i(TAG, "Connected.");

    // get BITalino version
    Log.i(TAG, "Version: " + bitalino.version());

    // start acquisition on predefined analog channels
    bitalino.start();

    // read n samples
    final int numberOfSamplesToRead = 1000;
    Log.i(TAG, "Reading " + numberOfSamplesToRead + " samples..");
    while (!isCancelled()) {
      BITalinoFrame[] frames = bitalino.read(numberOfSamplesToRead);
      publishProgress(frames);
    }
  } catch (Exception e) {
    Log.e(TAG, "There was an error.", e);
  }

  return null;
}
 
开发者ID:pires,项目名称:opensignals-android,代码行数:54,代码来源:ValuesActivity.java


注:本文中的com.bitalino.comm.BITalinoDevice类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。