Can AppleScript or any other script measure a Macbook's wifi signal strength?

The name of the pictureThe name of the pictureThe name of the pictureClash Royale CLAN TAG#URR8PPP











up vote
3
down vote

favorite












At my home I have two separate routers due to poor signals when being in one location opposed to another.



When I work on my Macbook from different locations I find it annoying when I have to switch between routers. The eventual goal is to run a more complex script under launchd to identify if a better networks is present and automate the change over.



I've tried experimenting with networksetup -listnetworkserviceorder and networksetup -listallhardwareports but have had no luck.



In AppleScript or any other scripting language a way to measure two router's strength similar to what's visible on the menu bar's wifi signal?










share|improve this question



























    up vote
    3
    down vote

    favorite












    At my home I have two separate routers due to poor signals when being in one location opposed to another.



    When I work on my Macbook from different locations I find it annoying when I have to switch between routers. The eventual goal is to run a more complex script under launchd to identify if a better networks is present and automate the change over.



    I've tried experimenting with networksetup -listnetworkserviceorder and networksetup -listallhardwareports but have had no luck.



    In AppleScript or any other scripting language a way to measure two router's strength similar to what's visible on the menu bar's wifi signal?










    share|improve this question

























      up vote
      3
      down vote

      favorite









      up vote
      3
      down vote

      favorite











      At my home I have two separate routers due to poor signals when being in one location opposed to another.



      When I work on my Macbook from different locations I find it annoying when I have to switch between routers. The eventual goal is to run a more complex script under launchd to identify if a better networks is present and automate the change over.



      I've tried experimenting with networksetup -listnetworkserviceorder and networksetup -listallhardwareports but have had no luck.



      In AppleScript or any other scripting language a way to measure two router's strength similar to what's visible on the menu bar's wifi signal?










      share|improve this question















      At my home I have two separate routers due to poor signals when being in one location opposed to another.



      When I work on my Macbook from different locations I find it annoying when I have to switch between routers. The eventual goal is to run a more complex script under launchd to identify if a better networks is present and automate the change over.



      I've tried experimenting with networksetup -listnetworkserviceorder and networksetup -listallhardwareports but have had no luck.



      In AppleScript or any other scripting language a way to measure two router's strength similar to what's visible on the menu bar's wifi signal?







      macos network applescript wifi automation






      share|improve this question















      share|improve this question













      share|improve this question




      share|improve this question








      edited 28 mins ago









      bmike♦

      153k46272596




      153k46272596










      asked 2 hours ago









      ʀ2ᴅ2

      4611518




      4611518




















          3 Answers
          3






          active

          oldest

          votes

















          up vote
          1
          down vote













          Your Mac can do that for you already.



          Of course you have to have set up both routers as Automatically Join and at the top of your list.



          Then tell it to roam and it will automatically connect to next stronger signal network.



          Even better is if your SSID and WPA are the same for both.



          To turn the roaming on in case it was off do this in Terminal:



          sudo defaults write /Library/Preferences/com.apple.airport.opproam enabled -bool true


          Then set it up to automatically join next strongest access point



          sudo /System/Library/PrivateFrameworks/Apple80211.framework/Versions/A/Resources/airport prefs joinMode=Strongest


          You are done, now you can move around and your Mac will keep you connected to the strongest signal.



          More reading material here



          And Apple explains it how it works






          share|improve this answer





























            up vote
            1
            down vote













            Here's a JavaScript for Automation (JXA) script that will scan for WiFi networks and retrieve the SSIDs and RSSI values:



            ObjC.import('CoreWLAN');
            nil = $();

            const defaultInterface = $.CWWiFiClient.sharedWiFiClient.interface;

            const networks = defaultInterface
            .scanForNetworksWithNameError(nil,nil)
            .allObjects;

            const ssids = ObjC.deepUnwrap(networks.valueForKey('ssid'));
            const rssiValues = ObjC.deepUnwrap(networks.valueForKey('rssiValue'));

            const WiFi = ssids.reduce((ξ, item, i)=>
            ξ[item] = rssiValues[i];
            return ξ;
            , )
            var WiFiByStrength = ;
            Object.keys(WiFi).sort((i,j)=> return WiFi[j] - WiFi[i]; )
            .map(key=>WiFiByStrength[key] = WiFi[key]);

            WiFiByStrength


            It presents the output of key-value pairs sorted by signal strength (RSSI) in order, starting with the strongest WiFi network signal first:



            "CK.net":-38, "NCC-1701-D":-59, "Peter's Wi-Fi Network":-67, 
            "BTWifi-X":-68, "BTWifi-with-FON":-68, "BTHub4-WMJM":-68


            Here, the RSSI values are negative numbers, with a number closer to 0 (more positive) indicative of a stronger WiFi signal.



            NB. If you'd prefer this script in AppleScript, I could probably do that for you as well. I just chose JXA because it handles Cocoa value types with less fuss. But now the script is written, it's fairly straightforward to translate it.






            share|improve this answer



























              up vote
              1
              down vote













              Yes - both the current network and potential networks can be scripted from unix command line / shell so that extends to most automation languages - including AppleScript. I'd make your final program in python or swift, but here's how to start your process with signal strength.



              Getting the current connected network is easy and quick. The relevant entries for signal and noise are the raw radio values on the channel negotiated but it would be better to key off Transmit Rate since as long as you have faster than X network, it doesn't really matter what noise / signal since the transmit rate drops down when the signal drops or the noise raises.



              system_profiler SPAirPortDataType:



               AC88U_5G:
              PHY Mode: 802.11ac
              BSSID: 54:36:9b:2d:78:e2
              Channel: 149
              Country Code: CN
              Network Type: Infrastructure
              Security: WPA2 Personal
              Signal / Noise: -26 dBm / -81 dBm
              Transmit Rate: 867
              MCS Index: 9
              Other Local Wi-Fi Networks:
              AC88U:
              PHY Mode: 802.11n
              BSSID: 54:36:9b:2d:78:e1
              Channel: 7
              Country Code: CN
              Network Type: Infrastructure
              Security: WPA2 Personal
              Signal / Noise: -18 dBm / 0 dBm


              Scanning all possible radios and channels is quite slower (5 to 10 seconds instead of a fraction of a second to run) than the simple dump above, so you'd need a program to handle that or a script that's a lot more savvy. I'd start with airport --scan and filter for your preferred SSID or known MAC address on your base stations:



              /System/Library/PrivateFrameworks/Apple80211.framework/Versions/A/Resources/airport --scan


              Once you've scanned, the system_profiler should report more results as the scan results seem to be cached locally for a while.



              WiFi engineers perform this optimization all the time by controlling the MCS / Transmit rate. Simply choose all transmit rates you wish to evict all clients for your main radio and once they lose connection at the preferred high speeds, all OS will drop and then pick up the next radio that's available. Much easier than rolling out custom scripts to all the devices that connect to your two radios.



              Also, it goes without saying - if you could make both radios broadcast on the same SSID - then your Apple products would just roam but maybe you have a good reason to not have the same network name and simplify your work.






              share|improve this answer










              New contributor




              maP1E bluE is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
              Check out our Code of Conduct.

















              • Can you add some detail on how to read the output, especially on how to decide which Wi-Fi is stronger?
                – nohillside♦
                1 hour ago










              • @nohillside Ok,I am not good at script, but I will try a simple one.
                – maP1E bluE
                1 hour ago











              • I got you @maP1EbluE - This is a very well known design problem for WiFi engineers. The RSSI and Signal are bad things to automate, but if the OP wants signal - it's there. The real two items to key on are MCS Index and Transmit rate and your answer is perfect to get a measure for when the OP wants to start the drop process. Trying to write the whole program / script is far too broad for one question so your answer should be perfect for how to get started. +1
                – bmike♦
                21 mins ago











              • I didn‘t ask for a script actually, but just an explanation on which of the values are important.
                – nohillside♦
                10 mins ago










              • @nohillside You didn't ask for a script, but the OP had it after the main question. I've edited the question to make this not too broad. There's some good info - hopefully I didn't add too many words here - please anyone pare down my text if the short answer of airport --getinfo and airport --scan is all that's needed here and the explanation to look at transmit rate when you wish to bail on a network instead of RSSI / SNR / Signal / Noise decibel values.
                – bmike♦
                8 mins ago










              Your Answer








              StackExchange.ready(function()
              var channelOptions =
              tags: "".split(" "),
              id: "118"
              ;
              initTagRenderer("".split(" "), "".split(" "), channelOptions);

              StackExchange.using("externalEditor", function()
              // Have to fire editor after snippets, if snippets enabled
              if (StackExchange.settings.snippets.snippetsEnabled)
              StackExchange.using("snippets", function()
              createEditor();
              );

              else
              createEditor();

              );

              function createEditor()
              StackExchange.prepareEditor(
              heartbeatType: 'answer',
              convertImagesToLinks: false,
              noModals: true,
              showLowRepImageUploadWarning: true,
              reputationToPostImages: null,
              bindNavPrevention: true,
              postfix: "",
              imageUploader:
              brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
              contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
              allowUrls: true
              ,
              onDemand: true,
              discardSelector: ".discard-answer"
              ,immediatelyShowMarkdownHelp:true
              );



              );













               

              draft saved


              draft discarded


















              StackExchange.ready(
              function ()
              StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fapple.stackexchange.com%2fquestions%2f341656%2fcan-applescript-or-any-other-script-measure-a-macbooks-wifi-signal-strength%23new-answer', 'question_page');

              );

              Post as a guest






























              3 Answers
              3






              active

              oldest

              votes








              3 Answers
              3






              active

              oldest

              votes









              active

              oldest

              votes






              active

              oldest

              votes








              up vote
              1
              down vote













              Your Mac can do that for you already.



              Of course you have to have set up both routers as Automatically Join and at the top of your list.



              Then tell it to roam and it will automatically connect to next stronger signal network.



              Even better is if your SSID and WPA are the same for both.



              To turn the roaming on in case it was off do this in Terminal:



              sudo defaults write /Library/Preferences/com.apple.airport.opproam enabled -bool true


              Then set it up to automatically join next strongest access point



              sudo /System/Library/PrivateFrameworks/Apple80211.framework/Versions/A/Resources/airport prefs joinMode=Strongest


              You are done, now you can move around and your Mac will keep you connected to the strongest signal.



              More reading material here



              And Apple explains it how it works






              share|improve this answer


























                up vote
                1
                down vote













                Your Mac can do that for you already.



                Of course you have to have set up both routers as Automatically Join and at the top of your list.



                Then tell it to roam and it will automatically connect to next stronger signal network.



                Even better is if your SSID and WPA are the same for both.



                To turn the roaming on in case it was off do this in Terminal:



                sudo defaults write /Library/Preferences/com.apple.airport.opproam enabled -bool true


                Then set it up to automatically join next strongest access point



                sudo /System/Library/PrivateFrameworks/Apple80211.framework/Versions/A/Resources/airport prefs joinMode=Strongest


                You are done, now you can move around and your Mac will keep you connected to the strongest signal.



                More reading material here



                And Apple explains it how it works






                share|improve this answer
























                  up vote
                  1
                  down vote










                  up vote
                  1
                  down vote









                  Your Mac can do that for you already.



                  Of course you have to have set up both routers as Automatically Join and at the top of your list.



                  Then tell it to roam and it will automatically connect to next stronger signal network.



                  Even better is if your SSID and WPA are the same for both.



                  To turn the roaming on in case it was off do this in Terminal:



                  sudo defaults write /Library/Preferences/com.apple.airport.opproam enabled -bool true


                  Then set it up to automatically join next strongest access point



                  sudo /System/Library/PrivateFrameworks/Apple80211.framework/Versions/A/Resources/airport prefs joinMode=Strongest


                  You are done, now you can move around and your Mac will keep you connected to the strongest signal.



                  More reading material here



                  And Apple explains it how it works






                  share|improve this answer














                  Your Mac can do that for you already.



                  Of course you have to have set up both routers as Automatically Join and at the top of your list.



                  Then tell it to roam and it will automatically connect to next stronger signal network.



                  Even better is if your SSID and WPA are the same for both.



                  To turn the roaming on in case it was off do this in Terminal:



                  sudo defaults write /Library/Preferences/com.apple.airport.opproam enabled -bool true


                  Then set it up to automatically join next strongest access point



                  sudo /System/Library/PrivateFrameworks/Apple80211.framework/Versions/A/Resources/airport prefs joinMode=Strongest


                  You are done, now you can move around and your Mac will keep you connected to the strongest signal.



                  More reading material here



                  And Apple explains it how it works







                  share|improve this answer














                  share|improve this answer



                  share|improve this answer








                  edited 57 mins ago

























                  answered 1 hour ago









                  Buscar웃

                  34.3k539111




                  34.3k539111






















                      up vote
                      1
                      down vote













                      Here's a JavaScript for Automation (JXA) script that will scan for WiFi networks and retrieve the SSIDs and RSSI values:



                      ObjC.import('CoreWLAN');
                      nil = $();

                      const defaultInterface = $.CWWiFiClient.sharedWiFiClient.interface;

                      const networks = defaultInterface
                      .scanForNetworksWithNameError(nil,nil)
                      .allObjects;

                      const ssids = ObjC.deepUnwrap(networks.valueForKey('ssid'));
                      const rssiValues = ObjC.deepUnwrap(networks.valueForKey('rssiValue'));

                      const WiFi = ssids.reduce((ξ, item, i)=>
                      ξ[item] = rssiValues[i];
                      return ξ;
                      , )
                      var WiFiByStrength = ;
                      Object.keys(WiFi).sort((i,j)=> return WiFi[j] - WiFi[i]; )
                      .map(key=>WiFiByStrength[key] = WiFi[key]);

                      WiFiByStrength


                      It presents the output of key-value pairs sorted by signal strength (RSSI) in order, starting with the strongest WiFi network signal first:



                      "CK.net":-38, "NCC-1701-D":-59, "Peter's Wi-Fi Network":-67, 
                      "BTWifi-X":-68, "BTWifi-with-FON":-68, "BTHub4-WMJM":-68


                      Here, the RSSI values are negative numbers, with a number closer to 0 (more positive) indicative of a stronger WiFi signal.



                      NB. If you'd prefer this script in AppleScript, I could probably do that for you as well. I just chose JXA because it handles Cocoa value types with less fuss. But now the script is written, it's fairly straightforward to translate it.






                      share|improve this answer
























                        up vote
                        1
                        down vote













                        Here's a JavaScript for Automation (JXA) script that will scan for WiFi networks and retrieve the SSIDs and RSSI values:



                        ObjC.import('CoreWLAN');
                        nil = $();

                        const defaultInterface = $.CWWiFiClient.sharedWiFiClient.interface;

                        const networks = defaultInterface
                        .scanForNetworksWithNameError(nil,nil)
                        .allObjects;

                        const ssids = ObjC.deepUnwrap(networks.valueForKey('ssid'));
                        const rssiValues = ObjC.deepUnwrap(networks.valueForKey('rssiValue'));

                        const WiFi = ssids.reduce((ξ, item, i)=>
                        ξ[item] = rssiValues[i];
                        return ξ;
                        , )
                        var WiFiByStrength = ;
                        Object.keys(WiFi).sort((i,j)=> return WiFi[j] - WiFi[i]; )
                        .map(key=>WiFiByStrength[key] = WiFi[key]);

                        WiFiByStrength


                        It presents the output of key-value pairs sorted by signal strength (RSSI) in order, starting with the strongest WiFi network signal first:



                        "CK.net":-38, "NCC-1701-D":-59, "Peter's Wi-Fi Network":-67, 
                        "BTWifi-X":-68, "BTWifi-with-FON":-68, "BTHub4-WMJM":-68


                        Here, the RSSI values are negative numbers, with a number closer to 0 (more positive) indicative of a stronger WiFi signal.



                        NB. If you'd prefer this script in AppleScript, I could probably do that for you as well. I just chose JXA because it handles Cocoa value types with less fuss. But now the script is written, it's fairly straightforward to translate it.






                        share|improve this answer






















                          up vote
                          1
                          down vote










                          up vote
                          1
                          down vote









                          Here's a JavaScript for Automation (JXA) script that will scan for WiFi networks and retrieve the SSIDs and RSSI values:



                          ObjC.import('CoreWLAN');
                          nil = $();

                          const defaultInterface = $.CWWiFiClient.sharedWiFiClient.interface;

                          const networks = defaultInterface
                          .scanForNetworksWithNameError(nil,nil)
                          .allObjects;

                          const ssids = ObjC.deepUnwrap(networks.valueForKey('ssid'));
                          const rssiValues = ObjC.deepUnwrap(networks.valueForKey('rssiValue'));

                          const WiFi = ssids.reduce((ξ, item, i)=>
                          ξ[item] = rssiValues[i];
                          return ξ;
                          , )
                          var WiFiByStrength = ;
                          Object.keys(WiFi).sort((i,j)=> return WiFi[j] - WiFi[i]; )
                          .map(key=>WiFiByStrength[key] = WiFi[key]);

                          WiFiByStrength


                          It presents the output of key-value pairs sorted by signal strength (RSSI) in order, starting with the strongest WiFi network signal first:



                          "CK.net":-38, "NCC-1701-D":-59, "Peter's Wi-Fi Network":-67, 
                          "BTWifi-X":-68, "BTWifi-with-FON":-68, "BTHub4-WMJM":-68


                          Here, the RSSI values are negative numbers, with a number closer to 0 (more positive) indicative of a stronger WiFi signal.



                          NB. If you'd prefer this script in AppleScript, I could probably do that for you as well. I just chose JXA because it handles Cocoa value types with less fuss. But now the script is written, it's fairly straightforward to translate it.






                          share|improve this answer












                          Here's a JavaScript for Automation (JXA) script that will scan for WiFi networks and retrieve the SSIDs and RSSI values:



                          ObjC.import('CoreWLAN');
                          nil = $();

                          const defaultInterface = $.CWWiFiClient.sharedWiFiClient.interface;

                          const networks = defaultInterface
                          .scanForNetworksWithNameError(nil,nil)
                          .allObjects;

                          const ssids = ObjC.deepUnwrap(networks.valueForKey('ssid'));
                          const rssiValues = ObjC.deepUnwrap(networks.valueForKey('rssiValue'));

                          const WiFi = ssids.reduce((ξ, item, i)=>
                          ξ[item] = rssiValues[i];
                          return ξ;
                          , )
                          var WiFiByStrength = ;
                          Object.keys(WiFi).sort((i,j)=> return WiFi[j] - WiFi[i]; )
                          .map(key=>WiFiByStrength[key] = WiFi[key]);

                          WiFiByStrength


                          It presents the output of key-value pairs sorted by signal strength (RSSI) in order, starting with the strongest WiFi network signal first:



                          "CK.net":-38, "NCC-1701-D":-59, "Peter's Wi-Fi Network":-67, 
                          "BTWifi-X":-68, "BTWifi-with-FON":-68, "BTHub4-WMJM":-68


                          Here, the RSSI values are negative numbers, with a number closer to 0 (more positive) indicative of a stronger WiFi signal.



                          NB. If you'd prefer this script in AppleScript, I could probably do that for you as well. I just chose JXA because it handles Cocoa value types with less fuss. But now the script is written, it's fairly straightforward to translate it.







                          share|improve this answer












                          share|improve this answer



                          share|improve this answer










                          answered 30 mins ago









                          CJK

                          2,05311




                          2,05311




















                              up vote
                              1
                              down vote













                              Yes - both the current network and potential networks can be scripted from unix command line / shell so that extends to most automation languages - including AppleScript. I'd make your final program in python or swift, but here's how to start your process with signal strength.



                              Getting the current connected network is easy and quick. The relevant entries for signal and noise are the raw radio values on the channel negotiated but it would be better to key off Transmit Rate since as long as you have faster than X network, it doesn't really matter what noise / signal since the transmit rate drops down when the signal drops or the noise raises.



                              system_profiler SPAirPortDataType:



                               AC88U_5G:
                              PHY Mode: 802.11ac
                              BSSID: 54:36:9b:2d:78:e2
                              Channel: 149
                              Country Code: CN
                              Network Type: Infrastructure
                              Security: WPA2 Personal
                              Signal / Noise: -26 dBm / -81 dBm
                              Transmit Rate: 867
                              MCS Index: 9
                              Other Local Wi-Fi Networks:
                              AC88U:
                              PHY Mode: 802.11n
                              BSSID: 54:36:9b:2d:78:e1
                              Channel: 7
                              Country Code: CN
                              Network Type: Infrastructure
                              Security: WPA2 Personal
                              Signal / Noise: -18 dBm / 0 dBm


                              Scanning all possible radios and channels is quite slower (5 to 10 seconds instead of a fraction of a second to run) than the simple dump above, so you'd need a program to handle that or a script that's a lot more savvy. I'd start with airport --scan and filter for your preferred SSID or known MAC address on your base stations:



                              /System/Library/PrivateFrameworks/Apple80211.framework/Versions/A/Resources/airport --scan


                              Once you've scanned, the system_profiler should report more results as the scan results seem to be cached locally for a while.



                              WiFi engineers perform this optimization all the time by controlling the MCS / Transmit rate. Simply choose all transmit rates you wish to evict all clients for your main radio and once they lose connection at the preferred high speeds, all OS will drop and then pick up the next radio that's available. Much easier than rolling out custom scripts to all the devices that connect to your two radios.



                              Also, it goes without saying - if you could make both radios broadcast on the same SSID - then your Apple products would just roam but maybe you have a good reason to not have the same network name and simplify your work.






                              share|improve this answer










                              New contributor




                              maP1E bluE is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
                              Check out our Code of Conduct.

















                              • Can you add some detail on how to read the output, especially on how to decide which Wi-Fi is stronger?
                                – nohillside♦
                                1 hour ago










                              • @nohillside Ok,I am not good at script, but I will try a simple one.
                                – maP1E bluE
                                1 hour ago











                              • I got you @maP1EbluE - This is a very well known design problem for WiFi engineers. The RSSI and Signal are bad things to automate, but if the OP wants signal - it's there. The real two items to key on are MCS Index and Transmit rate and your answer is perfect to get a measure for when the OP wants to start the drop process. Trying to write the whole program / script is far too broad for one question so your answer should be perfect for how to get started. +1
                                – bmike♦
                                21 mins ago











                              • I didn‘t ask for a script actually, but just an explanation on which of the values are important.
                                – nohillside♦
                                10 mins ago










                              • @nohillside You didn't ask for a script, but the OP had it after the main question. I've edited the question to make this not too broad. There's some good info - hopefully I didn't add too many words here - please anyone pare down my text if the short answer of airport --getinfo and airport --scan is all that's needed here and the explanation to look at transmit rate when you wish to bail on a network instead of RSSI / SNR / Signal / Noise decibel values.
                                – bmike♦
                                8 mins ago














                              up vote
                              1
                              down vote













                              Yes - both the current network and potential networks can be scripted from unix command line / shell so that extends to most automation languages - including AppleScript. I'd make your final program in python or swift, but here's how to start your process with signal strength.



                              Getting the current connected network is easy and quick. The relevant entries for signal and noise are the raw radio values on the channel negotiated but it would be better to key off Transmit Rate since as long as you have faster than X network, it doesn't really matter what noise / signal since the transmit rate drops down when the signal drops or the noise raises.



                              system_profiler SPAirPortDataType:



                               AC88U_5G:
                              PHY Mode: 802.11ac
                              BSSID: 54:36:9b:2d:78:e2
                              Channel: 149
                              Country Code: CN
                              Network Type: Infrastructure
                              Security: WPA2 Personal
                              Signal / Noise: -26 dBm / -81 dBm
                              Transmit Rate: 867
                              MCS Index: 9
                              Other Local Wi-Fi Networks:
                              AC88U:
                              PHY Mode: 802.11n
                              BSSID: 54:36:9b:2d:78:e1
                              Channel: 7
                              Country Code: CN
                              Network Type: Infrastructure
                              Security: WPA2 Personal
                              Signal / Noise: -18 dBm / 0 dBm


                              Scanning all possible radios and channels is quite slower (5 to 10 seconds instead of a fraction of a second to run) than the simple dump above, so you'd need a program to handle that or a script that's a lot more savvy. I'd start with airport --scan and filter for your preferred SSID or known MAC address on your base stations:



                              /System/Library/PrivateFrameworks/Apple80211.framework/Versions/A/Resources/airport --scan


                              Once you've scanned, the system_profiler should report more results as the scan results seem to be cached locally for a while.



                              WiFi engineers perform this optimization all the time by controlling the MCS / Transmit rate. Simply choose all transmit rates you wish to evict all clients for your main radio and once they lose connection at the preferred high speeds, all OS will drop and then pick up the next radio that's available. Much easier than rolling out custom scripts to all the devices that connect to your two radios.



                              Also, it goes without saying - if you could make both radios broadcast on the same SSID - then your Apple products would just roam but maybe you have a good reason to not have the same network name and simplify your work.






                              share|improve this answer










                              New contributor




                              maP1E bluE is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
                              Check out our Code of Conduct.

















                              • Can you add some detail on how to read the output, especially on how to decide which Wi-Fi is stronger?
                                – nohillside♦
                                1 hour ago










                              • @nohillside Ok,I am not good at script, but I will try a simple one.
                                – maP1E bluE
                                1 hour ago











                              • I got you @maP1EbluE - This is a very well known design problem for WiFi engineers. The RSSI and Signal are bad things to automate, but if the OP wants signal - it's there. The real two items to key on are MCS Index and Transmit rate and your answer is perfect to get a measure for when the OP wants to start the drop process. Trying to write the whole program / script is far too broad for one question so your answer should be perfect for how to get started. +1
                                – bmike♦
                                21 mins ago











                              • I didn‘t ask for a script actually, but just an explanation on which of the values are important.
                                – nohillside♦
                                10 mins ago










                              • @nohillside You didn't ask for a script, but the OP had it after the main question. I've edited the question to make this not too broad. There's some good info - hopefully I didn't add too many words here - please anyone pare down my text if the short answer of airport --getinfo and airport --scan is all that's needed here and the explanation to look at transmit rate when you wish to bail on a network instead of RSSI / SNR / Signal / Noise decibel values.
                                – bmike♦
                                8 mins ago












                              up vote
                              1
                              down vote










                              up vote
                              1
                              down vote









                              Yes - both the current network and potential networks can be scripted from unix command line / shell so that extends to most automation languages - including AppleScript. I'd make your final program in python or swift, but here's how to start your process with signal strength.



                              Getting the current connected network is easy and quick. The relevant entries for signal and noise are the raw radio values on the channel negotiated but it would be better to key off Transmit Rate since as long as you have faster than X network, it doesn't really matter what noise / signal since the transmit rate drops down when the signal drops or the noise raises.



                              system_profiler SPAirPortDataType:



                               AC88U_5G:
                              PHY Mode: 802.11ac
                              BSSID: 54:36:9b:2d:78:e2
                              Channel: 149
                              Country Code: CN
                              Network Type: Infrastructure
                              Security: WPA2 Personal
                              Signal / Noise: -26 dBm / -81 dBm
                              Transmit Rate: 867
                              MCS Index: 9
                              Other Local Wi-Fi Networks:
                              AC88U:
                              PHY Mode: 802.11n
                              BSSID: 54:36:9b:2d:78:e1
                              Channel: 7
                              Country Code: CN
                              Network Type: Infrastructure
                              Security: WPA2 Personal
                              Signal / Noise: -18 dBm / 0 dBm


                              Scanning all possible radios and channels is quite slower (5 to 10 seconds instead of a fraction of a second to run) than the simple dump above, so you'd need a program to handle that or a script that's a lot more savvy. I'd start with airport --scan and filter for your preferred SSID or known MAC address on your base stations:



                              /System/Library/PrivateFrameworks/Apple80211.framework/Versions/A/Resources/airport --scan


                              Once you've scanned, the system_profiler should report more results as the scan results seem to be cached locally for a while.



                              WiFi engineers perform this optimization all the time by controlling the MCS / Transmit rate. Simply choose all transmit rates you wish to evict all clients for your main radio and once they lose connection at the preferred high speeds, all OS will drop and then pick up the next radio that's available. Much easier than rolling out custom scripts to all the devices that connect to your two radios.



                              Also, it goes without saying - if you could make both radios broadcast on the same SSID - then your Apple products would just roam but maybe you have a good reason to not have the same network name and simplify your work.






                              share|improve this answer










                              New contributor




                              maP1E bluE is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
                              Check out our Code of Conduct.









                              Yes - both the current network and potential networks can be scripted from unix command line / shell so that extends to most automation languages - including AppleScript. I'd make your final program in python or swift, but here's how to start your process with signal strength.



                              Getting the current connected network is easy and quick. The relevant entries for signal and noise are the raw radio values on the channel negotiated but it would be better to key off Transmit Rate since as long as you have faster than X network, it doesn't really matter what noise / signal since the transmit rate drops down when the signal drops or the noise raises.



                              system_profiler SPAirPortDataType:



                               AC88U_5G:
                              PHY Mode: 802.11ac
                              BSSID: 54:36:9b:2d:78:e2
                              Channel: 149
                              Country Code: CN
                              Network Type: Infrastructure
                              Security: WPA2 Personal
                              Signal / Noise: -26 dBm / -81 dBm
                              Transmit Rate: 867
                              MCS Index: 9
                              Other Local Wi-Fi Networks:
                              AC88U:
                              PHY Mode: 802.11n
                              BSSID: 54:36:9b:2d:78:e1
                              Channel: 7
                              Country Code: CN
                              Network Type: Infrastructure
                              Security: WPA2 Personal
                              Signal / Noise: -18 dBm / 0 dBm


                              Scanning all possible radios and channels is quite slower (5 to 10 seconds instead of a fraction of a second to run) than the simple dump above, so you'd need a program to handle that or a script that's a lot more savvy. I'd start with airport --scan and filter for your preferred SSID or known MAC address on your base stations:



                              /System/Library/PrivateFrameworks/Apple80211.framework/Versions/A/Resources/airport --scan


                              Once you've scanned, the system_profiler should report more results as the scan results seem to be cached locally for a while.



                              WiFi engineers perform this optimization all the time by controlling the MCS / Transmit rate. Simply choose all transmit rates you wish to evict all clients for your main radio and once they lose connection at the preferred high speeds, all OS will drop and then pick up the next radio that's available. Much easier than rolling out custom scripts to all the devices that connect to your two radios.



                              Also, it goes without saying - if you could make both radios broadcast on the same SSID - then your Apple products would just roam but maybe you have a good reason to not have the same network name and simplify your work.







                              share|improve this answer










                              New contributor




                              maP1E bluE is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
                              Check out our Code of Conduct.









                              share|improve this answer



                              share|improve this answer








                              edited 10 mins ago









                              bmike♦

                              153k46272596




                              153k46272596






                              New contributor




                              maP1E bluE is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
                              Check out our Code of Conduct.









                              answered 1 hour ago









                              maP1E bluE

                              1716




                              1716




                              New contributor




                              maP1E bluE is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
                              Check out our Code of Conduct.





                              New contributor





                              maP1E bluE is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
                              Check out our Code of Conduct.






                              maP1E bluE is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
                              Check out our Code of Conduct.











                              • Can you add some detail on how to read the output, especially on how to decide which Wi-Fi is stronger?
                                – nohillside♦
                                1 hour ago










                              • @nohillside Ok,I am not good at script, but I will try a simple one.
                                – maP1E bluE
                                1 hour ago











                              • I got you @maP1EbluE - This is a very well known design problem for WiFi engineers. The RSSI and Signal are bad things to automate, but if the OP wants signal - it's there. The real two items to key on are MCS Index and Transmit rate and your answer is perfect to get a measure for when the OP wants to start the drop process. Trying to write the whole program / script is far too broad for one question so your answer should be perfect for how to get started. +1
                                – bmike♦
                                21 mins ago











                              • I didn‘t ask for a script actually, but just an explanation on which of the values are important.
                                – nohillside♦
                                10 mins ago










                              • @nohillside You didn't ask for a script, but the OP had it after the main question. I've edited the question to make this not too broad. There's some good info - hopefully I didn't add too many words here - please anyone pare down my text if the short answer of airport --getinfo and airport --scan is all that's needed here and the explanation to look at transmit rate when you wish to bail on a network instead of RSSI / SNR / Signal / Noise decibel values.
                                – bmike♦
                                8 mins ago
















                              • Can you add some detail on how to read the output, especially on how to decide which Wi-Fi is stronger?
                                – nohillside♦
                                1 hour ago










                              • @nohillside Ok,I am not good at script, but I will try a simple one.
                                – maP1E bluE
                                1 hour ago











                              • I got you @maP1EbluE - This is a very well known design problem for WiFi engineers. The RSSI and Signal are bad things to automate, but if the OP wants signal - it's there. The real two items to key on are MCS Index and Transmit rate and your answer is perfect to get a measure for when the OP wants to start the drop process. Trying to write the whole program / script is far too broad for one question so your answer should be perfect for how to get started. +1
                                – bmike♦
                                21 mins ago











                              • I didn‘t ask for a script actually, but just an explanation on which of the values are important.
                                – nohillside♦
                                10 mins ago










                              • @nohillside You didn't ask for a script, but the OP had it after the main question. I've edited the question to make this not too broad. There's some good info - hopefully I didn't add too many words here - please anyone pare down my text if the short answer of airport --getinfo and airport --scan is all that's needed here and the explanation to look at transmit rate when you wish to bail on a network instead of RSSI / SNR / Signal / Noise decibel values.
                                – bmike♦
                                8 mins ago















                              Can you add some detail on how to read the output, especially on how to decide which Wi-Fi is stronger?
                              – nohillside♦
                              1 hour ago




                              Can you add some detail on how to read the output, especially on how to decide which Wi-Fi is stronger?
                              – nohillside♦
                              1 hour ago












                              @nohillside Ok,I am not good at script, but I will try a simple one.
                              – maP1E bluE
                              1 hour ago





                              @nohillside Ok,I am not good at script, but I will try a simple one.
                              – maP1E bluE
                              1 hour ago













                              I got you @maP1EbluE - This is a very well known design problem for WiFi engineers. The RSSI and Signal are bad things to automate, but if the OP wants signal - it's there. The real two items to key on are MCS Index and Transmit rate and your answer is perfect to get a measure for when the OP wants to start the drop process. Trying to write the whole program / script is far too broad for one question so your answer should be perfect for how to get started. +1
                              – bmike♦
                              21 mins ago





                              I got you @maP1EbluE - This is a very well known design problem for WiFi engineers. The RSSI and Signal are bad things to automate, but if the OP wants signal - it's there. The real two items to key on are MCS Index and Transmit rate and your answer is perfect to get a measure for when the OP wants to start the drop process. Trying to write the whole program / script is far too broad for one question so your answer should be perfect for how to get started. +1
                              – bmike♦
                              21 mins ago













                              I didn‘t ask for a script actually, but just an explanation on which of the values are important.
                              – nohillside♦
                              10 mins ago




                              I didn‘t ask for a script actually, but just an explanation on which of the values are important.
                              – nohillside♦
                              10 mins ago












                              @nohillside You didn't ask for a script, but the OP had it after the main question. I've edited the question to make this not too broad. There's some good info - hopefully I didn't add too many words here - please anyone pare down my text if the short answer of airport --getinfo and airport --scan is all that's needed here and the explanation to look at transmit rate when you wish to bail on a network instead of RSSI / SNR / Signal / Noise decibel values.
                              – bmike♦
                              8 mins ago




                              @nohillside You didn't ask for a script, but the OP had it after the main question. I've edited the question to make this not too broad. There's some good info - hopefully I didn't add too many words here - please anyone pare down my text if the short answer of airport --getinfo and airport --scan is all that's needed here and the explanation to look at transmit rate when you wish to bail on a network instead of RSSI / SNR / Signal / Noise decibel values.
                              – bmike♦
                              8 mins ago

















                               

                              draft saved


                              draft discarded















































                               


                              draft saved


                              draft discarded














                              StackExchange.ready(
                              function ()
                              StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fapple.stackexchange.com%2fquestions%2f341656%2fcan-applescript-or-any-other-script-measure-a-macbooks-wifi-signal-strength%23new-answer', 'question_page');

                              );

                              Post as a guest













































































                              Comments

                              Popular posts from this blog

                              What does second last employer means? [closed]

                              List of Gilmore Girls characters

                              Confectionery