// Set the MAC PIB extended address according to results from above.
(void)ZMacSetReq(MAC_EXTENDED_ADDRESS, aExtendedAddress);
}
#if defined ZCL_KEY_ESTABLISH
/**************************************************************************************************
@fn zmain_cert_init
@brief Initialize the Certicom certificate information.
input parameters
None.
output parameters
None.
@return None.
*/
static void zmain_cert_init(void)
{
uint8 certData[ZCL_KE_IMPLICIT_CERTIFICATE_LEN];
uint8 nullData[ZCL_KE_IMPLICIT_CERTIFICATE_LEN] = {
0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF
};
(void)osal_nv_item_init(ZCD_NV_IMPLICIT_CERTIFICATE, ZCL_KE_IMPLICIT_CERTIFICATE_LEN, NULL);
(void)osal_nv_item_init(ZCD_NV_DEVICE_PRIVATE_KEY, ZCL_KE_DEVICE_PRIVATE_KEY_LEN, NULL);
// First check whether non-null certificate data exists in the OSAL NV. To save on code space,
// just use the ZCD_NV_CA_PUBLIC_KEY as the bellwether for all three.
if ((SUCCESS != osal_nv_item_init(ZCD_NV_CA_PUBLIC_KEY, ZCL_KE_CA_PUBLIC_KEY_LEN, NULL)) ||
(SUCCESS != osal_nv_read(ZCD_NV_CA_PUBLIC_KEY, 0, ZCL_KE_CA_PUBLIC_KEY_LEN, certData)) ||
(osal_memcmp(certData, nullData, ZCL_KE_CA_PUBLIC_KEY_LEN)))
{
// Attempt to read the certificate data from its corresponding location on the lock bits page.
HalFlashRead(HAL_FLASH_IEEE_PAGE, HAL_FLASH_CA_PUBLIC_KEY_OSET, certData,
ZCL_KE_CA_PUBLIC_KEY_LEN);
// If the certificate data is not NULL, use it to update the corresponding NV items.
if (!osal_memcmp(certData, nullData, ZCL_KE_CA_PUBLIC_KEY_LEN))
{
(void)osal_nv_write(ZCD_NV_CA_PUBLIC_KEY, 0, ZCL_KE_CA_PUBLIC_KEY_LEN, certData);
HalFlashRead(HAL_FLASH_IEEE_PAGE, HAL_FLASH_IMPLICIT_CERT_OSET, certData,
ZCL_KE_IMPLICIT_CERTIFICATE_LEN);
(void)osal_nv_write(ZCD_NV_IMPLICIT_CERTIFICATE, 0,
ZCL_KE_IMPLICIT_CERTIFICATE_LEN, certData);
HalFlashRead(HAL_FLASH_IEEE_PAGE, HAL_FLASH_DEV_PRIVATE_KEY_OSET, certData,
ZCL_KE_DEVICE_PRIVATE_KEY_LEN);
(void)osal_nv_write(ZCD_NV_DEVICE_PRIVATE_KEY, 0, ZCL_KE_DEVICE_PRIVATE_KEY_LEN, certData);
}
}
}
#endif
/**************************************************************************************************
@fn zmain_dev_info
@brief This displays the IEEE (MSB to LSB) on the LCD.
input parameters
None.
output parameters
None.
@return None.
*/
static void zmain_dev_info(void)
{
#ifdef LCD_SUPPORTED
uint8 i;
uint8 xad;
uint8 lcd_buf[Z_EXTADDR_LEN2+1];
// Display the extended address.
xad = aExtendedAddress + Z_EXTADDR_LEN - 1;
for (i = 0; i < Z_EXTADDR_LEN*2; xad–)
{
uint8 ch;
ch = (*xad >> 4) & 0x0F;
lcd_buf[i++] = ch + (( ch < 10 ) ? ‘0’ : ‘7’);
ch = xad & 0x0F;
lcd_buf[i++] = ch + (( ch < 10 ) ? ‘0’ : ‘7’);
}
lcd_buf[Z_EXTADDR_LEN2] = ‘\0’;
//DrawRectFill(0 ,0 ,128,128,GREEN);//背景色
DrawRectFill(3 ,20 ,122,106,WHITE); //显示窗口
Color = BLACK; //前景色
Color_BK = GREEN; //背景色
LCD_write_EN_string(64-7*osal_strlen((char *)AppTitle)/2,3,AppTitle); //显示标题
Color = BLACK; //前景色
Color_BK = WHITE; //背景色
HalLcdWriteString( "IEEE: ", HAL_LCD_LINE_3 );
Color = BLUE;
HalLcdWriteString( (char*)lcd_buf, HAL_LCD_LINE_4 );
Color = RED;
LCD_write_CN_string(9, 95, “西安工程大学”);
Color = BLACK;
LCD_write_CN_string(9, 110, “厚德弘毅”);
Color = MAGENTA;
LCD_write_CN_string(63,110, “博学笃行”);
#endif
|