« Back to Product

Documentation

SetForwardDataFilter

Require: IP-Symcon >= 4.1

 void SetForwardDataFilter (string $RequiredRegexRule) 

Parameters

RequiredRegexRule

RegexRule which should be used as a filter

Returns

No Return

Description

Sets the filter using the RequiredRegexRule regular expression. ForwardData() is only called if the set filter is matching.

Warning

The page www.regex101.com can be used to test the RegEx-expression.

Warning

In certain special cases PHP json_encode() may change from upper to lower case. For example, the special character encoded JSON_string ""\u001D"" becomes ""\u001d"" after a json_decode.

Example

//Add filter for ForwardData
public function ApplyChanges() {
	[...]
	//Apply filters
	$this->SetForwardDataFilter(".*Hello.*");
}

//Only called if “Hello” is found in the $JSONString
public function ForwardData($JSONString) {
	$data = json_decode($JSONString);
	//Your code here
	[...]
	$this->SendDataToParent(json_encode(Array("DataID" => "{12345678-ABCD-EFAB-123456789123}", "Buffer" => $data->Buffer)));
	return "String data for the device instance!";
}
Any questions?