1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.
Dismiss Notice

Welcome To SNBForums

SNBForums is a community for anyone who wants to learn about or discuss the latest in wireless routers, network storage and the ins and outs of building and maintaining a small network.

If you'd like to post a question, simply register and have at it!

While you're at it, please check out SmallNetBuilder for product reviews and our famous Router Charts, Ranker and plenty more!

Any well to tell from script if router is mesh node?

Discussion in 'Asuswrt-Merlin' started by cmkelley, Mar 28, 2020.

  1. cmkelley

    cmkelley Very Senior Member

    Joined:
    Aug 11, 2015
    Messages:
    1,160
    Location:
    Greater Los Angeles Area, California, USizicstania
    Is there an NVRAM variable or some other trick to determine in a script if it is running on a node or on the main router? I tried searching the NVRAM variables for something obvious, but either there's not an obvious one, or what's obvious to someone else isn't to me. :)
     
  2. RMerlin

    RMerlin Super Moderator

    Joined:
    Apr 14, 2012
    Messages:
    32,982
    Location:
    Canada
    Possibly with sw_mode.
     
    L&LD likes this.
  3. thelonelycoder

    thelonelycoder Part of the Furniture

    Joined:
    Jan 23, 2014
    Messages:
    6,808
    Location:
    Switzerland
    I have this code in Diversion, my guess is that mesh node is either 4 or a new value of 5, I have not checked. Let me know if you do:
    Code:
    if [ "$(nvram get sw_mode)" != "1" ]; then
        case "$(nvram get sw_mode)" in
            2)    rtrMode="Repeater";;
            3|4)rtrMode="Access Point (AP) or Media Bridge";;
        esac
        lastError=" Router is in $rtrMode mode,\\n $NAME cannot work in this mode."
        reload_d_menu
    else
        echo "${OK} Wireless router mode"
    fi
     
    L&LD likes this.
  4. cmkelley

    cmkelley Very Senior Member

    Joined:
    Aug 11, 2015
    Messages:
    1,160
    Location:
    Greater Los Angeles Area, California, USizicstania
    I'll try it. Sorry if I put the original post in the wrong spot, I forgot scripts only work on mesh nodes with your firmware.
    Nope, I get 3 on my 68U mesh node. My 86U main router returns 1. But that's good enough for what I want to do, which is detect if scribe is running on the main router or a node.
     
  5. RMerlin

    RMerlin Super Moderator

    Joined:
    Apr 14, 2012
    Messages:
    32,982
    Location:
    Canada
    here are the various modes as defined in libshared:

    Code:
    enum {
            SW_MODE_NONE=0,
            SW_MODE_ROUTER,
            SW_MODE_REPEATER,       /* Ralink/MTK/QCA: if wlc_psta = 1, Media bridge mode. */
            SW_MODE_AP,             /* Broadcom:       if wlc_psta = 1, Media bridge mode. */
            SW_MODE_HOTSPOT
    };
    
    
    No explicit mention of AiMesh nodes. But it points out that wlc_psta might be another potential variable to review.
     
    L&LD likes this.
  6. cmkelley

    cmkelley Very Senior Member

    Joined:
    Aug 11, 2015
    Messages:
    1,160
    Location:
    Greater Los Angeles Area, California, USizicstania
    wlc_psta returns 0 for the main router, 2 for the node.
     
    L&LD likes this.