MEAM.Design - M4 - mZigbee



Overview

The mZigbee uses Anaren A2530E24A modules which has its own dedicated wiki for all the information about the modules and examples. On the peripheral board the SPI transactions are done over I2C.



Functions

Provided you've included mZigbee.h, you will have access to the following custom functions, as described below:

Important Functions for Basic Functionality

uint8_t = zInit(uint8_t slaveAddress, const struct moduleConfiguration* mc);

slaveAddress Default address : 0x5E Applying solder to the pads on the bottom of the board will change the address, the three bridges correspond to following bit positions of address "0101xxx0"
struct moduleConfiguration
{
uint8_t deviceType;
uint32_t channelMask;
uint16_t panId;
uint16_t endDevicePollRate;
uint8_t startupOptions;
uint8_t securityMode;
uint8_t* securityKey;
};
deviceType can be COORDINATOR or ROUTER or END_DEVICE
channelMask can be a value like CHANNEL_MASK_xx where xx can be from 11 to 23. For multiple channels you can OR them and pass it as an argument. You can also use DEFAULT_CHANNEL_MASK to use default channels.
panId can be the panId that you want to assign. Default you should use ANY_PAN which will allow all PanID's.
endDevicePollRate is only used if the deviceType is END_DEVICE, default value should be DEFAULT_POLL_RATE_MS
startupOptions use default value as DEFAULT_STARTUP_OPTIONS
securityMode can be SECURITY_MODE_OFF or SECURITY_MODE_PRECONFIGURED_KEYS or SECURITY_MODE_COORD_DIST_KEYS
securityKey is a pointer to the 16 byte security key when securityMode is set to SECURITY_MODE_PRECONFIGURED_KEYS
There are default module configurations already declared in the library for
Co-ordinator: DEFAULT_MODULE_CONFIGURATION_COORDINATOR
Router: DEFAULT_MODULE_CONFIGURATION_ROUTER
End device: DEFAULT_MODULE_CONFIGURATION_END_DEVICE
So you can use in the code as follows:
struct moduleConfiguration defaultConfiguration = DEFAULT_MODULE_CONFIGURATION_COORDINATOR;

uint8_t = zReset(void);

uint8_t = zShortAddr(uint8_t* ieeeAddress, uint8_t requestType, uint8_t startIndex);

uint8_t = zTx(uint16_t destinationShortAddress, uint8_t* data, uint8_t dataLength);

destinationShortAddress is the short address of the Co-ordinator (0x00), Router or EndDevice you want to send data, use zShortAdd(...) function to convert the MAC address to ShortAddress
data is the pointer to the payload
dataLength is the length of the payload



Advanced Internal Functions

uint8_t zRegApp(void);

uint8_t zStartApp(void);

uint8_t zMacAdd(uint16_t shortAddress, uint8_t requestType, uint8_t startIndex);

uint8_t zAckMode(uint8_t ackMode);

uint8_t zbWriteConfiguration(uint8_t zcd, uint8_t zcdLength, uint8_t* data);

uint8_t zDeviceType(uint8_t deviceType);

uint8_t zPanID(uint16_t panId);

uint8_t zChannelMask(uint32_t channelMask);

uint8_t zChannel(uint8_t channel);

uint8_t zCallbacks(uint8_t cb);

uint8_t zStartupOptions(uint8_t option);

uint8_t zSecurityMode(uint8_t securityMode);

uint8_t zSecurityKey(uint8_t* key);

uint8_t zPollRate(uint16_t pollRate);

uint8_t zReadConfigParam(uint8_t configId);

uint8_t zReadDeviceInfo(uint8_t dip);

uint8_t zRandom(void);

uint8_t zNVSize(uint8_t nvItem);

uint8_t zNVRead(uint8_t nvItem);

uint8_t zNVWrite(uint8_t nvItem, uint8_t* data);

uint8_t zLed(uint8_t operation, uint8_t value);

uint8_t zWaitForMsg(uint16_t messageType, uint8_t timeoutSecs);

uint8_t zNewMsg(void);

uint8_t zGetMessage(void);

uint8_t zSendMessage(void);

void zPink(uint8_t val);

uint8_t zVersion(void);

uint8_t zWaitDevState(uint8_t deviceType, uint16_t timeoutMs);

void zResetPrintf(void);

void zVersionPrintf(void);

uint8_t zNwkConfigPrintf(void);

uint8_t zDevInfoPrintf(void);

void zHexPrintf(uint8_t* toPrint, uint16_t numBytes);

Error (The ones I faced)

The zInit would not work cause there needs to be a delay after every I2C call. I added mWait(2000); after every mBusWrite(zAddr,zGPIOwr,zGPIOstate) in mZigbee.c; and it worked. eg:-

void zPinkoff(void) {

    zGPIOstate|=pinkPin;
    mBusWrite(zAddr,zGPIOwr,zGPIOstate);
	mWait(2000);

}

and so on for every such function.