Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

added json support with the network export functionality. #228

Open
wants to merge 5 commits into
base: master
Choose a base branch
from

Conversation

duysqubix
Copy link

To generate a network overview, the XBeeNetwork.export only supports xml.

Simply, I needed json functionality and figured I would contribute to codebase while I am it.

This mimics the exact structure found in the generated XML, but in JSON. They map 1:1 very nicely.

@duysqubix
Copy link
Author

duysqubix commented Feb 16, 2021

Here is an example output from the latest commit:

{
  "xbee_network": {
    "description": "",
    "date": "2021-02-16 14:34:24.729143",
    "map_type": "dynamic",
    "protocol": "3",
    "devices": [
      {
        "addr": "0013A20041BD3346",
        "nwk_address": "FFFE",
        "node_id": " ",
        "role": "Router",
        "hw_version": "23",
        "fw_version": "8075",
        "serial_config": {
          "port": "/dev/ttyUSB0",
          "baud_rate": "9600",
          "data_bits": "8",
          "stop_bits": "1",
          "parity": "0",
          "flow_control": "0"
        },
        "connections": [
          {
            "addr": "0013A20041B625B5",
            "strength": "?",
            "status": "0"
          },
          {
            "addr": "0013A20041BD2A7A",
            "strength": "?",
            "status": "0"
          }
        ]
      },
      {
        "addr": "0013A20041B625B5",
        "nwk_address": "FFFE",
        "node_id": "MYNODE",
        "role": "Router",
        "hw_version": "???",
        "fw_version": "???",
        "connections": [
          {
            "addr": "0013A20041BD3346",
            "strength": "?",
            "status": "0"
          }
        ]
      },
      {
        "addr": "0013A20041BD2A7A",
        "nwk_address": "FFFE",
        "node_id": "SLAVE2",
        "role": "Router",
        "hw_version": "???",
        "fw_version": "???",
        "connections": [
          {
            "addr": "0013A20041BD3346",
            "strength": "?",
            "status": "0"
          }
        ]
      }
    ]
  }
}

XML Equivalent

<network name="%s_network">
	<description />
	<date>2/16/21 2:50:4 PM</date>
	<protocol>3</protocol>
	<map_type>dynamic</map_type>
	<devices>
		<device address="0013A20041BD3346">
			<nwk_address>FFFE</nwk_address>
			<node_id> </node_id>
			<role>Router</role>
			<hw_version>0x23</hw_version>
			<fw_version>8075</fw_version>
			<serial_config>
				<port>/dev/ttyUSB0</port>
				<baud_rate>9600</baud_rate>
				<data_bits>8</data_bits>
				<stop_bits>1</stop_bits>
				<parity>0</parity>
				<flow_control>0</flow_control>
			</serial_config>
			<connections>
				<connection address="0013A20041B625B5">
					<strength>?</strength>
					<status>0</status>
				</connection>
				<connection address="0013A20041BD2A7A">
					<strength>?</strength>
					<status>0</status>
				</connection>
			</connections>
		</device>
		<device address="0013A20041B625B5">
			<nwk_address>FFFE</nwk_address>
			<node_id>MYNODE</node_id>
			<role>Router</role>
			<hw_version />
			<fw_version />
			<connections>
				<connection address="0013A20041BD3346">
					<strength>?</strength>
					<status>0</status>
				</connection>
			</connections>
		</device>
		<device address="0013A20041BD2A7A">
			<nwk_address>FFFE</nwk_address>
			<node_id>SLAVE2</node_id>
			<role>Router</role>
			<hw_version />
			<fw_version />
			<connections>
				<connection address="0013A20041BD3346">
					<strength>?</strength>
					<status>0</status>
				</connection>
			</connections>
		</device>
	</devices>
</network>

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant