pear2/Net_RouterOS

Call "all" option on Hotspot Server submenu to use in Users submenu

VelaJafet opened this issue · 3 comments

I'm development a little system to interacte with Hotspot menu, i want to save the Hotspot Servers to use them when I create Users.

This is what I see in Winbox
WhatsApp Image 2021-04-27 at 4 51 43 PM

These are the options to assignanment when I create a User by Winbox (my manually server created and the "all" option)
imagen

I'm using Util and this is the code that I'm using to print the Hotspot Servers
imagen

This is what I receive with the code shown above
imagen

This is what other system returns me (include the "all" option)
imagen

How can I save the "all" option to use it? That's my question

When adding the user, leave the "server" option empty (or set to NULL). The default is "all", so that's what will be used. I'm not sure what would happen if you had a hotspot server called "all", or if that's even allowed (and I don't have a RouterOS install to try this on right now...), but in case it is allowed, you'll want to handle this edge case somehow.

Similarly with the default value for the "address-pool" in "/ip hotspot". If you don't want to include a value for it, leave it empty, and it will default to not having an "address-pool" (seen as "none" in Winbox). If the name of your IP pool is "all", you can just specify the "all" name. Again, I don't know if you can create an IP pool with the name "none", but this is an edge case you may want to address somehow.

How exactly to address both of these edge cases? One sure way is to go through the referenced menu's "find" command to get the ID of the item with the given name. Even if it's named with a keyword, you'll get an ID if it exists, or an empty string if not. Pass the ID if it exists, or error if not. Use NULL when your form's input is empty.

Thank you, you are right, to get the option as "NONE", "ALL", etc; I have to set in NULL