Exemplo n.º 1
0
/* temp function, only for open network */
int Wireless::joinWPANetwork(const QString ssid, const QString password)
{
	int status = 0;

	closeNetwork();
	sleep(1);

	// it has to be "ssid"
	QString ssidNew = "\"" + ssid + "\"";
	status = iw( WLAN_DEV, "connect", ssidNew );
	printf( "status : %d\n", status);
	if ( status )
		return -1;

	status = wpa_passphrase( ssid, password );
	if ( status )
		return -1;

	status = wpa_supplicant( WLAN_DEV );
	if ( status )
		return -1;

	status = udhcpc( WLAN_DEV, "-n -q" );
	printf( "status : %d\n", status);
	if ( status )
		return -1;

	printf( "status : %d\n", status);
	return status;
}
Exemplo n.º 2
0
int main(int argc, char ** argv) {


    initNetwork();

    struct epoll_event ev;
    memset(&ev, 0, sizeof (struct epoll_event));
    int epollfd;

    epollfd = epoll_create(10);
    FAIL(epollfd);

    //Ajout à epoll de l'entrée standard
    ev.events = EPOLLIN;
    ev.data.fd = STDIN_FILENO;
    FAIL(epoll_ctl(epollfd, EPOLL_CTL_ADD, STDIN_FILENO, &ev));

    struct epoll_event events[MAX_EVENTS];

    int nfds;
    int done = 0;


    while (done == 0) //Boucle principale
    {

        do {
            nfds = epoll_wait(epollfd, events, MAX_EVENTS, -1);
        } while(errno == EINTR);

        FAIL(nfds);

        int n;

        for (n = 0; n < nfds; ++n) {
            if (events[n].data.fd == STDIN_FILENO) {
                char chaine[16];
                fgets(chaine, 15, stdin); //récupère l'entrée standard

                //Traite la commande
                if (strcmp(chaine, "exit\n") == 0 || strcmp(chaine, "quit\n") == 0 || strcmp(chaine, "q\n") == 0) {
                    done = 1;
                    puts("Quiting simulator!");
                }
                else {
                    puts("Commande invalide\nUsage: exit, quit, q");
                }
            }
        }
    }
    closeNetwork();

    return 0;
}
Exemplo n.º 3
0
  MosaicControlNetTool::~MosaicControlNetTool() {
    m_controlNetGraphics = NULL; // the scene cleans/cleaned this up

    delete m_loadControlNetButton;
    delete m_displayControlNetButton;
    delete m_displayConnectivity;
    delete m_configMovement;
    delete m_closeNetwork;
    delete m_controlNetFileLabel;
    delete m_randomizeColors;

    closeNetwork();
  }
Exemplo n.º 4
0
/* temp function, only for open network */
int Wireless::joinOpenNetwork(const QString ssid)
{
	int status = 0;

	closeNetwork();
	sleep(1);

	// it has to be "ssid"
	QString ssidNew = "\"" + ssid + "\"";
	status = iw( WLAN_DEV, "connect", ssidNew );
	printf( "status : %d\n", status);
	if ( status )
		return -1;

	status = udhcpc( WLAN_DEV, "-n -q" );
	printf( "status : %d\n", status);
	if ( status )
		return -1;

	printf( "status : %d\n", status);
	return status;
}
Exemplo n.º 5
0
  /**
   * MosaicControlNetTool constructor
   *
   * @param parent
   */
  MosaicControlNetTool::MosaicControlNetTool(MosaicSceneWidget *scene) :
      MosaicTool(scene) {
    m_controlNet = NULL;
    m_controlNetGraphics = NULL;
    m_loadControlNetButton = NULL;
    m_displayControlNetButton = NULL;
    m_displayConnectivity = NULL;
    m_closeNetwork = NULL;
    m_controlNetFileLabel = NULL;
    m_randomizeColors = NULL;

    m_movementArrowColorSource = NoMovement;
    m_measureCount = 10;
    m_residualMagnitude = 5.0;

    // Create the action buttons

    m_displayControlNetButton = new QPushButton("Display");
    m_displayControlNetButton->setCheckable(true);
    m_displayControlNetButton->setEnabled(false);
    m_displayControlNetButton->setToolTip("Toggle the visibility of the "
        "control points and movement arrows in the network.");
    connect(m_displayControlNetButton, SIGNAL(clicked()), this, SLOT(displayControlNet()));
    connect(m_displayControlNetButton, SIGNAL(destroyed(QObject *)),
            this, SLOT(objectDestroyed(QObject *)));

    m_displayConnectivity = new QPushButton("Color Islands");
    m_displayConnectivity->setToolTip("Color cubes the same if the control "
        "network has a connection between them");
    connect(m_displayConnectivity, SIGNAL(clicked()), this, SLOT(displayConnectivity()));
    connect(m_displayConnectivity, SIGNAL(destroyed(QObject *)),
            this, SLOT(objectDestroyed(QObject *)));
    m_displayConnectivity->setEnabled(false);

    m_randomizeColors = new QPushButton("Color Images");
    m_randomizeColors->setToolTip("Color all cubes differently");
    connect(m_randomizeColors, SIGNAL(clicked()), this, SLOT(randomizeColors()));
    connect(m_randomizeColors, SIGNAL(destroyed(QObject *)),
            this, SLOT(objectDestroyed(QObject *)));

    m_configMovement = new QPushButton(tr("Configure Movement Display"));
    m_configMovement->setToolTip(tr("Show arrow from the apriori surface point to "
        "the adjusted surface point for each control point with this "
        "information"));
    connect(m_configMovement, SIGNAL(clicked()), this, SLOT(configMovement()));
    connect(m_configMovement, SIGNAL(destroyed(QObject *)),
            this, SLOT(objectDestroyed(QObject *)));

    m_closeNetwork = new QPushButton("Close Network");
    m_closeNetwork->setEnabled(false);
    m_closeNetwork->setVisible(false);
    m_closeNetwork->setToolTip("Close the currently open control network");
    connect(m_closeNetwork, SIGNAL(clicked()), this, SLOT(closeNetwork()));
    connect(m_closeNetwork, SIGNAL(destroyed(QObject *)),
            this, SLOT(objectDestroyed(QObject *)));

    m_loadControlNetButton = new QPushButton("Open Network");
    m_loadControlNetButton->setToolTip("Open and load a control network");
    connect(m_loadControlNetButton, SIGNAL(clicked()),
            this, SLOT(openControlNet()));
    connect(m_loadControlNetButton, SIGNAL(destroyed(QObject *)),
            this, SLOT(objectDestroyed(QObject *)));

    m_controlNetFileLabel = new QLabel;
    m_controlNetFileLabel->setToolTip("The filename of the currently open "
        "control network");
    connect(m_controlNetFileLabel, SIGNAL(destroyed(QObject *)),
            this, SLOT(objectDestroyed(QObject *)));
  }