Skip to content

seb-fae/zigbee-host-code-snippet

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

14 Commits
 
 

Repository files navigation

zigbee-host-examples

Send Custom command to NCP:

1) Add this code to Z3Host_callback.c

#define MAXRSPLEN 16

uint8_t cmd[1] = {1};
uint8_t rsp[MAXRSPLEN];
uint8_t rsplen = MAXRSPLEN;

static void sendCustom(void)
{
	EmberStatus status;
	status = ezspCustomFrame(sizeof(cmd), cmd, &rsplen, rsp);

	emberAfCorePrintln("rsp len %d", rsplen);
	for (uint8_t i = 0; i< rsplen; i++)
	  emberAfCorePrintln("%x", rsp[i]);
}

2) Add xncp library plugin to your NCP project

3) Enable emberAfPluginXncpIncomingCustomFrameCallback on NCP and implement it

EmberStatus emberAfPluginXncpIncomingCustomFrameCallback(uint8_t messageLength,
                                                         uint8_t *messagePayload,
                                                         uint8_t *replyPayloadLength,
                                                         uint8_t *replyPayload)
{
  *replyPayloadLength = 4;
  replyPayload[0] = 1;
  replyPayload[1] = 2;
  replyPayload[2] = 3;
  replyPayload[3] = 4;

  return EMBER_SUCCESS;
}

Set Manufacturing Ctune in User/Lockbit page from Host

static void setMfgCtune(void)
{
	uint16_t ctune = 32;
	EmberStatus status = ezspSetMfgToken(EZSP_MFG_CTUNE, 2, (uint8_t *) &ctune);
	emberAfCorePrintln("status 0x%x\n", status);
}

warning: To perform consecutive writes, you need to use "commander device pageerase --region @userdata" before each write

Set a Ctune in NCP CMU register from Host

static void setCtune(void)
{
	uint16_t ctune = 32;
	EmberStatus status = ezspSetConfigurationValue(EZSP_CONFIG_CTUNE_VALUE, ctune);
	emberAfCorePrintln("status 0x%x\n", status);
}

warning: you must not be on a network to use this command.

Read CTune from Host:

static void getCtune(void)
{
	uint16_t ctune;
	ezspGetConfigurationValue(EZSP_CONFIG_CTUNE_VALUE, &ctune);
	emberAfCorePrintln("ctune 0x%x\n", ctune);

	uint16_t mfgctune;
	uint8_t res = ezspGetMfgToken(EZSP_MFG_CTUNE, (uint8_t *) &mfgctune);
	emberAfCorePrintln("ctuneMfg 0x%x\n", mfgctune);
}

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published