Manages the detection of network presence events which occur when nominated devices join/leave the network
For more information on how to use this plugin, see Network Presence Detection
This plugin is a "singleton" - there may be only one single instance of it in the app. It may be instantiated as any name the user chooses.
H4P_GateKeeper youcantcomeinwithoutabelton();
N/A
stop
/ start
have no effect
N/A
H4P_GateKeeper
itself has no API, it merely manages and co-ordinates objects know as "Roamers" which represent various different device types whose joining / leaving can be detected.
Individual Roamers have different conctructors, but they all have a common API function:
string getIP(); // returns empty string if not in network
Type of device | Identifying features | Example | H4Plugins "Roamer" type |
---|---|---|---|
MDNS (.local) device | protocol / service attributes | tcp,http | h4pRoamingDotLocal |
H4 device | device name | bedroom | h4pRoamingH4 |
any | IP address | 192.168.1.42 | h4pRoamingIP |
UPNP device | UPNP Tag, value | USN,uuid:Socket-1_0-upnpF9198B | h4pRoamingUPNP |
/* Constructor
name = unique name to identify device to user
service = MDNS service type e.g. tcp or udp etc
protocol = MDNS protocol e.g. hrttp
*/
h4pRoamingDotLocal(const string& name,const string& service,const string& protocol);
/* Constructors
name = unique name to identify device to user
*/
h4pRoamingH4(const string& name);
/* Constructors
name = unique name to identify device to user
ip = the IP address that device will be recongised by
*/
h4pRoamingIP(const string& name,const string& ip);
h4pRoamingIP(const string& name,const IPAddress& ip);
Two additional examples show how to link joining / leaving automatically to a default Switch / Thing object (see "Things" and "Switches")
While the joining example and the leaving example are coded for h4pRoamingIP
, the code applies equally to any of the Roamers.
/* Constructor
name = unique name to identify device to user
tag = UPNP/SSDP message tag, e.g. USN, MX, LOCATION etc
id = value of the tag considered to be a "match" NB take care, many duplicates my occur with poor choices of tag/id!
*/
h4pRoamingUPNP(const string& name,const string& tag,const string& id);
(c) 2021 Phil Bowles [email protected]