蓝牙实习报告Word文档格式.docx

上传人:b****6 文档编号:19690111 上传时间:2023-01-08 格式:DOCX 页数:10 大小:367.61KB
下载 相关 举报
蓝牙实习报告Word文档格式.docx_第1页
第1页 / 共10页
蓝牙实习报告Word文档格式.docx_第2页
第2页 / 共10页
蓝牙实习报告Word文档格式.docx_第3页
第3页 / 共10页
蓝牙实习报告Word文档格式.docx_第4页
第4页 / 共10页
蓝牙实习报告Word文档格式.docx_第5页
第5页 / 共10页
点击查看更多>>
下载资源
资源描述

蓝牙实习报告Word文档格式.docx

《蓝牙实习报告Word文档格式.docx》由会员分享,可在线阅读,更多相关《蓝牙实习报告Word文档格式.docx(10页珍藏版)》请在冰豆网上搜索。

蓝牙实习报告Word文档格式.docx

实习主程序

总体的蓝牙功能介绍:

蓝牙操作具有搜索蓝牙设备、浏览发送文件、发送文件、清空蓝牙列表、状态栏、显示时间日期、清空历史记录、的作用。

(1)搜索蓝牙设备

usingSystem;

usingSystem.Collections.Generic;

usingSystem.ComponentModel;

usingSystem.Data;

usingSystem.Drawing;

usingSystem.Text;

usingSystem.Windows.Forms;

usingInTheHand.Net;

        //必要的引用

usingInTheHand.Net.Bluetooth;

//必要的引用

usingInTheHand.Net.Ports;

usingInTheHand.Net.Sockets;

namespacelanya

{

publicpartialclassForm1:

Form

{

publicForm1()

InitializeComponent();

}

privatevoidbuttonscan_Click(objectsender,EventArgse)

BluetoothRadioradio=BluetoothRadio.PrimaryRadio;

if(radio==null)

MessageBox.Show("

没有蓝牙设备或没有支持的蓝牙协议"

);

return;

radio.Mode=RadioMode.Discoverable;

BluetoothClientclient=newBluetoothClient();

statusBar1.Text="

正在搜索中"

;

Application.DoEvents();

BluetoothDeviceInfo[]bthdevice=client.DiscoverDevices();

//通过client.DiscoverDevices()寻找附近的bluetooth设备

cbdevices.DataSource=bthdevice;

cbdevices.DisplayMember="

DeviceName"

cbdevices.ValueMember="

DeviceAddress"

//搜索完成

搜索完成"

}

(2)浏览与发送

privatevoidbuttonskip_Click(objectsender,EventArgse)

OpenFileDialogofd=newOpenFileDialog();

if(ofd.ShowDialog()==DialogResult.OK){textBoxfilename.Text=ofd.FileName;

privatevoidForm1_Load(objectsender,EventArgse)}

privatevoidbutton3_Click(objectsender,EventArgse)

System.Uriuri=newUri("

obex:

//"

+cbdevices.SelectedValue.ToString()+"

/"

+//获取服务器obex的uri,获取要传送的文件名

System.IO.Path.GetFileName(textBoxfilename.Text.Trim()));

ObexWebResponseresponse=null;

//新建response变量

ObexWebRequestrequest=newObexWebRequest(uri);

//通过ObexWebRequest来推文件到目标机器,发送请求,等待回应

try

request.ReadFile(textBoxfilename.Text.Trim());

//读出textboxfilename的文件内容

response=(ObexWebResponse)request.GetResponse();

//回应封装在ObexWebResponse类里面。

如果目标机器的Obex服务没有打开,会发生文件传输错误。

MessageBox.Show(response.StatusCode.ToString());

catch

传输失败"

finally

if(response!

=null)

response.Close();

其中:

1、System.Uriuri=newUri("

+cbDevices.SelectedValue.ToString()+"

+System.IO.Path.GetFileName(tbad.Text.Trim())+System.Net.Dns.GetHostName());

