AF层学习总结

AF层学习总结
2010-03-16 19:00

/*
* afInit - Initialize the AF.
*/
extern void afInit( void );
作用:初始化AF层,在ZMain中mian()函数中调用

/*
* afRegisterExtended - Register an Application's EndPoint description
*           with a callback function for descriptors.
*
*/
extern epList_t *afRegisterExtended( endPointDesc_t *epDesc, pDescCB descFn );
作用:在afRegister()中调用,注册一个端点描述符,可以选择是否需要为端点设定回调函数,
默认为空,即不设定

/*
* afRegister - Register an Application's EndPoint description.
*
*/
extern afStatus_t afRegister( endPointDesc_t *epDesc );
作用:任务中注册一个端点描述符,示例如下:
GenericApp_epDesc.endPoint = GENERICAPP_ENDPOINT;
GenericApp_epDesc.task_id = &GenericApp_TaskID;
GenericApp_epDesc.simpleDesc
            = (SimpleDescriptionFormat_t *)&GenericApp_SimpleDesc;
GenericApp_epDesc.latencyReq = noLatencyReqs;

// Register the endpoint description with the AF
afRegister( &GenericApp_epDesc );

/*
* afDataConfirm - APS will call this function after a data message
*                 has been sent.
*/
extern void afDataConfirm( uint8 endPoint, uint8 transID, ZStatus_t status );
作用:应用层AF_DataRequest()函数中先调用APSDE_DataReq()向下层发送,再调用这个函数,
向与端点相关联的应用层任务中注册一个AF_DATA_CONFIRM_CMD事件,表示确认数据已经发送出去


/*
* afIncomingData - APS will call this function when an incoming
*                   message is received.
*/
extern void afIncomingData( aps_FrameFormat_t *aff, zAddrType_t *SrcAddress,
                       uint8 LinkQuality, byte SecurityUse, uint32 timestamp );
作用:在APS层接收到数据后,会调用这个函数,函数内部调用afBuildMSGIncoming(),
如果项目中定义了MT_AF_CB_FUNC,则向MT注册SPI_CB_AF_DATA_IND事件,否则向应用层注册
AF_INCOMING_MSG_CMD事件,两者只取其一


afStatus_t AF_DataRequest( afAddrType_t *dstAddr, endPointDesc_t *srcEP,
                             uint16 cID, uint16 len, uint8 *buf, uint8 *transID,
                             uint8 options, uint8 radius );
作用:应用层利用此函数,向目标网络地址的设备发送buf中的数据


/*********************************************************************
* Direct Access Functions - ZigBee Device Object
*/

/*
* afFindEndPointDesc - Find the endpoint description entry from the
*                      endpoint number.
*/
extern endPointDesc_t *afFindEndPointDesc( byte endPoint );
作用:该函数可以返回与某个端点相关的端点描述符,示例如下:
endPointDesc_t * epDesc = afFindEndPointDesc( endPoint );

/*
* afFindSimpleDesc - Find the Simple Descriptor from the endpoint number.
*      If return value is not zero, the descriptor memory must be freed.
*/
extern byte afFindSimpleDesc( SimpleDescriptionFormat_t **ppDesc, byte EP );
作用:该函数可以获取与端点EP相关的简单描述符,保存到ppDesc中,示例如下
SimpleDescriptionFormat_t *sDesc = NULL;
byte free = false;
free = afFindSimpleDesc( &sDesc, endPoint );


/*
* afDataReqMTU - Get the Data Request MTU(Max Transport Unit)
*/
extern uint8 afDataReqMTU( afDataReqMTU_t* fields );
作用:该函数可以查询应用层可以发送的最大数据单元,示例如下:
if (len > afDataReqMTU( &mtu ) )
{
   //不发送数据
}
else
{
    //否则发送数据
    stat = APSDE_DataReq( &req );
}


/*
* afGetMatch - Get the action for the Match Descriptor Response
*             TRUE allow match descriptor response
*/
extern uint8 afGetMatch( uint8 ep );
作用:获取端点的行为是否允许Response,返回true则允许,否则不允许


