Community discussions

MikroTik App
 
User avatar
omega-00
Forum Guru
Forum Guru
Topic Author
Posts: 1167
Joined: Sat Jun 06, 2009 4:54 am
Location: Australia
Contact:

Determining Band and channel width options for wireless cards

Thu Jul 07, 2016 6:23 am

Hi Guys,

I'm in the process of updating a few scripts to automatically set wireless card configuration but am getting stuck on band and channel width selection.
In winbox there is a dropdown list which tells you the available bands for the card you're using and in terminal you can get a printout by using:
/interface wireless info hw-info wlan1
however I can't find any way to commit/parse this info to a variable so I can work with it (and use it to determine what the highest band available is).

By comparison if I'm using something like monitor-traffic and I want to grab certain values I can do so like this:
/interface monitor-traffic [find name=$iface] once do={
 :set rxThisBits ($"rx-bits-per-second")
 :set txThisBits ($"tx-bits-per-second")
 } 
But there's no similar options available for the hw-info.

Anyone else run into this and if so how did you work around it? My current solution (as I want to use the highest options available) is to run through like so:
:foreach i in=[/interface wireless find] do={
:if ([/interface wireless get $i band] ~"2ghz") do={
:do {:global wififrequency2ghz; /interface wireless set $i frequency=$"wififrequency2ghz"} on-error={:log error "Failed to Set initial wireless frequency"}
:do {/interface wireless set $i band=2ghz-b/g/n } on-error={:log warning "wireless frequency and band limit reached"}
}

:if ([/interface wireless get $i band] ~"5ghz") do={
:do {:global wififrequency5ghz; /interface wireless set $i frequency=$"wififrequency5ghz" } on-error={:log error "Failed to Set initial wireless frequency"}
:do {/interface wireless set $i band=5ghz-a } on-error={:log warning "wireless band limit reached"}
:do {/interface wireless set $i band=5ghz-a/n } on-error={:log warning "wireless band limit reached"}
:do {/interface wireless set $i band=5ghz-a/n/ac } on-error={:log warning "wireless band limit reached"}
:do {/interface wireless set $i channel-width=20/40mhz-Ce } on-error={:log warning "wireless channel-width limit reached"}
:do {/interface wireless set $i channel-width=20/40/80mhz-Ceee } on-error={:log warning "wireless channel-width limit reached"}
}
}

Who is online

Users browsing this forum: No registered users and 23 guests