物联网学习,每日一考一练!

时间:2022年10月21日下午4:16
物联网学习,每日一考一练!

物联网学习,每日一考一练!

物联网学习,每日一考一练:考试不是目的,学习知识才是重点!

完成以下答题能掌握的知识点:

物联网的基本概念

单片机IO口基本配置

Zigbee中函数传参

Zigbee 函数调用

中断函数使用

ZigBee 无线传感网组网

物联网学习,每日一考一练!


一、基础题 (掌握和学习物联网的基本概念)

1、下面哪一项不属于物联网关键技术?

A.ZigBee技术 B. RFID C.低功耗蓝牙技术 D.收音机

2、我国提出发展中国的物联网的口号是?

A.智慧地球 B.感知中国 C.U-CHINA D.认知中国

3、非接触式自动识别技术是

A.ZigBee B. M2M C.RFID D.NFC

4、智慧地球(Smarter Planet)是谁最先提出的( )

A.无锡研究院 B.温总理 C. IBM D. 奥巴马

5、物联网的英文名字是(), 简称();

6、()是物联网采集信息的终端工具;

7、()与IPv4协议相比和物联网的联系更广泛;

8、ZigBee节点所属类别有3种,包括:()、()、()。


二、应用题

应用题1:主要掌握单片机IO口基本配置

1.基础实验,我们常需要对IO口进行配置,点亮LED1?

/*************************************
 描述:点亮LED1
 IO口:LED1-P1.0
 点亮:低电平点亮
**************************************/
#include <ioCC2530.h>
#define LED1 ? //定义P10口为LED1控制端 
void IO_Init(void)
{
 P1SEL &=~0x01; //作为普通IO口 
 P1DIR |= ? ; //P1_0定义为输出 
 P1INP &=~0X01; //打开上拉 
}
void main(void)
{ 
 IO_Init(); //调用初始化程序
 LED1= ? ; //点亮LED1 
 while(1);
}

请在上面#define LED1 ? 和 LED1= ? ; //点亮LED1 2处 补充完代码


应用题2:主要掌握Zigbee中函数传参

2. ZigBee数据发送

ZigBee 常用数据发送函数定义如下:

afStatus_t AF_DataRequest( afAddrType_t *dstAddr,
endPointDesc_t *srcEP,
uint16 cID,
uint16 len,
uint8 *buf,
uint8 *transID,
uint8 options,
uint8 radius )

请参考上面代码将下面空格补充完整,实现将数据 data 发送出去。

