Dusun Gateway Z-wave API

This document lists the API used for Zwave development. The SDK related to it can be download from DUSUN website. For detailed information, please refer to the example in the SDK sample code.
Table of Contents

Summary

This document lists the API used for Zwave development. The SDK related to it can be download from DUSUN website. For detailed information, please refer to the example in the SDK sample code.

1. SDK init function

SDK init function
Function declaration

				
					BOOL SerialAPI_Init(const char* serial_port, const struct SerialAPI_Callbacks* _callbacks )
				
			
Parameter
Parameter Necessity Type Input type Introduction
serial_port Yes char * input Serial setting etc, /dev/ttyUSB1
SerialAPI_Callbacks Yes Callback function input Seen in example
Sample
				
					const struct SerialAPI_Callbacks serial_api_callbacks = {
        ApplicationCommandHandler,
        ApplicationNodeInformation,
        ApplicationControllerUpdate,
        0,
        0,
        0,
        0,
};

if (!SerialAPI_Init("/dev/ttyUSB1", &serial_api_callbacks))
{
    fprintf(stderr, "SerialAPI not initilized\n");
    return 1;
}
				
			

2. ZW_Version

SDK version query
Function Declaration

				
					
BYTE ZW_Version(BYTE *pBuf)
				
			
Parameter
None
Sample
				
					char buf[64];
ZW_Version(buf);
printf("Vesion: %s \n", buf );
				
			

3. ZW_SoftRest

SDK software reset
Function Declaration
				
					BYTE ZW_SoftReset()
				
			
Parameter
None
Sample
				
					ZW_SoftReset();
				
			

4. SerialAPI_Poll

SDK event poll
Function Declaration
				
					uint8_t SerialAPI_Poll(void)
				
			
Parameter
None
Sample
				
					SerialAPI_Poll();
				
			

Notice: While calling the Poll function, the Z-wave event would return by the registration function in the SerialAPI_Init function.

5. SerialAPI_GetFd

SDK io reuse to get the fd
Function Declaration
				
					int fd = SerialAPI_GetFd();
				
			
Parameter
None
Sample
				
					SerialAPI_Poll();
				
			

6. ZW_AddNodeToNetwork

Add devices to the the network
Function Declaration

				
					void ZW_AddNodeToNetwork(BYTE bMode,VOID_CALLBACKFUNC(completedFunc) (auto LEARN_INFO*))
				
			
Parameter
Parameter Necessity Type Input type Introduction
mode Yes BYTE input REMOVE_NODE_ANY - Remove any node from the network
REMOVE_NODE_CONTROLLER - Remove a controller from the network
REMOVE_NODE_SLAVE - Remove a slaev node from the network
REMOVE_NODE_STOP - Stop learn mode without reporting an error
completedFunc Yes Function input Remove Node Step Callback

Sample

				
					ZW_AddNodeToNetwork(ADD_NODE_ANY|ADD_NODE_OPTION_NETWORK_WIDE,AddNodeStatusUpdate);
				
			

7. ZW_RemoveNodeFromNetwork

Delete devices from the network
Function Declaration

				
					void ZW_RemoveNodeFromNetwork(BYTE bMode, VOID_CALLBACKFUNC(completedFunc)(auto LEARN_INFO*))
				
			
Parameter
Parameter Necessity Type Input type Introduction
mode Yes BYTE input REMOVE_NODE_ANY - Remove any node from the network
REMOVE_NODE_CONTROLLER - Remove a controller from the network
REMOVE_NODE_SLAVE - Remove a slaev node from the network
REMOVE_NODE_STOP - Stop learn mode without reporting an error
completedFunc Yes Function input Remove Node Step Callback

Sample

				
					
ZW_RemoveNodeFromNetwork(REMOVE_NODE_ANY,RemoveNodeStatusUpdate);;
				
			

8. ZW_SendData

Send data to the device
Function Declaration

				
					BYTE ZW_SendData( BYTE nodeID, BYTE *pData, BYTE dataLength, BYTE txOptions, VOID_CALLBACKFUNC(completedFunc)(BYTE, TX_STATUS_TYPE*))
				
			
Parameter
Parameter Necessity Type Input type Introduction
nodeID Yes BYTE input Destination node ID (0xFF == broadcast)
pData Yes BYTE * input Data buffer pointer
dataLength Yes BYTE input Data buffer length
txOptions Yes BYTE input Transmit option flags
completedFunc Yes function input Transmit completed call back function
nodeID Yes BYTE input Destination node ID (0xFF == broadcast)

Sample

				
					int zwave_class_cmd(unsigned char nid, unsigned char class, unsigned char cmd, char *data, int len, void (*completed)(BYTE x, TX_STATUS_TYPE *status))
{
    char buf[256] = {0};
    buf[0] = class & 0xff;
    buf[1] = cmd & 0xff;
    if (len > 0)
    {
        memcpy(buf + 2, data, len);
    }
    unsigned char options = 0x25;
    void (*f)(BYTE, TX_STATUS_TYPE *) = NULL;
    if (completed == NULL)
    {
        f = zwave_class_cmd_completed;
    }
    else
    {
        f = completed;
    }
    if (ZW_SendData((BYTE)nid, (BYTE *)buf, 2 + len, options, f) == FALSE)
    {
        {
            printf("full tx queue!\n");
            return -1;
        }
        return 0;
    }
				
			
Related IoT Product Specifications

Wi-Fi Repeater Product Specification

It’s a 300Mbps / 1200Mbps Wi-Fi range extender. It can boost your existing Wi-Fi coverage to deliver fast and reliable wired and wireless connectivity.

DSGW-201-tuya Ceiling Router Gateway

DSGW-201-tuya is an application gateway developed on the basis of programmable gateway DSGW-201, which integrates router, CPE, gateway function.

Looking For An IoT Device Supplier For Your Projects?

CONTACT US

    This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.

    IoT Gateways for Recommendation

    Apply For Our Document

      This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.

      CONTACT US

        This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.

        Welcome to DusunIoT

        Hi there 👋 Is there anything we can help you with today? Please fill in the form below for the team to follow up if you become disconnected.

          DusunIoT Distributor Program

            This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.

              This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.