示例#1
0
int main(int argc, char *argv[])
{
    int type, chans;
    RadioDevice *usrp;
    RadioInterface *radio = NULL;
    Transceiver *trx = NULL;
    struct trx_config config;

    handle_options(argc, argv, &config);

    setup_signal_handlers();

    /* Check database sanity */
    if (!trx_setup_config(&config)) {
        std::cerr << "Config: Database failure - exiting" << std::endl;
        return EXIT_FAILURE;
    }

    gLogInit("transceiver", config.log_level.c_str(), LOG_LOCAL7);

    srandom(time(NULL));

    /* Create the low level device object */
    usrp = RadioDevice::make(config.sps, config.chans,
                             config.diversity, config.offset);
    type = usrp->open(config.dev_args, config.extref, config.swap_channels);
    if (type < 0) {
        LOG(ALERT) << "Failed to create radio device" << std::endl;
        goto shutdown;
    }

    /* Setup the appropriate device interface */
    radio = makeRadioInterface(&config, usrp, type);
    if (!radio)
        goto shutdown;

    /* Create the transceiver core */
    trx = makeTransceiver(&config, radio);
    if (!trx)
        goto shutdown;

    chans = trx->numChans();
    std::cout << "-- Transceiver active with "
              << chans << " channel(s)" << std::endl;

    while (!gshutdown)
        sleep(1);

shutdown:
    std::cout << "Shutting down transceiver..." << std::endl;

    delete trx;
    delete radio;
    delete usrp;

    return 0;
}
int main(int argc, char *argv[]) {

	SubscriberRegistry gHLR;

	gLogInit("HLRTest");
	gConfig.set("Log.Level","DEBUG");

	if (argc!=2) {
		std::cerr << "usage: " << argv[0] << " <number>" << std::endl;
		exit(-1);
	}
	const char *targ = argv[1];

	char *IMSI = gHLR.getIMSI(targ);
	if (IMSI) std::cout << "IMSI for " << targ << " is " << IMSI << std::endl;
	else std::cout << "no IMSI found for " << targ << std::endl;

	char *CLID = gHLR.getCLIDLocal(IMSI);
	if (CLID) std::cout << "CLID for " << IMSI << " is " << CLID << std::endl;
	else std::cout << "no CLID found for " << IMSI << std::endl;

	char *regIP = gHLR.getRegistrationIP("234100223456161");
	if (regIP) std::cout << "registration IP for " << IMSI << " is " << regIP << std::endl;
	else std::cout << "no regIP found for " << IMSI << std::endl;

	IMSI = gHLR.getIMSI(targ);
	if (IMSI) std::cout << "IMSI for " << targ << " is " << IMSI << std::endl;
	else std::cout << "no IMSI found for " << targ << std::endl;

	CLID = gHLR.getCLIDLocal(IMSI);
	if (CLID) std::cout << "CLID for " << IMSI << " is " << CLID << std::endl;
	else std::cout << "no CLID found for " << IMSI << std::endl;


	const char targ2[] = "1234567890";
	gHLR.addUser("123456789012345",targ2);

	sleep(2);

	IMSI = gHLR.getIMSI(targ2);
	if (IMSI) std::cout << "IMSI for " << targ2 << " is " << IMSI << std::endl;
	else std::cout << "no IMSI found for " << targ2 << std::endl;

	CLID = gHLR.getCLIDLocal(IMSI);
	if (CLID) std::cout << "CLID for " << IMSI << " is " << CLID << std::endl;
	else std::cout << "no CLID found for " << IMSI << std::endl;



}
示例#3
0
int main(int argc, char *argv[])
{
	gLogInit("NOTICE");

	LOG(ERROR) << " testing the logger.";
	LOG(WARN) << " testing the logger.";
	LOG(NOTICE) << " testing the logger.";
	LOG(INFO) << " testing the logger.";
	LOG(DEBUG) << " testing the logger.";
	LOG(DEEPDEBUG) << " testing the logger.";
    std::cout << "\n\n\n";
    std::cout << "testing Alarms - you should run apps/showalarms.py to check udp\n";
	LOG(ALARM) << " testing the logger alarm.";
    std::cout << "you should see one line:" << std::endl;
    printAlarms();
    std::cout << "----------- generating 20 alarms ----------" << std::endl;
    for (int i = 0 ; i < 20 ; ++i) {
        LOG(ALARM) << i;
    }
    std::cout << "you should see ten line with the numbers 10..19:" << std::endl;
    printAlarms();
}
示例#4
0
// For best effects, run this program thrice: once with a pre-created
// /var/run/argv.pid, and once without.  First one should exit with an
// error. Second should run this test.  Third, with an argument, then type
// Control-C.
int main(int argc, char *argv[])
{
    int ret;
    gLogInit("SelfDetectTest","DEBUG",LOG_LOCAL7);
    gSelf.RegisterProgram(argv[0]);

    ret = system("touch /tmp/foo.1");
    ret = system("touch /tmp/foo.2");
    ret = system("touch /tmp/foo.3");
    ret = system("touch /tmp/foo.4");
    ret = system("touch /tmp/foo.5");
    ret = system("touch /tmp/foo.6");
    ret = system("touch /tmp/foo.7");
    if (ret < 0) { ret = ret; } // warning eater

    gSelf.RegisterFile("/tmp/foo.0"); // ignored
    gSelf.RegisterFile("/tmp/foo.1"); // removed
    gSelf.RegisterFile("/tmp/foo.2"); // removed
    gSelf.RegisterFile("/tmp/foo.3"); // removed
    gSelf.RegisterFile("/tmp/foo.4"); // removed
    gSelf.RegisterFile("/tmp/foo.5"); // removed
    gSelf.RegisterFile("/tmp/foo.6"); // removed
    gSelf.RegisterFile("/tmp/foo.7"); // removed
    gSelf.RegisterFile("/tmp/foo.8"); // ignored
    gSelf.RegisterFile("/tmp/foo.9"); // ignored

    if (argv[1] != NULL)
    {
    	printf("Use a Control-C to test in this mode, make sure\n");
	printf("that the file goes away\n");
	while(1)
	    sleep(60);
    }

    return 0;
}
示例#5
0
int main(int argc, char *argv[])
{
	int i, chanM, numARFCN = 1;
	int chanMap[CHAN_MAX];
	RadioDevice *usrp;
	RadioInterface* radio;
	DriveLoop *drive;
	Transceiver *trx[CHAN_MAX];

	gLogInit("transceiver", gConfig.getStr("Log.Level").c_str(), LOG_LOCAL7);

	if (argc > 1) {
		numARFCN = atoi(argv[1]);
		if (numARFCN > (CHAN_MAX - 1)) {
			LOG(ALERT) << numARFCN << " channels not supported with current build";
			exit(-1);
		}
	}

	srandom(time(NULL));

	if (setupSignals() < 0) {
		LOG(ERR) << "Failed to setup signal handlers, exiting...";
		exit(-1);
	}

	/*
	 * Select the number of channels according to the number of ARFCNs's
	 * and generate ARFCN-to-channelizer path mappings. The channelizer
	 * aliases and extracts 'M' equally spaced channels to baseband. The
	 * number of ARFCN's must be less than the number of channels in the
	 * channelizer.
	 */
	switch (numARFCN) {
	case 1:
		chanM = 1;
		break;
	case 2:
	case 3:
		chanM = 5;
		break;
	default:
		chanM = 10;
	}
	genChanMap(numARFCN, chanM, chanMap);

	/* Find a timing offset based on the channelizer configuration */
	double rxOffset = getRadioOffset(chanM);
	if (rxOffset == 0.0f) {
		LOG(ALERT) << "Rx sample offset not found, using offset of 0.0s";
		LOG(ALERT) << "Rx burst timing may not be accurate"; 
	}

	double deviceRate = chanM * CHAN_RATE * DEV_RESAMP_OUTRATE / DEV_RESAMP_INRATE;
	usrp = RadioDevice::make(deviceRate, rxOffset, DEVICE_TX_AMPL / numARFCN);
	if (!usrp->open()) {
		LOG(ALERT) << "Failed to open device, exiting...";
		return EXIT_FAILURE;
	}

	radio = new RadioInterface(usrp, chanM, 3, SAMPSPERSYM, 0, false);
	drive = new DriveLoop(5700, "127.0.0.1", chanM, chanMap[0],
			      SAMPSPERSYM, GSM::Time(3,0), radio);

	/* Create, attach, and activate all transceivers */
	createTrx(trx, chanMap, numARFCN, radio, drive);

	while (!gbShutdown) { 
		sleep(1);
	}

	LOG(NOTICE) << "Shutting down transceivers...";
	for (i = 0; i < numARFCN; i++) {
		trx[i]->shutdown();
	}

	/*
	 * Allow time for threads to end before we start freeing objects
	 */
	sleep(2);

	for (i = 0; i < numARFCN; i++) {
		delete trx[i];
	}

	delete drive;
	delete radio;
	delete usrp;
}