CAResult_t CAEDRInitializeNetworkMonitor(const ca_thread_pool_t threadPool) { OIC_LOG(DEBUG, EDR_ADAPTER_TAG, "IN"); // Initialize Bluetooth service int err = bt_initialize(); if (BT_ERROR_NONE != err) { OIC_LOG_V(ERROR, EDR_ADAPTER_TAG, "Bluetooth initialization failed!, error num [%x]", err); return CA_STATUS_FAILED; } OIC_LOG(DEBUG, EDR_ADAPTER_TAG, "OUT"); return CA_STATUS_OK; }
int main (int argc, char **argv) { char * filename; boolean ok; if (argc != 2) { fprintf (stderr, Usage); fprintf (stderr, "Wrong number of arguments\n"); exit (1); } bt_initialize (); filename = argv[1]; ok = process_file (filename); bt_cleanup (); exit (ok ? 0 : 1); }
void main() { bt_initialize(); trace_initialize(); i386_initialize_descriptor_tables(); i8259_initialize(); exceptions_initialize(); timer_initialize(); mem_initialize(); dma_initialize(); keyboard_initialize(); floppy_initialize(); tty_initialize(); sys_initialize(); loader_initialize(); clear_display(); printk("Start running processes!!!\nStartup Communications\n Press ALT-LSHIFT for next terminal\n"); i8259_start(); while(1); }
static int __init bt_osl_init (void) { acpi_status status = AE_OK; /* abort if no busmgr */ if (!bm_proc_root) return -ENODEV; bt_proc_root = proc_mkdir(BT_PROC_ROOT, bm_proc_root); if (!bt_proc_root) { status = AE_ERROR; } else { status = bt_initialize(); if (ACPI_FAILURE(status)) { remove_proc_entry(BT_PROC_ROOT, bm_proc_root); } } return (ACPI_SUCCESS(status)) ? 0 : -ENODEV; }
CAResult_t CAInitializeLE(CARegisterConnectivityCallback registerCallback, CANetworkPacketReceivedCallback reqRespCallback, CANetworkChangeCallback netCallback) { OCLog(DEBUG, CALEADAPTER_TAG, "IN"); //Input validation VERIFY_NON_NULL(registerCallback, NULL, "RegisterConnectivity callback is null"); VERIFY_NON_NULL(reqRespCallback, NULL, "PacketReceived Callback is null"); VERIFY_NON_NULL(netCallback, NULL, "NetworkChange Callback is null"); #ifdef __TIZEN__ int ret = bt_initialize(); if (0 != ret) { OCLog(ERROR, CALEADAPTER_TAG, "bt_initialize failed!"); return CA_STATUS_FAILED; } #endif //#ifdef __TIZEN__ CASetBLEReqRescallback(reqRespCallback); CALERegisterNetworkNotifications(netCallback); CAConnectivityHandler_t connHandler; connHandler.startListenServer = CAStartLEListeningServer; connHandler.startDiscoverServer = CAStartLEDiscoveryServer; connHandler.sendData = CASendLEUnicastData; connHandler.sendDataToAll = CASendLEMulticastData; connHandler.startNotifyServer = CAStartLENotifyServer; connHandler.sendNotification = CASendLENotification; connHandler.GetnetInfo = CAGetLEInterfaceInformation; connHandler.readData = CAReadLEData; connHandler.terminate = CATerminateLE; registerCallback(connHandler, CA_LE); OCLog(DEBUG, CALEADAPTER_TAG, "OUT"); return CA_STATUS_OK; }
CAResult_t CAEDRStartNetworkMonitor() { OIC_LOG(DEBUG, EDR_ADAPTER_TAG, "IN"); // Initialize Bluetooth service int ret = bt_initialize(); if (BT_ERROR_NONE != ret) { OIC_LOG_V(ERROR, EDR_ADAPTER_TAG, "Bluetooth initialization failed!, error num [%x]", ret); return; } ret = bt_adapter_set_state_changed_cb(CAEDRAdapterStateChangeCallback, NULL); if(BT_ERROR_NONE != ret) { OIC_LOG(ERROR, EDR_ADAPTER_TAG, "bt_adapter_set_state_changed_cb failed"); return; } OIC_LOG(DEBUG, EDR_ADAPTER_TAG, "OUT"); return CA_STATUS_OK; }
CAResult_t CAEDRStartNetworkMonitor() { OIC_LOG(DEBUG, EDR_ADAPTER_TAG, "IN"); g_mainloop = g_main_loop_new(NULL, 0); if(!g_mainloop) { OIC_LOG(ERROR, EDR_ADAPTER_TAG, "g_main_loop_new failed\n"); return CA_STATUS_FAILED; } if (CA_STATUS_OK != ca_thread_pool_add_task(g_threadPoolHandle, GMainLoopThread, (void *) NULL)) { OIC_LOG(ERROR, EDR_ADAPTER_TAG, "Failed to create thread!"); return CA_STATUS_FAILED; } // Initialize Bluetooth service int err = bt_initialize(); if (BT_ERROR_NONE != err) { OIC_LOG_V(ERROR, EDR_ADAPTER_TAG, "Bluetooth initialization failed!, error num [%x]", err); return CA_STATUS_FAILED; } int ret = bt_adapter_set_state_changed_cb(CAEDRAdapterStateChangeCallback, NULL); if(BT_ERROR_NONE != ret) { OIC_LOG(ERROR, EDR_ADAPTER_TAG, "bt_adapter_set_state_changed_cb failed"); return CA_STATUS_FAILED; } OIC_LOG(DEBUG, EDR_ADAPTER_TAG, "OUT"); return CA_STATUS_OK; }
int rhtf_initialize_bluetooth(const char *device_name) { // Initialize bluetooth and get adapter state __COMMON_FUNC_ENTER__; int ret; ret = bt_initialize(); if(ret != BT_ERROR_NONE) { MIN_LOG("Unknown exception is occured in bt_initialize(): %x", ret); return -1; } ret = bt_adapter_get_state(&gBtState); if(ret != BT_ERROR_NONE) { MIN_LOG("Unknown exception is occured in bt_adapter_get_state(): %x", ret); return -2; } // Enable bluetooth device manually if(gBtState == BT_ADAPTER_DISABLED) { MIN_LOG("[%s] bluetooth is not enabled.", __FUNCTION__); return -3; } else { MIN_LOG("[%s] BT was already enabled.", __FUNCTION__); } // Set adapter's name if(gBtState == BT_ADAPTER_ENABLED) { char *name = NULL; ret = bt_adapter_get_name(&name); if(name == NULL) { MIN_LOG("NULL name exception is occured in bt_adapter_get_name(): %x", ret); return -5; } if(strncmp(name, device_name, strlen(name)) != 0) { if(bt_adapter_set_name(device_name) != BT_ERROR_NONE) { if (NULL != name) free(name); MIN_LOG("Unknown exception is occured in bt_adapter_set_name : %x", ret); return -6; } } free(name); } else { MIN_LOG("Bluetooth is not enabled"); return -7; } /* No need to visualize the device when connecting as a client // Set visibility as BT_ADAPTER_VISIBILITY_MODE_GENERAL_DISCOVERABLE if(bt_adapter_get_visibility(&gVisibilityMode, NULL) != BT_ERROR_NONE) { LOGE("[%s] bt_adapter_get_visibility() failed.", __FUNCTION__); return -11; } if(gVisibilityMode != BT_ADAPTER_VISIBILITY_MODE_GENERAL_DISCOVERABLE) { if(bt_adapter_set_visibility(BT_ADAPTER_VISIBILITY_MODE_GENERAL_DISCOVERABLE, 0) != BT_ERROR_NONE) { LOGE("[%s] bt_adapter_set_visibility() failed.", __FUNCTION__); return -12; } gVisibilityMode = BT_ADAPTER_VISIBILITY_MODE_GENERAL_DISCOVERABLE; } else { LOGI("[%s] Visibility mode was already set as BT_ADAPTER_VISIBILITY_MODE_GENERAL_DISCOVERABLE.", __FUNCTION__); } */ // Connecting socket as a client ret = bt_socket_set_connection_state_changed_cb(rhtf_socket_connection_state_changed_cb, NULL); if(ret != BT_ERROR_NONE) { MIN_LOG("Unknown exception is occured in bt_socket_set_connection_state_changed_cb(): %x", ret); __COMMON_FUNC_EXIT__; return -9; } ret = bt_socket_set_data_received_cb(rhtf_received_data_cb, NULL); if(ret != BT_ERROR_NONE) { MIN_LOG("Unknown exception is occured in bt_socket_set_data_received_cb(): %x", ret); __COMMON_FUNC_EXIT__; return -10; } __COMMON_FUNC_EXIT__; return 0; }
int FC_MAIN(int argc,char **argv) { MDL mdl; MSR msr; FILE *fpLog = NULL; char achFile[256]; /*DEBUG use MAXPATHLEN here (& elsewhere)? -- DCR*/ double dTime; double E=0,T=0,U=0,Eth=0,L[3]={0,0,0},F[3]={0,0,0},W=0; double dMultiEff=0; long lSec=0,lStart; int i,iStep,iSec=0,iStop=0; uint64_t nActive; #ifdef TINY_PTHREAD_STACK static int first = 1; static char **save_argv; /* * Hackery to get around SGI's tiny pthread stack. * Main will be called twice. The second time, argc and argv * will be garbage, so we have to save them from the first. * Another way to do this would involve changing the interface * to mdlInitialize(), so that this hackery could be hidden * down there. */ if (first) { save_argv = malloc((argc+1)*sizeof(*save_argv)); for (i = 0; i < argc; i++) save_argv[i] = strdup(argv[i]); save_argv[argc] = NULL; } else { argv = save_argv; } first = 0; #endif /* TINY_PTHREAD_STACK */ #ifdef USE_BT bt_initialize(); #endif #ifdef ENABLE_FE feenableexcept(FE_INVALID|FE_DIVBYZERO|FE_OVERFLOW); #endif #ifndef CCC /* no stdout buffering */ setbuf(stdout,(char *) NULL); #endif lStart=time(0); #ifdef USE_MDL_IO mdlInitialize(&mdl,argv,main_ch,main_io); #else mdlInitialize(&mdl,argv,main_ch,0); #endif for (argc = 0; argv[argc]; argc++); /* some MDLs can trash argv */ printf("%s\n", PACKAGE_STRING ); msrInitialize(&msr,mdl,argc,argv); /* ** Establish safety lock. */ if (!msrGetLock(msr)) { msrFinish(msr); mdlFinish(mdl); return 1; } /* ** Output the host names to make troubleshooting easier */ msrHostname(msr); /* ** Read in the binary file, this may set the number of timesteps or ** the size of the timestep when the zto parameter is used. */ #ifdef USE_GRAFIC if (prmSpecified(msr->prm,"nGrid")) { dTime = msrGenerateIC(msr); msrInitStep(msr); if (prmSpecified(msr->prm,"dSoft")) msrSetSoft(msr,msrSoft(msr)); } else { #endif if ( msr->param.achInFile[0] ) { dTime = msrRead(msr,msr->param.achInFile); msrInitStep(msr); if (msr->param.bAddDelete) msrGetNParts(msr); if (prmSpecified(msr->prm,"dRedFrom")) { double aOld, aNew; aOld = csmTime2Exp(msr->param.csm,dTime); aNew = 1.0 / (1.0 + msr->param.dRedFrom); dTime = msrAdjustTime(msr,aOld,aNew); /* Seriously, we shouldn't need to send parameters *again*. When we remove sending parameters, we should remove this. */ msrInitStep(msr); } if (prmSpecified(msr->prm,"dSoft")) msrSetSoft(msr,msrSoft(msr)); } else { #ifdef USE_PYTHON if ( !msr->param.achScriptFile[0] ) { #endif printf("No input file specified\n"); return 1; } #ifdef USE_PYTHON } #endif #ifdef USE_GRAFIC } #endif if ( msr->param.bWriteIC ) { msrBuildIoName(msr,achFile,0); msrWrite( msr,achFile,dTime,msr->param.bWriteIC-1); } /* ** Now we have all the parameters for the simulation we can make a ** log file entry. */ if (msrLogInterval(msr)) { sprintf(achFile,"%s.log",msrOutName(msr)); fpLog = fopen(achFile,"a"); assert(fpLog != NULL); setbuf(fpLog,(char *) NULL); /* no buffering */ /* ** Include a comment at the start of the log file showing the ** command line options. */ fprintf(fpLog,"# "); for (i=0;i<argc;++i) fprintf(fpLog,"%s ",argv[i]); fprintf(fpLog,"\n"); msrLogParams(msr,fpLog); } #ifdef USE_PYTHON /* If a script file was specified, enter analysis mode */ if ( msr->param.achScriptFile[0] ) iStep = 0; else #endif iStep = msrSteps(msr); if (iStep > 0) { if (msrComove(msr)) { msrSwitchTheta(msr,dTime); } /* ** Build tree, activating all particles first (just in case). */ msrActiveRung(msr,0,1); /* Activate all particles */ msrDomainDecomp(msr,0,1,0); msrUpdateSoft(msr,dTime); msrBuildTree(msr,dTime,msr->param.bEwald); if (msrDoGravity(msr)) { msrGravity(msr,0,MAX_RUNG,dTime,msr->param.iStartStep,msr->param.bEwald,&iSec,&nActive); msrMemStatus(msr); if (msr->param.bGravStep) { msrBuildTree(msr,dTime,msr->param.bEwald); msrGravity(msr,0,MAX_RUNG,dTime,msr->param.iStartStep,msr->param.bEwald,&iSec,&nActive); msrMemStatus(msr); } } if (msrDoGas(msr)) { /* Initialize SPH, Cooling and SF/FB and gas time step */ #ifdef COOLING msrCoolSetup(msr,dTime); #endif /* Fix dTuFac conversion of T in InitSPH */ msrInitSph(msr,dTime); } msrCalcEandL(msr,MSR_INIT_E,dTime,&E,&T,&U,&Eth,L,F,&W); dMultiEff = 1.0; if (msrLogInterval(msr)) { (void) fprintf(fpLog,"%e %e %.16e %e %e %e %.16e %.16e %.16e " "%.16e %.16e %.16e %.16e %i %e\n",dTime, 1.0/csmTime2Exp(msr->param.csm,dTime)-1.0, E,T,U,Eth,L[0],L[1],L[2],F[0],F[1],F[2],W,iSec,dMultiEff); } #ifdef PLANETS if (msr->param.bHeliocentric) { msrGravSun(msr); } #ifdef SYMBA msrDriftSun(msr,dTime,0.5*msrDelta(msr)); #endif #endif if ( msr->param.bTraceRelaxation) { msrInitRelaxation(msr); } #ifdef HERMITE if (msr->param.bHermite) { msrActiveRung(msr,0,1); /* Activate all particles */ msrCopy0(msr, dTime); if (msr->param.bAarsethStep) { msrFirstDt(msr); } } #endif for (iStep=msr->param.iStartStep+1;iStep<=msrSteps(msr)&&!iStop;++iStep) { if (msrComove(msr)) { msrSwitchTheta(msr,dTime); } dMultiEff = 0.0; lSec = time(0); #ifdef HERMITE if (msr->param.bHermite) { msrTopStepHermite(msr,iStep-1,dTime, msrDelta(msr),0,0,msrMaxRung(msr),1, &dMultiEff,&iSec); } else #endif #ifdef SYMBA if (msr->param.bSymba) { msrTopStepSymba(msr,iStep-1,dTime, msrDelta(msr),0,0,msrMaxRung(msr),1, &dMultiEff,&iSec); } else #endif { msrTopStepKDK(msr,iStep-1,dTime, msrDelta(msr),0,0,msrMaxRung(msr),1, &dMultiEff,&iSec); } dTime += msrDelta(msr); lSec = time(0) - lSec; msrMemStatus(msr); /* ** Output a log file line if requested. ** Note: no extra gravity calculation required. */ if (msrLogInterval(msr) && iStep%msrLogInterval(msr) == 0) { msrCalcEandL(msr,MSR_STEP_E,dTime,&E,&T,&U,&Eth,L,F,&W); (void) fprintf(fpLog,"%e %e %.16e %e %e %e %.16e %.16e " "%.16e %.16e %.16e %.16e %.16e %li %e\n",dTime, 1.0/csmTime2Exp(msr->param.csm,dTime)-1.0, E,T,U,Eth,L[0],L[1],L[2],F[0],F[1],F[2],W,lSec,dMultiEff); } if ( msr->param.bTraceRelaxation) { msrActiveRung(msr,0,1); /* Activate all particles */ msrDomainDecomp(msr,0,1,0); msrBuildTree(msr,dTime,0); msrRelaxation(msr,dTime,msrDelta(msr),SMX_RELAXATION,0); } /* ** Check for user interrupt. */ iStop = msrCheckForStop(msr); /* ** Check to see if the runtime has been exceeded. */ if (!iStop && msr->param.iWallRunTime > 0) { if (msr->param.iWallRunTime*60 - (time(0)-lStart) < ((int) (lSec*1.5)) ) { printf("RunTime limit exceeded. Writing checkpoint and exiting.\n"); printf(" iWallRunTime(sec): %d Time running: %ld Last step: %ld\n", msr->param.iWallRunTime*60,time(0)-lStart,lSec); iStop = 1; } } /* ** Output if 1) we've hit an output time ** 2) We are stopping ** 3) we're at an output interval */ if (msrOutTime(msr,dTime) || iStep == msrSteps(msr) || iStop || (msrOutInterval(msr) > 0 && iStep%msrOutInterval(msr) == 0) || (msrCheckInterval(msr) > 0 && iStep%msrCheckInterval(msr) == 0)) { msrOutput(msr,iStep,dTime, msrCheckInterval(msr)>0 && (iStep%msrCheckInterval(msr) == 0 || iStep == msrSteps(msr) || iStop)); } } } /* No steps were requested */ else { #ifdef USE_PYTHON if ( msr->param.achScriptFile[0] ) { PPY ppy; ppyInitialize(&ppy,msr,dTime); msr->prm->script_argv[0] = msr->param.achScriptFile; ppyRunScript(ppy,msr->prm->script_argc,msr->prm->script_argv); ppyFinish(ppy); } else { #endif if (msrDoGravity(msr) ||msrDoGas(msr)) { msrActiveRung(msr,0,1); /* Activate all particles */ msrDomainDecomp(msr,0,1,0); msrUpdateSoft(msr,dTime); msrBuildTree(msr,dTime,msr->param.bEwald); if (msrDoGravity(msr)) { msrGravity(msr,0,MAX_RUNG,dTime,msr->param.iStartStep,msr->param.bEwald,&iSec,&nActive); msrMemStatus(msr); if (msr->param.bGravStep) { msrBuildTree(msr,dTime,msr->param.bEwald); msrGravity(msr,0,MAX_RUNG,dTime,msr->param.iStartStep,msr->param.bEwald,&iSec,&nActive); msrMemStatus(msr); } } if (msrDoGas(msr)) { /* Initialize SPH, Cooling and SF/FB and gas time step */ #ifdef COOLING msrCoolSetup(msr,dTime); #endif /* Fix dTuFac conversion of T in InitSPH */ msrInitSph(msr,dTime); } msrUpdateRung(msr,0); /* set rungs for output */ msrCalcEandL(msr,MSR_INIT_E,dTime,&E,&T,&U,&Eth,L,F,&W); dMultiEff = 1.0; if (msrLogInterval(msr)) { (void) fprintf(fpLog,"%e %e %.16e %e %e %e %.16e %.16e " "%.16e %.16e %.16e %.16e %.16e %i %e\n",dTime, 1.0/csmTime2Exp(msr->param.csm,dTime)-1.0, E,T,U,Eth,L[0],L[1],L[2],F[0],F[1],F[2],W,iSec,dMultiEff); } } msrOutput(msr,0,dTime,0); /* JW: Will trash gas density */ #ifdef USE_PYTHON } #endif } if (msrLogInterval(msr)) (void) fclose(fpLog); #ifdef PP_SIMD_BENCHMARK PPDumpStats(); #endif msrFinish(msr); mdlFinish(mdl); return 0; }