/************************************************************************* * FUNCTION * DclIRDA_Initialize * * DESCRIPTION * This function is to initialize IRDA module. * * PARAMETERS * DCL_STATUS_OK * STATUS_UNSUPPORTED - IrDA is not supported or enabled. * * RETURNS * none * *************************************************************************/ DCL_STATUS DclIRDA_Initialize(void) { extern kal_bool irda_init(void); #ifdef __IRDA_SUPPORT__ irda_init(INDX_IRDA); //the task_indx does not be handled in init function. return STATUS_OK; #else // __IRDA_SUPPORT__ return STATUS_UNSUPPORTED; #endif // __IRDA_SUPPORT__ }
void ICACHE_FLASH_ATTR mod_irda_init() { uint8 addr = 0; i2c_status status; irda_init(&addr, &status); uint8 i; for (i=0; i<MOD_IRDA_URLs_COUNT; i++) { webserver_register_handler_callback(MOD_IRDA_URLs[i], mod_irda_handler); } device_register(I2C, MOD_IRDA_ID, MOD_IRDA_URL); }
int main(int argc, char ** argv) { int exit = 0; int rv; /* Setup Logging */ smartid_log_open(); /* Process Options */ rv = smartid_parse_args(argc, argv, & exit); if (exit || (rv != 0)) { return rv; } /* Daemonize */ if (g_fork) { FILE * fp_pid; pid_t pid = 0; pid_t sid = 0; /* Fork the Process */ pid = fork(); if (pid < 0) { fprintf(stderr, "Error: fork() failed (code %d: %s)", errno, strerror(errno)); return 1; } if (pid > 0) { /* Kill the Parent Process */ return 0; } /* Setup the Daemon */ umask(0); chdir("/"); pid = getpid(); sid = setsid(); if (sid < 0) { smartid_log_syserror("setsid() failed in child"); return 1; } /* Write the PID to disk */ fp_pid = fopen(g_pidfile, "w"); if (! fp_pid) { smartid_log_syserror("fopen() failed for pid file '%s'", g_pidfile); return 1; } fprintf(fp_pid, "%lu", pid); fflush(fp_pid); fclose(fp_pid); /* Close Standard I/O */ close(STDIN_FILENO); close(STDOUT_FILENO); close(STDERR_FILENO); } /* Setup IrDA */ rv = irda_init(); if (rv != 0) { smartid_log_error("Failed to initialize IrDA (code %d: %s)", irda_errcode(), irda_errmsg()); return rv; } /* Initialize and Run Smart-I Daemon */ smartid_log_info("%s/%s (%s)", SMARTID_APP_NAME, SMARTID_VERSION_STRING, SMARTID_MACHINE); rv = smartid_run(); irda_cleanup(); smartid_log_info("%s is exiting (code %d)", SMARTID_APP_TITLE, rv); return rv; }
int plugin_load() { return irda_init(); }