How to detect radio series in python

From Digi Developer

Jump to: navigation, search

How to detect the radio series in your Gateway product.

This sample is designed to be used in code that may have to run on multiple radio platforms (802.15.4, ZNet 2.5, ZB, etc.) that will make conditional statements based on the type of radio module present in the Gateway.

Code:

import zigbee
import struct
 
try:
  hw_version = zigbee.ddo_get_param(None, "HV")
  hw_version = struct.unpack("=H", hw_version)[0]
except Exception, e:
  print "Failed to retrieve hardware version from local radio"
 
if hw_version != None:
  if hw_version > 6400: #If the hardware version is greater then 6400, it must be a series 2 radio
    print "Detected Series 2 radio in gateway"
  else:
    print "Detected Series 1 radio in gateway"

The key to this example is retrieving the Hardware version via the AT command 'HV' which is a unsigned 16 bit integer, and performing a comparison operator to decimal 6400.

Series 2 radio modules' hardware version are greater than 6400 for both PRO and regular versions.

Series 1 radio modules' hardware version are 6400 and less for both PRO and regular versions.

Note that the struct.unpack(...) call returns a tuple object, regardless of how many elements it unpacks from the input.

Availability:

This example requires the User to have a Gateway product with a mesh radio of some kind installed. On the gateway they must have the two libraries uploaded: zigbee and struct.

Personal tools
Wiki Editing