/*
* afSetMatch - Set the action for the Match Descriptor Response
*             TRUE allow match descriptor response
*/
extern uint8 afSetMatch( uint8 ep, uint8 action );
作用:设定AF层端点的行为是否允许Response,action为true则允许,否则不允许
示例如下:
afSetMatch(sapi_epDesc.simpleDesc->EndPoint, FALSE);

/*
* afNumEndPoints - returns the number of endpoints defined.
*/
extern byte afNumEndPoints( void );
作用:获取AF层注册的端点的个数,示例如下:
uint8 cnt = afNumEndPoints() - 1; // -1 for ZDO endpoint descriptor


/*
* afCnvtSP_uint16 - Converts uint16 to semi-precision structure format.
*/
extern uint16 afCnvtSP_uint16( afSemiPrecision_t sp );
作用:微精度(afSemiPrecision_t)格式数据转换成普通16位数格式数据


/*
* afCnvtuint16_SP - Converts uint16 to semi-precision structure format.
*/
extern afSemiPrecision_t afCnvtuint16_SP( uint16 rawSP );
作用:把普通16位数格式的数据转换成微精度格式数据


/*
* afCnvtFloat_SP - Converts float to semi-precision
*                    structure format
* NOTE: This function will convert to the closest possible
*       representation in a 16 bit format. Meaning that
*       the number may not be exact. For example, 10.7 will
*       convert to 10.69531, because .7 is a repeating binary
*       number. The mantissa for afSemiPrecision_t is 10 bits
*       and .69531 is the 10 bit representative of .7.
*/
extern afSemiPrecision_t afCnvtFloat_SP( float f );
作用:把普通float格式数据转换成微精度格式数据


/*
* afCnvtSP_Float - Converts semi-precision structure format to float.
*/
extern float afCnvtSP_Float( afSemiPrecision_t sp );
作用:转换微精度格式数据为普通float格式数据


/*
* afCopyAddress
*
*/
extern void afCopyAddress (afAddrType_t *afAddr, zAddrType_t *zAddr);
作用:AF层地址拷贝,示例如下:
afCopyAddress( &MSGpkt->srcAddr, SrcAddress );

### 计算机网络考研面试的经验总结 #### 一、基础知识准备 在计算机网络的考研面试中,通常会考察学生对基础理论的理解程度以及实际应用能力。因此,在复习过程中应重点关注以下几个方面的知识点[^1]: - **OSI七模型与TCP/IP协议栈**:掌握各次的功能及其对应的主要协议。 - **IP地址分类及子网划分**:熟悉IPv4和IPv6的区别,理解如何进行有效的网络规划。 - **路由算法**:深入学习距离矢量法、链路状态法等基本概念,并能解释其优缺点。 - **传输控制机制**:包括流量控制、拥塞控制等内容。 ```python # 示例代码展示简单的Socket编程实现客户端和服务端通信过程 import socket def start_server(): server_socket = socket.socket(socket.AF_INET, socket.SOCK_STREAM) host = 'localhost' port = 9999 server_socket.bind((host, port)) server_socket.listen(5) while True: client_socket, addr = server_socket.accept() message = client_socket.recv(1024).decode('utf-8') print(f"Received from {addr}: {message}") response = "Hello Client" client_socket.send(response.encode('utf-8')) client_socket.close() if __name__ == "__main__": start_server() ``` 以上是一个非常基础的服务端程序例子,用于演示基于Python语言下的套接字(Socket)操作原理[^2]。 #### 二、常见问题应对策略 针对可能被问到的一些典型题目提前做好充分准备是非常必要的。例如可能会涉及到以下几类问题: - 描述一次完整的HTTP请求流程? - ARP欺骗是如何发生的?怎样防范此类攻击行为的发生呢? - VLAN的作用是什么?它又是通过哪些方式来隔离广播域? 对于这些问题的回答不仅要做到条理清晰而且还要体现出自己对该领域最新动态有一定关注度[^3]。 #### 三、软实力提升建议 除了专业知识外,良好的表达能力和逻辑思维同样重要。可以通过模拟演练的形式提高临场发挥水平;另外保持自信积极的态度也是成功的关键因素之一。 ---
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值