蓝牙开发总结
来源:互联网 发布:汉语语法 知乎 编辑:程序博客网 时间:2024/05/21 19:31
1.Android开发
使用android自带的开发包
btAdapt = BluetoothAdapter.getDefaultAdapter();btAdapt.startDiscovery();IntentFilter intent = new IntentFilter(); intent.addAction(BluetoothDevice.ACTION_FOUND);intent.addAction(BluetoothDevice.ACTION_BOND_STATE_CHANGED); intent.addAction(BluetoothAdapter.ACTION_SCAN_MODE_CHANGED); intent.addAction(BluetoothAdapter.ACTION_STATE_CHANGED); registerReceiver(searchDevices, intent); intent.getParcelableExtra(BluetoothDevice.EXTRA_DEVICE);device.getName();btSocket = btDev.createRfcommSocketToServiceRecord(uuid);btSocket.connect();
2.J2ME使用blueCover开发包
try { localdev = LocalDevice.getLocalDevice(); } catch (BluetoothStateException e) { System.out.println("ERROR: cannot access local device"); }DiscoveryAgent agent = localdev.getDiscoveryAgent(); try { agent.startInquiry(DiscoveryAgent.GIAC, listener); } catch (BluetoothStateException e) { System.out.println("Device unable to inquiry"); System.exit(2); }
3.C#使用的蓝牙 InTheHand.Net.Personal dll
_NearbyDevices = new List(); BluetoothClient cli = new BluetoothClient(); BluetoothDeviceInfo[] devices = cli.DiscoverDevices(); if (devices.Length == 0) { mybluetooth = false; } foreach (BluetoothDeviceInfo d in devices) { _NearbyDevices.Add(d); mybluetooth = true; } return _NearbyDevices;
// -------------------------12 -27 finish-----------------------------------------
//注册Receiver来获取蓝牙设备相关的结果
IntentFilter intent = new IntentFilter();registerReceiver(searchDevices, intent); //蓝牙uuid UUID uuid = new UUID(0x0000110100001000L,0x800000805F9B34FBL);//connect 前必须先完成createBond btSocket = btDevice.createRfcommSocketToServiceRecord(uuid); btSocket.connect();
// 广播pin
<receiver android:name="com.sceec.MainInterface"> <intent-filter> <!-- <action android:name="android.bluetooth.intent.action.DISCOVERY_COMPLETED" /> <action android:name="android.bluetooth.intent.action.DISCOVERY_STARTED" /> <action android:name="android.bluetooth.intent.action.NAME_CHANGED" /> <action android:name="android.bluetooth.intent.action.SCAN_MODE_CHANGED" /> <action android:name="android.bluetooth.intent.action.BLUETOOTH_STATE_CHANGED" /> <action android:name="android.bluetooth.intent.action.REMOTE_DEVICE_CONNECTED" /> <action android:name="android.bluetooth.intent.action.REMOTE_DEVICE_DISCONNECTED" /> <action android:name="android.bluetooth.intent.action.REMOTE_DEVICE_DISCONNECT_REQUESTED" /> <action android:name="android.bluetooth.intent.action.BOND_STATE_CHANGED" /> <action android:name="android.bluetooth.intent.action.PAIRING_REQUEST" /> <action android:name="android.bluetooth.intent.action.PAIRING_CANCEL" /> <action android:name="android.bluetooth.intent.action.REMOTE_DEVICE_CLASS_UPDATED" /> <action android:name="android.bluetooth.intent.action.REMOTE_DEVICE_FOUND" /> <action android:name="android.bluetooth.intent.action.REMOTE_NAME_UPDATED" /> <data android:scheme="file"/> --> <action android:name="android.bluetooth.intent.action.PAIRING_REQUEST" /> </intent-filter> </receiver>//本机显示pin intent.action.PAIRING_REQUEST 本机不显示
<action android:name="android.bluetooth.device.action.PAIRING_REQUEST" />
4.使用串口通信,根据驱动程序,把蓝牙通信信息传输到串口。
然后和聂小猛童鞋程序类似。实现蓝牙通信。
- 蓝牙开发总结
- iphone 蓝牙开发 总结
- Andriod蓝牙开发总结
- ios 蓝牙开发总结
- iPhone开发:蓝牙项目总结
- android 蓝牙开发常见问题总结
- Android蓝牙开发全面总结
- Android蓝牙开发全面总结
- Android蓝牙开发全面总结
- Android蓝牙通信开发总结
- iOS开发之蓝牙总结
- Android蓝牙开发全面总结
- Android无线蓝牙开发总结
- 05-iOS蓝牙开发总结
- iOS蓝牙开发总结-4
- Android无线蓝牙开发总结
- CoreBlueTooth 蓝牙开发相关总结
- Android蓝牙开发全面总结
- tomcat-user-xml 配置文件
- 如何使用mstsc进行远程登录?
- linux下自动创建设备文件节点---class
- 如何搭建自己的iPhone Installer软件源
- 使用zend framework 搭建网站(七)--实现多服务器共享 SESSION 数据
- 蓝牙开发总结
- 2011-12-03晴,
- 几种常见的基于Lucene的开源搜索解决方案对比
- linux虚拟机的安装
- 为什么有的人飞黄腾达,有的人穷困潦倒
- UISearchBar下拉列表(类似百度搜索)代码分享
- Android系统首次应用于工业级坚固型PDA
- 盈利模式:从一款小应用看日本开发者大智慧
- 使用zend framework框架搭建网站(三) --smarty扩展