IOBOX API USAGE GUIDE
This document provides an overview and usage instructions for the APIs available in iobox_api.h.
1. Api name and features
-
Scan
std::vector<std::string> scanNetworkDevicesMulticast(int timeout);API need to be passed a timeout in second unit. The API will return a list of IPs as a vector string.
-
Connect
bool connectToIobox(const std::string& ip, int port, const std::string& username, const std::string& password);Connect to a specific IP device from list of IPs above. Default port is 502 Username and password are param to anthenticate device
-
Disconnect
bool disconnectToIobox(const std::string& ip);Disconnect to a specific IP device that is connected before
-
Get value of channel
std::string getValueDataStringIoboxFromChannelName(const std::string& ip, const std::string& channelName);Get value of specific channel name from a IP device that is connected before. List of channel name is obtained from
getDeviceChannelNamesapi -
Set value of channel
bool setValueDataStringIoboxFromChannelName(const std::string& ip, const std::string& channelName, const std::string& value);Set a value of specific channel name from a IP device that is connected before. List of channel name is included in
channel_namearray. -
Other api
bool setAuthenticationIobox(const std::string& ip, const std::string& username, const std::string& password);This api to change username and password, this can be only called after a connection to devicebool resetAuthenticationIobox(const std::string& ip, const std::string& token);This api to reset username and password to defaultbool resetIobox(const std::string& ip, const std::string& token);This api to restart devicetokenis generated default by usinggenerateTokenapi
2. How to using example test in main.cpp
You need build this project before run by using g++ compiler
g++ .\*.cpp .\*.c -lws2_32 -o main.exe
Then you need only running main.exe.
Start application, it will show
Enter command followed by Enter: exit, scan, setip, connect, channels, disconnect, show, get, set, restart, setauthen, resetauthen
- You type
scan, it will scan all device iobox on local network then it will list them on terminal attach their IP address if they is found. - You type
channelsto get name of all of channels that device supports - Then type
setipto setup IP of iobox you need to connect Then you will be required to input of specific IP address and you need type IP you want. - Next you type
connectto connect to this IP device - Then you can use
getorsetcommand to continue get or set value to any channel. - You can use
setauthenandresetauthento change usename/password to connect device, and reset usename/password to default (now default in device is: admin/1234) - You can use
restartto restart devcie