ZigBee+GPRSWord文件下载.docx
- 文档编号:18920966
- 上传时间:2023-01-02
- 格式:DOCX
- 页数:56
- 大小:213.56KB
ZigBee+GPRSWord文件下载.docx
《ZigBee+GPRSWord文件下载.docx》由会员分享,可在线阅读,更多相关《ZigBee+GPRSWord文件下载.docx(56页珍藏版)》请在冰豆网上搜索。
各部分的主要功能以及程序
前端数据库数据提取客户端
主要功能:
提取数据库的最新一条数据(实际测量中肯定要把最新的数据发送出去),由于前端也是用电脑操作,所以设计客户端,可能真正的测量不可能让人操作的,是做成一体的,把数据从电脑端口发送出去,同事可以设定定时采集的时间,以及服务器的ip地址(最后做好之后希望不再动ZigBee程序,因为比较麻烦,还要下载调试)。
客户端界面:
实现的程序:
usingSystem;
usingSystem.Collections.Generic;
usingSystem.ComponentModel;
usingSystem.Data;
usingSystem.Drawing;
usingSystem.Text;
usingSystem.Windows.Forms;
usingSystem.Data.OleDb;
namespaceTest1
{
publicpartialclassForm1:
Form
{
publicForm1()
InitializeComponent();
}
privatevoidForm1_Load(objectsender,EventArgse)
{
OleDbConnectionthisConnection=newOleDbConnection(@"
provider=Microsoft.Jet.OLEDB.4.0;
DataSource=cjs.mdb"
);
stringsql="
select*fromcaiji1"
;
OleDbDataAdapterthisAdapter=newOleDbDataAdapter(sql,thisConnection);
DataSetthisDataSet=newDataSet();
thisAdapter.Fill(thisDataSet,"
table"
dataGridView1.DataSource=thisDataSet.Tables["
];
thisConnection.Close();
privatevoidbutton1_Click(objectsender,EventArgse)
try
serialPort1.PortName=comboBox1.Text;
serialPort1.BaudRate=Convert.ToInt32(comboBox2.Text);
serialPort1.Open();
button1.Enabled=false;
button2.Enabled=true;
button3.Enabled=true;
button4.Enabled=true;
button5.Enabled=true;
button6.Enabled=true;
catch(Exception)
Console.WriteLine("
请检查串口是否可用"
privatevoidbutton2_Click(objectsender,EventArgse)
serialPort1.Close();
button1.Enabled=true;
button2.Enabled=false;
button3.Enabled=false;
button4.Enabled=false;
button5.Enabled=false;
button6.Enabled=false;
privatevoidtimer1_Tick(objectsender,EventArgse)
textBox1.Text=textBox7.Text;
textBox2.Text=textBox8.Text;
textBox3.Text=textBox9.Text;
textBox4.Text=textBox10.Text;
textBox5.Text=textBox11.Text;
textBox6.Text=textBox12.Text;
select*fromcaiji1where序号=(selectmax(序号)fromcaiji1)"
textBox7.Text=dataGridView1.Rows[0].Cells[2].Value.ToString();
textBox8.Text=dataGridView1.Rows[0].Cells[3].Value.ToString();
textBox9.Text=dataGridView1.Rows[0].Cells[4].Value.ToString();
textBox10.Text=dataGridView1.Rows[0].Cells[5].Value.ToString();
textBox11.Text=dataGridView1.Rows[0].Cells[6].Value.ToString();
textBox12.Text=dataGridView1.Rows[0].Cells[7].Value.ToString();
stringsql1=label1.Text+textBox1.Text+label2.Text+textBox2.Text+label3.Text+textBox3.Text+label4.Text+textBox4.Text+label5.Text+textBox5.Text+label6.Text+textBox6.Text;
stringsql2=label1.Text+textBox7.Text+label2.Text+textBox8.Text+label3.Text+textBox9.Text+label4.Text+textBox10.Text+label5.Text+textBox12.Text+label6.Text+textBox13.Text;
if(sql1==sql2)
serialPort1.WriteLine(sql1);
privatevoidbutton3_Click_1(objectsender,EventArgse)
stringsql1="
LIAN"
privatevoidbutton4_Click_1(objectsender,EventArgse)
timer1.Interval=Convert.ToInt32(textBox14.Text);
//设置timer1的timer1_Tick实践执行周期为1000毫秒
timer1.Enabled=true;
//设置为truetimer1_Tick实践就会执行,开始计时
privatevoidbutton5_Click_1(objectsender,EventArgse)
IP"
+textBox13.ToString();
privatevoidbutton6_Click_1(objectsender,EventArgse)
timer1.Enabled=false;
}
ZigBee终端
设置好波特率,从串口接受数据,直接发送到协调器
终端程序:
主要就是波特率设置以及串口设置,也就是标文字的地方。
/******************************************************************************
Filename:
GenericApp.c
Revised:
$Date:
2012-03-0701:
04:
58-0800(Wed,07Mar2012)$
Revision:
$Revision:
29656$
Description:
GenericApplication(noProfile).
Copyright2004-2012TexasInstrumentsIncorporated.Allrightsreserved.
ShouldyouhaveanyquestionsregardingyourrighttousethisSoftware,
contactTexasInstrumentsIncorporatedatwww.TI.com.
******************************************************************************/
/*********************************************************************
Thisapplicationisn'
tintendedtodoanythinguseful,itis
intendedtobeasimpleexampleofanapplication'
sstructure.
Thisapplicationsends"
HelloWorld"
toanother"
Generic"
applicationevery5seconds.Theapplicationwillalso
receives"
packets.
The"
messagesaresent/receivedasMSGtypemessage.
Thisapplicationsdoesn'
thaveaprofile,soithandleseverything
directly-itself.
Keycontrol:
SW1:
SW2:
initiatesenddevicebinding
SW3:
SW4:
initiatesamatchdescriptionrequest
*********************************************************************/
*INCLUDES
*/
#include"
OSAL.h"
AF.h"
ZDApp.h"
ZDObject.h"
ZDProfile.h"
GenericApp.h"
DebugTrace.h"
#if!
defined(WIN32)
#include"
OnBoard.h"
#endif
/*HAL*/
hal_lcd.h"
hal_led.h"
hal_key.h"
hal_uart.h"
/*RTOS*/
#ifdefined(IAR_ARMCM3_LM)
RTOS_App.h"
#endif
*MACROS
*CONSTANTS
*TYPEDEFS
*GLOBALVARIABLES
//ThislistshouldbefilledwithApplicationspecificClusterIDs.
constcId_tGenericApp_ClusterList[GENERICAPP_MAX_CLUSTERS]=
GENERICAPP_CLUSTERID
};
constSimpleDescriptionFormat_tGenericApp_SimpleDesc=
GENERICAPP_ENDPOINT,//intEndpoint;
GENERICAPP_PROFID,//uint16AppProfId[2];
GENERICAPP_DEVICEID,//uint16AppDeviceId[2];
GENERICAPP_DEVICE_VERSION,//intAppDevVer:
4;
GENERICAPP_FLAGS,//intAppFlags:
GENERICAPP_MAX_CLUSTERS,//byteAppNumInClusters;
(cId_t*)GenericApp_ClusterList,//byte*pAppInClusterList;
(cId_t*)GenericApp_ClusterList//byte*pAppInClusterList;
//ThisistheEndpoint/Interfacedescription.Itisdefinedhere,but
//filled-ininGenericApp_Init().Anotherwaytogowouldbetofill
//inthestructurehereandmakeita"
const"
(incodespace).The
//wayit'
sdefinedinthissampleappitisdefineinRAM.
endPointDesc_tGenericApp_epDesc;
*EXTERNALVARIABLES
*EXTERNALFUNCTIONS
*LOCALVARIABLES
byteGenericApp_TaskID;
//TaskIDforinternaltask/eventprocessing
//Thisvariablewillbereceivedwhen
//GenericApp_Init()iscalled.
devStates_tGenericApp_NwkState;
byteGenericApp_TransID;
//ThisistheuniquemessageID(counter)
afAddrType_tGenericApp_DstAddr;
*LOCALFUNCTIONS
staticvoidGenericApp_ProcessZDOMsgs(zdoIncomingMsg_t*inMsg);
staticvoidGenericApp_HandleKeys(byteshift,bytekeys);
staticvoidGenericApp_MessageMSGCB(afIncomingMSGPacket_t*pckt);
staticvoidGenericApp_SendTheMessage(void);
staticvoidrxCB(uint8port,uint8event);
//我加的,声明串口回调函数
staticvoidGenericApp_ProcessRtosMessage(void);
*NETWORKLAYERCALLBACKS
*PUBLICFUNCTIONS
*@fnGenericApp_Init
*
*@briefInitializationfunctionfortheGenericAppTask.
*Thisiscalledduringinitializationandshouldcontain
*anyapplicationspecificinitialization(ie.hardware
*initialization/setup,tableinitialization,powerup
*notificaiton...).
*@paramtask_id-theIDassignedbyOSAL.ThisIDshouldbe
*usedtosendmessagesandsettimers.
*@returnnone
voidGenericApp_Init(uint8task_id)
GenericApp_TaskID=task_id;
GenericApp_NwkState=DEV_INIT;
GenericApp_TransID=0;
//下面六句是我加的,初始化串口的
halUA
- 配套讲稿:
如PPT文件的首页显示word图标,表示该PPT已包含配套word讲稿。双击word图标可打开word文档。
- 特殊限制:
部分文档作品中含有的国旗、国徽等图片,仅作为作品整体效果示例展示,禁止商用。设计者仅对作品中独创性部分享有著作权。
- 关 键 词:
- ZigBee GPRS