#author("2019-10-29T15:12:55+08:00","default:Admin","Admin") #author("2022-11-16T14:11:52+08:00","default:Admin","Admin") [[ZigBee]] &color(red){※This article is based on ZigBee Stack 2.51.a}; CC2530有8KRAM,协议栈就用了5K,用户程序只有3K字节 应用的非易失性存储器(Application Non-Volatile Memory) 在z-stack中,每一个参数的配置对应的是一个Nv条目(item),每一个item都有自己的ID,z-stack中使用的条目ID范围如下: #codeprettify{{ 0x0000 Reserved 0x0001 – 0x0020 操作系统抽象层(OSAL) 0x0021 – 0x0040 网络层(NWK) 0x0041 – 0x0060 应用程序支持子层(APS) 0x0061 – 0x0080 安全(Security) 0x0081 – 0x00B0 Zigbee设备对象(ZDO) 0x00B1 – 0x00E0 Commissioning SAS (调试用的) 0x00E1 – 0x0100 Reserved 0x0101 – 0x01FF Trust Center Link Keys (秘钥) 0x0201 – 0x0300 ZigBee-Pro: APS Links Keys ZigBee-RF4CE: network layer 0x0301 – 0x0400 ZigBee-Pro: Master Keys ZigBee-RF4CE: app framework 0x0401 – 0x0FFF Application (应用层,用来给我们自己使用) 0x1000 -0xFFFF Reserved }} 如果是我们自己的应用程序中需要使用Nv,则定义其ID在0×0201~0x0FFF 范围内! 从CC2530的<OSAL API.pdf>中可以看到自定义的NV 编号范围是 0x0401 – 0x0FFF。 - SUCCESS 表示成功,并且该ID已经存在 - NV_ITEM_UNINIT 表示成功,但ID之前不存在,即第一次初始化。 - NV_OPER_FAILED 初始化失败 ZStack(CC2530) 断电存储(NV)方法 https://blog.csdn.net/huangmeimao/article/details/73649301 https://blog.csdn.net/songisgood/article/details/78006538 * API [#o3faf2d1] ** 初始化nv数据项 osal_nv_item_init() [#nd976c70] uint8 osal_nv_item_init( uint16 id, uint16 len, void *buf ) --id: NV项的ID --len: 项的长度 -- buf: 初始化项的数据,如果没有设置为NULL ** 读取nv数据项 osal_nv_read() [#c6f4306f] uint8 osal_nv_read( uint16 id, uint16 ndx, uint16 len, void *buf ) -- id: NV项的ID -- ndx: 项中的索引 -- len: 项的长度 -- buf: 项的数据 ** 写入nv数据项 osal_nv_write() [#d04b5111] uint8 osal_nv_write( uint16 id, uint16 ndx, uint16 len, void *buf ) -- id: NV项的ID -- ndx: 项中的索引 -- len: 项的长度 -- buf: 项的数据 #hr(); コメント: #comment_kcaptcha