cele303
December 16, 2019, 12:28pm
1
Hello everyone,
I’m trying to implement script which will check presence of connected client based on his MAC address and then execute IFTTT webhook.
My programming knowledge is really limited (but I’m trying ).
I’m trying to use this script(found here at Mikrotik forums):
:global MACCurrentStatus;
:local Mac;
:local PrevStatus;
:foreach Mac,PrevStatus in=$MACCurrentStatus do={
# check if Mac present in Capsman table
:local Present 0;
:if ([:len [/caps-man registration-table find where mac-address=$Mac]] !=0) do={
:set Present 1;
}
# see if Presence has changed and post it
:if ($PrevStatus != $Present) do={
:if ($PrevStatus >= 0) do={
/log info "Presence of $Mac changed to $Present";
}
:do {
:local Url "https://maker.ifttt.com/trigger/wifi_present/with/key/";
/tool fetch mode=https url=$Url http-method=post http-data="x" keep-result=no ;
} on-error={ /log warning "SetPresence failed" }
:set ($MACCurrentStatus->$Mac) $Present;
}
}
but I’m lost at the part where should I input MAC address of client I want to be tracked?
If anybody can help please.
Thanks
Damir
pe1chl
December 16, 2019, 12:32pm
2
That script (I think I recognize something I posted before) is tracking a specific list of MAC addresses, which is stored in the array MACCurrentStatus.
(the MAC is used as the key, the corresponding value is the current present/not present state of that MAC address)
The array has to be initialized once with the proper MAC addresses you want to track. This can be done in another script.
cele303
December 16, 2019, 1:00pm
3
That script (I think I recognize something I posted before) is tracking a specific list of MAC addresses, which is stored in the array MACCurrentStatus.
(the MAC is used as the key, the corresponding value is the current present/not present state of that MAC address)
The array has to be initialized once with the proper MAC addresses you want to track. This can be done in another script.
Woow, that was quick!
Yes, that’s your script I’ve modified to fetch MAC address from Capsman registration table.
Since I’m not good at coding, can you please give me some example for that other script. If it isn’t to complicated
Thank you!
pe1chl
December 16, 2019, 3:22pm
4
It would be like:
:global MACCurrentStatus;
:set ($MACCurrentStatus->"11:22:33:44:55:66") -1;
cele303
December 16, 2019, 4:14pm
5
Thanks for the example, unfortunately it does not insert values
Pls see screenshots:
https://imgur.com/a/5do8dUe
pe1chl
December 16, 2019, 4:46pm
6
I always have problems like that, and I don’t have a good advice for you except hope that an experience script programmer has a solution for you.
(in my example I used a statement to first create MACCurrentStatus as an empty array, maybe it helps you)