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
ParameterNecessityTypeInput typeIntroduction
serial_portYeschar *inputSerial setting etc, /dev/ttyUSB1
SerialAPI_CallbacksYesCallback functioninputSeen 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
ParameterNecessityTypeInput typeIntroduction
modeYesBYTEinputREMOVE_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
completedFuncYesFunctioninputRemove 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
ParameterNecessityTypeInput typeIntroduction
modeYesBYTEinputREMOVE_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
completedFuncYesFunctioninputRemove 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
ParameterNecessityTypeInput typeIntroduction
nodeIDYesBYTEinputDestination node ID (0xFF == broadcast)
pDataYesBYTE *inputData buffer pointer
dataLengthYesBYTEinputData buffer length
txOptionsYesBYTEinputTransmit option flags
completedFuncYesfunctioninputTransmit completed call back function
nodeIDYesBYTEinputDestination 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

DSGW-210-HA Home Assistant Gateway

The DSGW-210-HA Gateway enables the user to run Home Assistant and experience the best home automation in the world via the easiest way, which is

DSOM-020 PX30 System on Module (SoM)

DSOM-020 PX30 System on Module/Core Board adopts the PX30 processor, which is a ARM Cortex A-53, quad core. It can be paired with multiple types

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.