Ejemplo n.º 1
0
QNetworkInfo::NetworkStatus QNetworkInfoPrivate::networkStatus(QNetworkInfo::NetworkMode mode, int interface)
{
    if (watchNetworkStatus && (mode == QNetworkInfo::WlanMode
                               || mode == QNetworkInfo::EthernetMode
                               || mode == QNetworkInfo::BluetoothMode)) {
        return networkStatuses.value(QPair<QNetworkInfo::NetworkMode, int>(mode, interface));
    } else
        return getNetworkStatus(mode, interface);
}
Ejemplo n.º 2
0
void* monitorThread( void* param )
{
  pthread_t listener,talker,notifier;

  while( getNetworkStatus( ) < 0 ) {
    printf("Network not up yet. Coming back in 5...\n");
    sleep( 5 );
  }

  bRun = 1;
  pthread_create( &notifier, NULL, notifierThread, NULL );
  pthread_create( &listener, NULL, listenerThread, NULL );
  pthread_create( &talker, NULL, talkerThread, NULL );
  
  signalHello( );

  while( bRun )
  {
    int i;
    struct timespec ts;

    sleep( 10 );

    clock_gettime(CLOCK_MONOTONIC, &ts);

    picassoPrintStatus( );

    printf( "\nNetwork Diagnostic info - txCnt:%d txErr:%d (Diag:%d/%d) \n", 
      diag.txCnt, diag.txErrCnt, diag.frmCnt, diag.errCnt );

    for( i=0; i<MAX_OTHERS; i++ )
    {
      if( diag.other[i].IP[0] )
      {
        int timeSinceLastMsg = ts.tv_sec - diag.other[i].lastRxTime.tv_sec;

        printf( "  IP:%s rxCnt:%d Err:%d,%d,%d,%d (%d).\n",
          diag.other[i].IP,
          diag.other[i].rxCnt,
          diag.other[i].repeatRxMissingErrCnt,
          diag.other[i].repeatRxExtraErrCnt,
          diag.other[i].unxpctdRxErrCnt,
          diag.other[i].mlfrmdRxErrCnt,
          timeSinceLastMsg );
      }
    }
  }

  return NULL;
}
bool FONA808::init(){
  mSerial.baud(115200);
  DEBUG_PRINT("Ciao FONA808!\n");
  m_rst = 1;         //perform FONA reboot
  wait_ms(200);
  m_rst=0;
  wait_ms(200);
  m_rst = 1;
  
  wait_ms(2000);   // wait for reboot
  
  DEBUG_PRINT("Cleaning buffer\n");
  mSerial.cleanBuffer();
  DEBUG_PRINT("Buffer clean\n");
  mSerial.printf("+++");
  
  wait_ms(1000);
  for(int tries=0; tries < 3; tries++){
	  sendCheckReply("AT", "OK",500);
	  wait_ms(100);
	  sendCheckReply("AT", "OK",500);
	  wait_ms(100);
	  sendCheckReply("AT", "OK",500);
	  wait_ms(100);

	  // turn off Echo!
	  sendCheckReply("ATE0", "OK",5000);
	  wait_ms(100);

	  if (! sendCheckReply("ATE0", "OK",5000)) {
	    continue;
	  }

	  if(getNetworkStatus()!=1){
		DEBUG_PRINT("Not registered to network yet\n");
		wait_ms(500);
		continue;
	 }
	 return true;
 }
  DEBUG_PRINT("Max num tries!\n");

  return false;
  
}
Ejemplo n.º 4
0
/** Constructor */
NetworkDialog::NetworkDialog(QWidget *parent)
: MainPage(parent), connectdialog(NULL)
{
  /* Invoke the Qt Designer generated object setup routine */
  ui.setupUi(this);

  connect( ui.connecttreeWidget, SIGNAL( customContextMenuRequested( QPoint ) ), this, SLOT( connecttreeWidgetCostumPopupMenu( QPoint ) ) );

  /* create a single connect dialog */
  connectdialog = new ConnectDialog();
  
  connect(ui.infoLog, SIGNAL(customContextMenuRequested(const QPoint&)), this, SLOT(displayInfoLogMenu(const QPoint&)));
  
  /* hide the Tree +/- */
  ui.connecttreeWidget -> setRootIsDecorated( false );
  
  /* Set header resize modes and initial section sizes */
	QHeaderView * _header = ui.connecttreeWidget->header () ;   
	_header->setResizeMode (0, QHeaderView::Custom);
	_header->setResizeMode (1, QHeaderView::Interactive);
	_header->setResizeMode (2, QHeaderView::Interactive);
	_header->setResizeMode (3, QHeaderView::Interactive);
	_header->setResizeMode (4, QHeaderView::Interactive);
	_header->setResizeMode (5, QHeaderView::Interactive);
	_header->setResizeMode (6, QHeaderView::Interactive);
	_header->setResizeMode (7, QHeaderView::Interactive);
	_header->setResizeMode (8, QHeaderView::Interactive);
	_header->setResizeMode (9, QHeaderView::Interactive);
    
	_header->resizeSection ( 0, 25 );
	_header->resizeSection ( 1, 100 );
	_header->resizeSection ( 2, 100 );
	_header->resizeSection ( 3, 100 );
	_header->resizeSection ( 4, 100 );
	_header->resizeSection ( 5, 200);
	_header->resizeSection ( 6, 100 );
	_header->resizeSection ( 7, 100 );
	_header->resizeSection ( 8, 100 );
	_header->resizeSection ( 9, 100 );
	
	// set header text aligment
	QTreeWidgetItem * headerItem = ui.connecttreeWidget->headerItem();
	headerItem->setTextAlignment(0, Qt::AlignHCenter | Qt::AlignVCenter);
	headerItem->setTextAlignment(1, Qt::AlignHCenter | Qt::AlignVCenter);
  headerItem->setTextAlignment(2, Qt::AlignHCenter | Qt::AlignVCenter);
	headerItem->setTextAlignment(3, Qt::AlignHCenter | Qt::AlignVCenter);
	headerItem->setTextAlignment(4, Qt::AlignHCenter | Qt::AlignVCenter);
	headerItem->setTextAlignment(5, Qt::AlignHCenter | Qt::AlignVCenter);
	headerItem->setTextAlignment(6, Qt::AlignHCenter | Qt::AlignVCenter);
	headerItem->setTextAlignment(7, Qt::AlignHCenter | Qt::AlignVCenter);
	headerItem->setTextAlignment(8, Qt::AlignHCenter | Qt::AlignVCenter);
	headerItem->setTextAlignment(9, Qt::AlignHCenter | Qt::AlignVCenter);
	
	/*networkview = new NetworkView(ui.networkviewTab);
	QVBoxLayout *layout = new QVBoxLayout;
	layout->addWidget(networkview);
	ui.networkviewTab->setLayout(layout);
	layout->setSpacing( 0 );
	layout->setMargin( 0 );*/

  ui.networkTab->addTab(new NetworkView(),QString(tr("Network View")));
	ui.networkTab->addTab(new TrustView(),QString(tr("Trust matrix")));
     
    // Set Log infos
    setLogInfo(tr("RetroShare %1 started.", "e.g: RetroShare v0.x started.").arg(retroshareVersion()));
    
    setLogInfo(tr("Welcome to RetroShare."), QString::fromUtf8("blue"));
      
    QMenu *menu = new QMenu(tr("View"));
    menu->addAction(ui.actionTabsright); 
    menu->addAction(ui.actionTabswest);
    menu->addAction(ui.actionTabssouth); 
    menu->addAction(ui.actionTabsnorth);
    menu->addSeparator();
    menu->addAction(ui.actionTabsTriangular); 
    menu->addAction(ui.actionTabsRounded);
    ui.viewButton->setMenu(menu);
    
    QTimer *timer = new QTimer(this);
    timer->connect(timer, SIGNAL(timeout()), this, SLOT(getNetworkStatus()));
    timer->start(100000);
    
    QTimer *timer2 = new QTimer(this);
    timer2->connect(timer, SIGNAL(timeout()), this, SLOT(updateNetworkStatus()));
    timer2->start(1000);
    
    getNetworkStatus();
    updateNetworkStatus();
    //load();
    

  /* Hide platform specific features */
#ifdef Q_WS_WIN

#endif
}