其中newUri("

+cbDevices.SelectedValue.ToString()

代表的是要发送的蓝牙的地址,System.IO.Path.GetFileName(tbad.Text.Trim())这一句代表的是要发送的文件;

System.Net.Dns.GetHostName()代表的是本机的地址。

2、Intcountre;

For(counter=0;

counter<

=100;

counter++)progressBar1.Value=Counter;

这一句代表的是在蓝牙发送过程中加上一个进度指示标志从更加直观的显示发送文件的过程。

(3)蓝牙发送与接收

usingSystem.Threading;

namespace_910414zcy

privateThreadthreadfile;

privateObexListenerlistener;

privateboollistening;

privatedelegatevoidSafeWinFormsThreadDelegate(stringmsg);

//监听线程

privatevoidWriteMsg(stringmsg)

SafeWinFormsThreadDelegated;

d=newSafeWinFormsThreadDelegate(UpdateUI);

Invoke(d,newobject[]{msg});

publicvoidDealWithRequest()//处理请求

while(this.listener.IsListening)

ObexListenerContextolc=listener.GetContext();

ObexListenerRequestolr=olc.Request;

stringfilename=olr.RawUrl.TrimStart(newchar[]{'

/'

});

olr.WriteFile(DateTime.Now.ToString("

2012-12-12"

)+filename);

{continue;

privatevoidUpdateUI(stringmsg)

listBox1.Items.Add(msg);

privatevoidbutton1_Click(objectsender,EventArgse)//开始按钮程序

if(listener==null)

listener=newObexListener();

BluetoothRadio.PrimaryRadio.Mode=RadioMode.Discoverable;

listener.Start();

listening=true;

threadfile=newThread(DealWithRequest);

threadfile.Start();

button1.Enabled=false;

button2.Enabled=true;

UpdateUI("

监听开始!

"

privatevoidbutton2_Click(objectsender,EventArgse)//停止按钮程序

if(listener!

listener.Stop();

if(threadfile!

threadfile.Abort();

button1.Enabled=true;

button2.Enabled=false;

点按“开始”按钮,文本框显示“监听开始”

 

(4)部署应用程序

当在桌面计算机上完成了WindowsCE应用程序开发和测试工作之后,就需要将其部署到设备中去运行。

具体步骤如下:

①部署.NETCompactFramework2.0;

②制作CAB安装包;

③创建CAB安装包项目;

④编辑器,当CAB安装包项目创建好了之后,VS.NET2005就会自动打开文件系统编辑器;

⑤添加可执行文件;

⑥创建快捷方式;

⑦生成安装包和分发安装包

4、实习心得:

为期一周的时间很快过去了,时间虽短,却是让我受益匪浅。

这次的基于WINCE平台的蓝牙嵌入式系统的应用实践实习

让我在短短的时间内了解了嵌入式系统和嵌入式技术,学会了用C语言编写程序来达到实现蓝牙基本传输功能。

同时对项目的安装和部署也有了初步的认识。

同时也明白了一个学生要想真正掌握一门课程、一个知识点,仅仅通过课本上的理论是不可能实现的,只有将理论与实践融合起来,将理论付诸于实践,将实践回归于理论,才是掌握并且运用一个知识点最好的方式。

在实习中与队友的合作是必不可少的,要有团队合作精神,善于听取不同的建议,分享我们的想法,共同去做好这次的实习。

同时也谢谢两位实习老师,在我们的设计过程中所遇到的问题一次次不厌烦的给与指导和帮助。

这一次的实习是我在整个大学中平凡却又特别的一个经历。

嵌入式实验报告

姓名:

孙宏强

学号:

111041123

学院班级:

电信学院111041A

专业:

通信工程

展开阅读全文
相关资源
猜你喜欢
相关搜索

当前位置:首页 > 初中教育 > 学科竞赛

copyright@ 2008-2022 冰豆网网站版权所有

经营许可证编号:鄂ICP备2022015515号-1