Henri
Henri

Reputation: 1741

How to detect 4G dongle(s) connected to my computer using NodeJs

How can I detect 4G dongle(s) connected to my computer using NodeJS?

I tried the following code:

var os = require('os');
var allNetworkInterfaces = os.networkInterfaces();
console.log(allNetworkInterfaces);

It works, but I got all network interfaces... I would like to get a list with my 4G dongles only. Knowing that I could have either 1 dongle, or several dongles connected to the same computer, as well as other USB hardwares connected.

Upvotes: 0

Views: 133

Answers (1)

Hitesh Lala
Hitesh Lala

Reputation: 326

After installing the usb package by running npm install usb I was able to get a list of usb devices using the following code:

const usb = require('usb');
const devices = usb.getDeviceList();
console.log( devices );

You will have to go through that list and decide which is your "4G dongle".

Upvotes: 0

Related Questions