测试环境,使用dopod818写蓝牙的数据发送,而接收端直接使用MOTO E680i进行测试
原想使用eVC++开发,都是些API调用的方式,够麻烦,不想这样麻烦,无意发现opennetcf的组件库,哈哈,简单多了!
开始吧,用组件吧,毕竟VS2003也是用MS的,自己无需从底层写了,可以注重应用的开发!
搜索蓝牙设备,并记录蓝牙设备的MAC,然后通过连接,取得NetworkStream的实例对象,通过NetworkStream发送数据
BluetoothClient bc = new BluetoothClient();
BluetoothDeviceInfo[] bdi = bc.DiscoverDevices(20);
Guid spguid = BluetoothService.ObexObjectPush;
string BTMAC= bdi[0].DeviceID.ToString();
BluetoothAddress btaddress = BluetoothAddress.Parse(BTMAC);
BluetoothEndPoint endpoint = = new BluetoothEndPoint(btaddress, spguid);
BluetoothClient client = new BluetoothClient();client.Connect(endpoint);
NetworkStream stream = (NetworkStream)client.GetStream();
好了,然后可以通过stream发送数据了,主要是数据包的格式,网上有很多,需要的朋友在google中搜一下吧!
int result = BluetoothSend("PUT","测试.txt","来自ITBABY的818的数据...");
switch (result)
{