Networking :: Making a usb wireless device config utility



Quote (Aiku @ Sep. 20 2004,01:19 (in the "Verified Wireless Cards" Thread))
Here is what I use for basic connection for my Netgear USB MA111

#!/bin/bash
wlanctl-ng wlan0 lnxreq_ifstate ifstate=enable
wlanctl-ng wlan0 lnxreq_autojoin ssid=YOUR_SSID authtype=opensystem
pump -i wlan0
kill `pidof wmnet`
wmnet -w -W wlan0 &

I mainly use it a public access points



I'm getting in the spirit of a real linux user and writing an app to do this easily.

It'll be in C++ as source, and I'll post the source here as well as emailing the binary to ke4nt1.

I'd write it in C, but I don't know how to use variables as a part of a system call in C, although I'm not 100% sure how to in C++, that's what I've been using lately. So deal.

Here's the incomplete source for what I have so far. far from finished, so it won't compile, but I wanted to share.

Code Sample
#include <iostream.h>
#include <string>
#include <stdlib.h>

int main()
{
// This program will configure your prism2_usb.o based USB wireless device for use in Damn Small Linux v.0.8.2
// This was thrown together by J.P. Nimmo, a.k.a. SaidinUnleased late at night, and as such may be buggy, crappy, ed up, or may not work all together. If you experience problems, fix it yourself.

 system ("clear");

 cout << "This program will configure and enable your prism2 based USB wireless device and restarts wmnet to monitor it.\n";

 short int menuchoice = 0;

 string devname = wlan0;

 string authtype = opensystem;

 string sid;

 while (menuchoice != 6)
  {
   cout << "--------MAKE SURE YOU DO 3--------\n";
   cout << "1 - run iwconfig \(so you can see the name of your USB wireless device, usually wlan0\)\n";
   cout << "2 - set your USB wireless device's name \(default wlan0\)\n";
   cout << "3 - set your SSID \(the name of the network, usually\)\n";
   cout << "4 - set your authtype \(default is opensystem\)\n";
   cout << "5 - execute the setup, according to your settings and exit\n";
   cout << "6 - Exit without doing anything\n"
   cout << "--------MAKE SURE YOU DO 3--------\n";
   cout << endl;
   cout << Enter your choice: ";

   cin >> menuchoice;

   if (menuchoice<1 || menuchoice>5)
    {
     cout << "THAT CHOICE IS NOT VALID!!!\n";
     cout << endl;
    }

   if (menuchoice == 1)
    {
     system ("sudo iwconfig");
     cout << endl;
    }

   if (menuchoice == 2)
    {
     cout << "Enter the name of the wireless device: ";
     cin >> devname;
     cout << endl;
    }

   if (menuchoice == 3)
    {
     cout << "Enter your SSID: ";
     cin ssid;
     cout << endl;
    }

   if (menuchoice == 5)
    {
     cout << "Executing config with Device name \"" << devname << "\" with SSID \" << ssid << "\" and authtype \"" << authtype << "\".\n";
     cout << "Is this correct? \(y or n\) ";

     char confirm;


Like I said, it's not finished, but it's a start. And it should work on all prism2_usb.o based devices, when it's done.

-J.P.
SaidinUnleashed

It appears that 0.8.2 has a GUI for prims2 devices.
System->Net Setup->prism2

Yes, but it doesn't work with usb devices. Or, at least, I can't get it to work...

-J.P.
SaidinUnleashed

okay, it app is mostly done. Only thing is, I can't figure out how to use a variable's value in a system call, which is required to set the ssid.

so, this is my little attempt at getting some help.

the source code can be downloaded here/

In it's current form, the source won't compile, so unless you want to help me figure this out, please don't download it. very limited bandwidth there.

okay, here are the problems.

Lines 66 - 71: trying to make a confirm input that would accept Y and y as true, and N and n as false. Simple for someone with a lot of experience, which I don't have.

Lines 73 - 77: can't figure out how to use the value of a variable inside a system call.


anyways, I will continue to tinker with it next week untill someone fixes it here, or I figure it out.

Have fun.

-J.P.
SaidinUnleashed

Good job. Keep up the good work :)
Next Page...
original here.