基于Zigbee的家居环境信息采集平台设计与开发

 2022-07-18 12:07

论文总字数:9256字

基于Zigbee的家居环境信息采集平台设计与开发

程序源代码

电气工程学院 院(系) 电气工程及其自动化专业

学 号 16014429

学生姓名 虞 悦

指导教师 金 龙

起止日期 2018.1.13——2018.5.15

设计地点 动力楼

设计中主要代码如下:

#ifndef NONWK

#include"AF.h"

#endif

#include"hal_adc.h"

#include"hal_flash.h"

#include"hal_lcd.h"

#include"hal_led.h"

#include"hal_drivers.h"

#include"OnBoard.h"

#include"OSAL.h"

#include"OSAL_Nv.h"

#include"ZComDef.h"

#include"ZMAC.h"

int main(void){

osal_int_disable(INTS_ALL);

HAL_BOARD_INIT();

zmain_vdd_check();

InitBoard(OB_COLD);

HalDriverInit();

osal_nv_init(NULL);

ZMacInit();

zmain_ext_addr();

#if defined ZCL_KEY_ESTABLISH

zmain_cert_init();

#endif

zgInit();

#ifndef NONWK

afInit();

#endif

osal_init_system();

osal_int_enable(INTS_ALL);

InitBoard(OB_READY);

zmain_dev_info();

#ifdef LCD_SUPPORTED

zmain_lcd_init();

#endif

#ifdef WDT_IN_PM1

WatchDogEnable(WDTIMX);

#endif

osal_start_system();

return 0;

}

#ifndef SAMPLEAPP_H

#define SAMPLEAPP_H

#ifdef __cplusplus

extern "C"{

#endif

#include"ZComDef.h"

#define SAMPLEAPP_ENDPOINT 20

#define SAMPLEAPP_PROFID 0x0F08

#define SAMPLEAPP_DEVICEID 0x0001

#define SAMPLEAPP_DEVICE_VERSION 0

#define SAMPLEAPP_FLAGS 0

#define SAMPLEAPP_MAX_CLUSTERS 3

#define SAMPLEAPP_PERIODIC_CLUSTERID 1

#define SAMPLEAPP_FLASH_CLUSTERID 2

#define SAMPLEAPP_P2P_CLUSTERID 3

#define SAMPLEAPP_SEND_PERIODIC_MSG_TIMEOUT 2000

#define SAMPLEAPP_SEND_PERIODIC_MSG_EVT 0x0001

#define SAMPLEAPP_FLASH_GROUP 0x0001

#define SAMPLEAPP_FLASH_DURATION 1000

extern void SampleApp_Init(uint8 task_id);

extern UINT16 SampleApp_ProcessEvent(uint8 task_id, uint16 events);

#ifdef __cplusplus

}

#endif

#endif

#ifndef _HAL_TYPES_H

#define _HAL_TYPES_H

typedef signed char int8;

typedef unsigned char uint8;

typedef signed short int16;

typedef unsigned short uint16;

typedef signed long int32;

typedef unsigned long uint32;

typedef unsigned char bool;

typedef uint8 halDataAlign_t;

#ifdef __IAR_SYSTEMS_ICC__

#define CODE __code

#define XDATA __xdata

#elif defined __KEIL__

#define CODE code

#define XDATA xdata

#else

#error "ERROR: Unknown compiler."

#endif

#ifndef TRUE

#define TRUE 1

#endif

#ifndef FALSE

#define FALSE 0

#endif

#ifndef NULL

#define NULL 0

#endif

#endif

#include"OSAL.h"

#include"ZGlobals.h"

#include"AF.h"

#include"aps_groups.h"

#include"ZDApp.h"

#include"SampleApp.h"

#include"SampleAppHw.h"

#include"OnBoard.h"

#include"hal_lcd.h"

#include"hal_led.h"

#include"hal_key.h"

#include"MT_UART.h"

#include"MT_APP.h"

#include"MT.h"

#include"DHT11.h"

uint8 AppTitle[]="2530DHT11 seu";

void SampleApp_MessageMSGCB(afIncomingMSGPacket_t *pkt){

uint16 flashTime;

switch(pkt-gt;clusterId){

case SAMPLEAPP_P2P_CLUSTERID:

HalUARTWrite(0,"Tempamp;Hum:",9);

HalUARTWrite(0,pkt-gt;cmd.Data,pkt-gt;cmd.DataLength);

HalUARTWrite(0,"\n",1);

break;

case SAMPLEAPP_PERIODIC_CLUSTERID:

break;

case SAMPLEAPP_FLASH_CLUSTERID:

flashTime = BUILD_UINT16(pkt-gt;cmd.Data[1], pkt-gt;cmd.Data[2]);

HalLedBlink(HAL_LED_4,4,50,(flashTime/4));

break;

}

}

void SampleApp_SendPeriodicMessage(void){

if(AF_DataRequest(amp;SampleApp_Periodic_DstAddr,

amp;SampleApp_epDesc,

SAMPLEAPP_PERIODIC_CLUSTERID,

1,

(uint8*)amp;SampleAppPeriodicCounter,

amp;SampleApp_TransID,

AF_DISCV_ROUTE,

AF_DEFAULT_RADIUS)==afStatus_SUCCESS){ }

else{ }

}

#ifndef __DHT11_H__

#define __DHT11_H__

#define uchar unsigned char

extern void Delay_ms(unsigned int xms);

extern void COM(void);

extern void DHT11(void);

extern uchar temp[2];

extern uchar temp1[5];

extern uchar humidity[2];

extern uchar humidity1[9];

extern uchar hum_ten,hum_uni,temp_ten,temp_uni;

#endif

#includelt;ioCC2530.hgt;

#include "OnBoard.h"

typedef unsigned char uchar;

typedef unsigned int uint;

#define DATA_PIN P0_7

void Delay_us(void);

void Delay_10us(void);

void Delay_ms(uint Time);

void COM(void);

void DHT11(void);

uchar ucFLAG,ucbit;

uchar hum_ten,hum_uni,temp_ten,temp_uni=4;

uchar ucT_H,ucT_L,ucRH_H,ucRH_L,uccheckdata;

uchar ucT_H_bit,ucT_L_bit,ucRH_H_bit,ucRH_L_bit,uccheckdata_bit;

uchar uccomdata;

void Delay_us(void){

MicroWait(1);

}

void Delay_10us(void){

MicroWait(10);

剩余内容已隐藏,请支付后下载全文,论文总字数:9256字

您需要先支付 80元 才能查看全部内容!立即支付

该课题毕业论文、开题报告、外文翻译、程序设计、图纸设计等资料可联系客服协助查找;