Application Simple demo application for testing NETIO 4 power switch using Json.
Author © 2021 Johannes Grunedal ([email protected])
Environment Built, run and tested with Visual Studio 2019 Target framework: .Net 5 Platform: x64
NOTE! This application is tested with NETIO 4, minor changes may be needed to be run on other devices. To keep demo simple and short, data validation and error handling is reduced to a minimum.
Getting started
- Enable read/write in web config M2M API Protocols -> JSON API -> Enable JSON API -> Enable READ-WRITE
- Enter username and password (default is netio).
- Click Save Changes.
- Note current NETIO IP address.
- Build and run this application.
- Enter IP address, user and password.
- Click Connect button.
- If successful, Info field is populated with current NETIO data (if not, check above settings).
- Set selected outputs to ON/OFF using the Control buttons.
- Click Status button to read current NETIO putput status.
Run standalone
- Create a new C#/WPF project.
- Add NetIoDriver.cs to your project.
- Include it: using NetIo;
- Depending on your settings, one or more namespaces may have to be included (see using's below).
- Init driver: netIoDriver = new NetIoDriver("192.168.11.250", netio, netio);
- Test connection:
var agent = netIoDriver.GetAgent();
if ("Error" != agent.Model)
var model = agent.Model; // reads out all agent info - Set output, e.g. set output 2 to on: bool isOk = netIoDriver.SetState(NetIoDriver.Output.Output_2, NetIoDriver.Action.On);
- Read output, e.g. read output 1: var output1 = netIoDriver.GetOutputState(NetIoDriver.Output.Output_1);
- Enjoy!