gruijter / netgear.js

Node js module to communicate with Netgear routers via SOAP
Mozilla Public License 2.0
58 stars 11 forks source link

router.getAttachedDevices() often returns undefined #22

Open JackAida opened 1 year ago

JackAida commented 1 year ago

Ive been using router.getAttachedDevices() to get each devices current download and upload speeds but often everything but ip and mac returns undefined, below is an example of how all devices attached look 90% of the time, one in around 500 attempts will give me something usable, I have tried making it wait some time between each call and if you spam call it you get it quicker but you also get an error that pops up from time to time regarding some nodejs queuing thing.

Is there a way I can more reliably get the .getAttachedDevices() information?

AttachedDevice {
    IP: '192.168.1.80',
    Name: 'teiraaaa',
    NameUserSet: undefined,
    MAC: 'XX:XX:XX:XX:XX:XX',
    ConnectionType: 'wireless',
    SSID: undefined,
    Linkspeed: 433,
    SignalStrength: 100,
    AllowOrBlock: 'Allow',
    Schedule: undefined,
    DeviceType: undefined,
    DeviceTypeV2: undefined,
    DeviceTypeUserSet: undefined,
    DeviceTypeName: undefined,
    DeviceTypeNameV2: undefined,
    DeviceModel: undefined,
    DeviceModelUserSet: undefined,
    Upload: undefined,
    Download: undefined,
    QosPriority: undefined,
    Grouping: undefined,
    SchedulePeriod: undefined,
    ConnAPMAC: undefined
  }

Currently checking to see how many attempts it takes to get the correct information to see how many tries it actually takes the above one in 500 attempts was just a guess:

deviceArray = await router.getAttachedDevices();
    if(deviceArray[0].Download == undefined){attempts++;}else{
            console.log("took: " + attempts + " to get the correct information");
        attempts = 0;
JackAida commented 1 year ago

Its actually quite random how often it sends through the correct / required information.

took: 67 to get the correct information
4 12:31:46
devices: 9
took: 47 to get the correct information
5 12:32:52
devices: 9
took: 227 to get the correct information
6 12:37:51
devices: 9
took: 23 to get the correct information
7 12:38:26
devices: 9

How above log works: Took x attempts to get the correct information x correct information and timestamp when it was correct devices: x amount connected to router (deviceArray.length)