Void SampleApp _SendPeriodicMessage ( void )
{
uint8 data[10]={0,1,2,3,4,5,6,7,8,9};
if ( AF_DataRequest( &SampleApp_Periodic_DstAddr,
&SampleApp_epDesc,
SAMPLEAPP_PERIODIC_CLUSTERID,
, ,
&SampleApp_TransID,
AF_DISCV_ROUTE,
AF_DEFAULT_RADIUS ) == afStatus_SUCCESS )
{ }
else
{
// Error occurred in request to send.
}

应用题3:主要掌握Zigbee 函数调用

3.编程使节点 1 的 LED1 指示灯复位后闪烁 4 次,闪烁周期为 200ms,即亮 100ms,灭 100ms;可以调用 z-stack 的 LED 闪烁函数:函数如下:

void HalLedBlink (uint8 leds, uint8 numBlinks, uint8 percent, uint16 period)
{
#if (defined (BLINK_LEDS)) && (HAL_LED == TRUE)
 uint8 led;
 HalLedControl_t *sts;
 if (leds && percent && period)
 {
 if (percent < 100)
 {
 led = HAL_LED_1;
 leds &= HAL_LED_ALL;
 sts = HalLedStatusControl.HalLedControlTable;
 while (leds)
 {
 if (leds & led)
 {
 /* Store the current state of the led before going to blinking */
 preBlinkState |= (led & HalLedState);
 sts->mode = HAL_LED_MODE_OFF; /* Stop previous blink */
 sts->time = period; /* Time for one on/off cycle */
 sts->onPct = percent; /* % of cycle LED is on */
 sts->todo = numBlinks; /* Number of blink cycles */
 if (!numBlinks) sts->mode |= HAL_LED_MODE_FLASH; 
 /* Continuous */
 sts->next = osal_GetSystemClock(); /* Start now */
 sts->mode |= HAL_LED_MODE_BLINK; /* Enable blinking */
 leds ^= led;
 }
 led <<= 1;
 sts++;
 }
 osal_set_event (Hal_TaskID, HAL_LED_BLINK_EVENT);
}
 else
 {
 HalLedSet (leds, HAL_LED_MODE_ON); /* >= 100%, turn on */
 }
 }
 else
 {
 HalLedSet (leds, HAL_LED_MODE_OFF); /* No on time, turn off */
 }
#elif (HAL_LED == TRUE)
 percent = (leds & HalLedState) ? HAL_LED_MODE_OFF : HAL_LED_MODE_ON;
 HalLedOnOff (leds, percent); /* Toggle */
#else
 // HAL LED is disabled, suppress unused argument warnings
 (void) leds;
 (void) numBlinks;
 (void) percent;
 (void) period;
#endif /* BLINK_LEDS && HAL_LED */
}

按题目要求调用函数:(?)


题目4:主要掌握中断函数使用

4.编程使节点1的按键S1每按一次,控制LED1灯闪烁一次。

闪烁函数定义:

/***************************************************************************************************

* @fn HalLedSet

*

* @brief Tun ON/OFF/TOGGLE given LEDs

*

* @param leds - HAL_LED_1,HAL_LED_2;

* mode - BLINK, FLASH, TOGGLE, ON, OFF

* @return None

***************************************************************************************************/

uint8 HalLedSet (uint8 leds, uint8 mode);

按键中断函数:

void SampleApp_HandleKeys( uint8 shift, uint8 keys )

{

(void)shift; // Intentionally unreferenced parameter

if ( keys & HAL_KEY_SW_6 )

{

HalUARTWrite(0,"K1 ",3); //提示KEY1被按下

? ; // LED1闪一下

}

if ( keys & HAL_KEY_SW_1 )

{

/* This key sends the Flash Command is sent to Group 1.

* This device will not receive the Flash Command from this

* device (even if it belongs to group 1).

*/

SampleApp_SendFlashMessage( SAMPLEAPP_FLASH_DURATION );

}

if ( keys & HAL_KEY_SW_2 )

{

/* The Flashr Command is sent to Group 1.

* This key toggles this device in and out of group 1.

* If this device doesn't belong to group 1, this application

* will not receive the Flash command sent to group 1.

*/

aps_Group_t *grp;

grp = aps_FindGroup( SAMPLEAPP_ENDPOINT, SAMPLEAPP_FLASH_GROUP );

if ( grp )

{

// Remove from the group

aps_RemoveGroup( SAMPLEAPP_ENDPOINT, SAMPLEAPP_FLASH_GROUP );

}

else

{

// Add to the flash group

aps_AddGroup( SAMPLEAPP_ENDPOINT, &SampleApp_Group );

}

}

}

请完善以上中断函数的调用。


三 综合题:主要掌握如何组建 ZigBee 无线传感网:

打开工程文件 3.1。节点 1 作为协调器,节点 2 作为终端设备且连接温度传

感器 DS18B20,通过周期性读取温度信息发送给协调器。协调器将收集到的温度

信息通过串口 0 发送到 PC 机,并使用串口调试助手打印出来。

要求: 写出下列要求对应的函数或代码,在考试套件上实现题目功能:试卷共 6 页 第 6 页

(1) 配置串口波特率为 115200bps,关闭串口流控;

#define MT_UART_DEFAULT_BAUDRATE
#define MT_UART_DEFAULT_OVERFLOW

(2) 将采集到的温度信息发送给协调器的发送函数;

void SampleApp_SendPointToPointMessage( void )
{
uint8 T[2];//温度
//16 进制转换成 ASCII 码 温度十位
//16 进制转换成 ASCII 码 温度个位
if ( AF_DataRequest( &Point_To_Point_DstAddr,
&SampleApp_epDesc,
SAMPLEAPP_POINT_TO_POINT_CLUSTERID,
2,
T,
&SampleApp_TransID,
AF_DISCV_ROUTE,
AF_DEFAULT_RADIUS ) == afStatus_SUCCESS )
{ }
else
{ // Error occurred in request to send.
}
}

(3) 协调器将接收到的温度信息通过串口 0 打印出来。

void SampleApp_MessageMSGCB( afIncomingMSGPacket_t *pkt )
{
uint16 flashTime;
switch ( pkt->clusterId )
{
case SAMPLEAPP_POINT_TO_POINT_CLUSTERID:
HalUARTWrite(0,"Temp is:",8); //串口提示接收到数据
; //温度信息通过串口 0 发给 PC 机
HalUARTWrite(0,"\n",1); // 回车换行
break;
}
}

以上题目你找到答案了吗?可以关注+私信(IOT)获取完整答案哟!

物联网学习,每日一考一练!

物联网学习,每日一考一练!

二维码
智宇物联平台二维码

搜浪信息科技发展(上海)有限公司 备案号:沪ICP备17005676号