int32_t fs_opr_t::record(const char* uuid, const char* file, uint32_t time_s) { FUNC_BEGIN(); std::string full_file = _recordbase; full_file += "/"; full_file += file; TRACE_LOG("fs::record(%s) start.", full_file.c_str()); //set_channel_attribute(uuid,"playback_terminators=none"); //set_channel_attribute(uuid,"RECORD_HANGUP_ON_ERROR=false");//1.0.7的fs才有 //set_channel_attribute(uuid,"RECORD_MIN_SEC=0"); //TRACE_LOG("fs::record(%s) middle.",full_file.c_str()); snprintf(szcmd, LEN_512, CMD_RECORD_FMT, uuid, full_file.c_str(), time_s); //if(esl_send_recv(&_handle,szcmd)==ESL_SUCCESS){ // if(is_result_ok(fs_resp=esl_event_get_body(_handle.last_sr_event))){ // ret=IMS_SUCCESS; // } // else{ // WARNING_LOG("fs:record(%s,%s,%u);ret(%s)",uuid,full_file.c_str(),time_s,fs_resp); // } //} if (esl_send_recv(&_handle, szcmd) == ESL_SUCCESS && is_result_ok(fs_resp = esl_event_get_header(_handle.last_sr_event, "Reply-Text"))) { ret = IMS_SUCCESS; } else { WARNING_LOG("fs:record(%s,%s,%u) esl_send_recv != ESL_SUCCESS", uuid, full_file.c_str(), time_s); } //TRACE_LOG("fs::record(%s) done.",full_file.c_str()); FUNC_END(); }
int32_t fs_opr_t::eval(const char* key, char* val, uint32_t val_len) { FUNC_BEGIN(); snprintf(szcmd, LEN_512, "api eval %s\n\n", key); TRACE_LOG("eval, (%s)", szcmd); if (esl_send_recv(&_handle, szcmd) == ESL_SUCCESS && (fs_resp = esl_event_get_body(_handle.last_sr_event))) { strncpy(val, fs_resp, val_len); fs_resp = val; while (fs_resp && *fs_resp && (fs_resp - val) < val_len) { if ('\n' == *fs_resp || '\r' == *fs_resp) { val[fs_resp - val] = '\0'; break; } ++fs_resp; } ret = IMS_SUCCESS; } else { WARNING_LOG("fs_eval(%s) failed", key); } FUNC_END(); }
static int msr3110_dev_release( struct inode *inode, struct file *filp) { FUNC_START(); FUNC_END(); return 0; }
int32_t fs_opr_t::bridge(const char* uuid, const char* called_disp, const char* dnis) { FUNC_BEGIN(); if (set_channel_attribute(uuid, "bridge_early_media=true") && set_channel_attribute(uuid, "hangup_after_bridge=false") && set_channel_attribute(uuid, "bypass_media=false") && set_channel_attribute(uuid, "playback_terminators=none") && set_channel_attribute(uuid, "continue_on_fail=true")) { set_channel_attribute(uuid, "export_vars=IMSDATA"); snprintf(szcmd, LEN_512, "effective_caller_id_name=%s", called_disp); set_channel_attribute(uuid, szcmd); snprintf(szcmd, LEN_512, "effective_caller_id_number=%s", called_disp); set_channel_attribute(uuid, szcmd); if (esl_execute(&_handle, "bridge", dnis, uuid) == ESL_SUCCESS && is_result_ok(fs_resp = esl_event_get_header(_handle.last_sr_event, "Reply-Text"))) { ret = IMS_SUCCESS; break; } else { WARNING_LOG("fs:bridge(%s,%s,%s);ret(%s)", uuid, called_disp, dnis, fs_resp); } } FUNC_END(); }
void livecdfs_free(void *fs) { FUNC_START("fs=%p", fs); LiveCDFS::destroy((LiveCDFS*)fs); FUNC_END(); }
int32_t fs_opr_t::subscribe_event(const char* event) { FUNC_BEGIN(); (void)szcmd; (void)fs_resp; if (esl_events(&_handle, ESL_EVENT_TYPE_PLAIN, event) == ESL_SUCCESS) { TRACE_LOG("subscribe_event %s success", event); ret = IMS_SUCCESS; break; } else { WARNING_LOG("subscribe_event %s failed(connect err)", event); ims_tool_t::safe_sleepms(20); } /* if(is_handle_valid()){ ret=IMS_FAIL_TIMEOUT; break; } else if(IMS_SUCCESS!=connect(_address,_port,_pswd,true)){ WARNING_LOG("subscribe_event %s failed(connect err)",event); ret=IMS_FAIL_CONNECT; break; } */ FUNC_END(); }
int32_t fs_opr_t::get_var(const char* key, char* val, uint32_t val_len) { FUNC_BEGIN(); (void)fs_resp; snprintf(szcmd, LEN_512, "variable_%s", key); ret = get_head_val(szcmd, val, val_len); FUNC_END(); }
void livecdfs_umount(void *fs) { FUNC_START("fs=%p", fs); ((LiveCDFS*)fs)->doUmount(); FUNC_END(); }
static int nfc_remove(struct i2c_client *client) { FUNC_START(); nfc_client = NULL; FUNC_END(); return 0; }
LiveCDFS::~LiveCDFS() { FUNC_START("~destructor"); delete path; delete whiteout; delete handles; FUNC_END(); }
/////////////////////////////////////媒体START///////////////////////////////////////////////// int32_t fs_opr_t::stop_media(const char* uuid) { FUNC_BEGIN(); (void)szcmd; if (esl_execute(&_handle, "break", NULL, uuid) == ESL_SUCCESS && is_result_ok(fs_resp = esl_event_get_header(_handle.last_sr_event, "Reply-Text"))) { ret = IMS_SUCCESS; } else { WARNING_LOG("fs:stop_media(%s);ret(%s)", uuid, fs_resp); } FUNC_END(); }
int32_t fs_opr_t::mark_sessionid(const char* uuid, uint64_t sid) { FUNC_BEGIN(); snprintf(szcmd, LEN_512, "IMSDATA=%lu", sid); if (set_channel_attribute(uuid, szcmd) && is_result_ok(fs_resp = esl_event_get_header(_handle.last_sr_event, "Reply-Text"))) { ret = IMS_SUCCESS; } else { WARNING_LOG("fs_opr:mark_sessionid(%s,%lu);ret(%s)", uuid, sid, fs_resp); } FUNC_END(); }
int32_t fs_opr_t::conference(const char* uuid, const char* name) { FUNC_BEGIN(); (void)szcmd; if (esl_execute(&_handle, "conference", name, uuid) == ESL_SUCCESS && is_result_ok(fs_resp = esl_event_get_header(_handle.last_sr_event, "Reply-Text"))) { ret = IMS_SUCCESS; } else { WARNING_LOG("fs:conference(%s,%s);ret(%s)", uuid, name, fs_resp); } FUNC_END(); }
//============================= // MotorTest // // Turn a motor connected to port // armPort at a speed of armSpeed // for waitTime seconds //============================= void MotorTest( int portNum, int motorSpeed, float waitTime ) { FUNC_BEGIN("MotorTest"); if (waitTime < 1) printf("WARNING: waitTime is lower than 1 second: %f\n", waitTime); Motor(portNum, motorSpeed); wait( waitTime ); Motor(portNum, MOTOR_OFF); FUNC_END("MotorTest"); }
static int nfc_probe(struct i2c_client *client, const struct i2c_device_id *id) { FUNC_START(); my_pr_debug( "%s clinet 0x%p id %s", __func__, client, id->name); adapter = to_i2c_adapter( client->dev.parent); my_pr_debug( "%s master tx 0x%p id %s", __func__, client->adapter->algo->master_xfer, id->name); my_pr_debug( "%s master tx 0x%p id %s", __func__, adapter->algo->master_xfer, id->name); nfc_client = client; my_pr_err( "%s nfc_client->ext_flag: %d", __func__, nfc_client->ext_flag); FUNC_END(); return 0; }
int32_t fs_opr_t::unbridge(const char* uuid) { FUNC_BEGIN(); snprintf(szcmd, LEN_512, CMD_UNBRIDGE_FMT, uuid); TRACE_LOG("unbridge(%s)", szcmd); if (esl_send_recv(&_handle, szcmd) == ESL_SUCCESS) { if (is_result_ok(fs_resp = esl_event_get_body(_handle.last_sr_event))) { ret = IMS_SUCCESS; } else { WARNING_LOG("fs:unbridge(%s);ret(%s)", uuid, fs_resp); } } FUNC_END(); }
int32_t fs_opr_t::play(const char* uuid, const char* file, uint32_t count) { FUNC_BEGIN(); (void)szcmd; if (set_channel_attribute(uuid, "playback_terminators=none") && esl_execute(&_handle, "playback", file, uuid) == ESL_SUCCESS && is_result_ok(fs_resp = esl_event_get_header(_handle.last_sr_event, "Reply-Text"))) { ret = IMS_SUCCESS; TRACE_LOG("fs:play(%s,%s,%u) success.", uuid, file, count); } else { WARNING_LOG("fs:play(%s,%s,%u);ret(%s)", uuid, file, count, fs_resp); } FUNC_END(); }
int32_t fs_opr_t::conference_mute(const char* name, const char* member) { FUNC_BEGIN(); snprintf(szcmd, LEN_512, "api conference %s mute %s\n\n", name, member); TRACE_LOG("conference_mute(%s)", szcmd); if (esl_send_recv(&_handle, szcmd) == ESL_SUCCESS) { if (is_result_ok(fs_resp = esl_event_get_body(_handle.last_sr_event))) { ret = IMS_SUCCESS; } else { WARNING_LOG("fs:conference_mute (%s,%s);ret(%s)", name, member, fs_resp); } } FUNC_END(); }
int32_t fs_opr_t::bridge_ex(const char* uuid, const char* called_disp, const char* dnis, bool isAsync, bool return_ring_ready) { FUNC_BEGIN(); if (set_channel_attribute(uuid, "bridge_early_media=true") && set_channel_attribute(uuid, "hangup_after_bridge=false") && set_channel_attribute(uuid, "bypass_media=false") && set_channel_attribute(uuid, "playback_terminators=none") && set_channel_attribute(uuid, "continue_on_fail=true")) { set_channel_attribute(uuid, "export_vars=IMSDATA"); snprintf(szcmd, LEN_512, "effective_caller_id_name=%s", called_disp); set_channel_attribute(uuid, szcmd); snprintf(szcmd, LEN_512, "effective_caller_id_number=%s", called_disp); set_channel_attribute(uuid, szcmd); //char param[LEN_512+1]={0}; //snprintf(param, LEN_512, "[return_ring_ready=%s]%s", return_ring_ready ? "true" : "false", dnis); esl_status_t esl_ret = ESL_GENERR; TRACE_LOG("before bridge %s", isAsync ? "async" : "sync"); if (isAsync) { int async = _handle.async_execute; _handle.async_execute = 1; esl_ret = esl_execute(&_handle, "bridge", dnis, uuid); _handle.async_execute = async; } else { esl_ret = esl_execute(&_handle, "bridge", dnis, uuid); } TRACE_LOG("after bridge %s", isAsync ? "async" : "sync"); if (esl_ret == ESL_SUCCESS && is_result_ok(fs_resp = esl_event_get_header(_handle.last_sr_event, "Reply-Text"))) { ret = IMS_SUCCESS; break; } else { WARNING_LOG("fs:bridge(%s,%s,%s,%s);ret(%s)", uuid, called_disp, dnis, fs_resp, isAsync ? "async" : "sync"); } } FUNC_END(); }
int32_t fs_opr_t::send_dtmf(const char* uuid, const char* keys) { FUNC_BEGIN(); (void)szcmd; //snprintf(szcmd,LEN_512,CMD_UUIDSENDDTMF_FMT,uuid,keys); //TRACE_LOG("send_dtmf(%s)",szcmd); //if(esl_send_recv(&_handle,szcmd)==ESL_SUCCESS){ if (esl_execute(&_handle, "send_dtmf", keys, uuid) == ESL_SUCCESS && is_result_ok(fs_resp = esl_event_get_header(_handle.last_sr_event, "Reply-Text"))) { ret = IMS_SUCCESS; } else { WARNING_LOG("fs:send_dtmf(%s,%s);ret(%s)", uuid, keys, fs_resp); } FUNC_END(); }
static ssize_t msr3110_dev_write(struct file *filp, const char __user *buf, size_t count, loff_t *offset) { ssize_t retVal = 0; FUNC_START(); my_pr_debug( "%s count: %d \n", __func__, count); if( count > MSR3110_DEV_WRITE_MAX) { count = MSR3110_DEV_WRITE_MAX; } if( copy_from_user( I2CDMAWriteBuf, buf, count)) { my_pr_err( "%s fail to copy from user \n", __func__); retVal = -EFAULT; goto end; } nfc_client->addr = ( MSR3110_CMD_I2C_ID & I2C_MASK_FLAG); SET_NFC_CLIENT_TIMING(); SET_NFC_CLIENT_BUS_LOG(); nfc_client->ext_flag = I2C_DMA_FLAG; nfc_client->ext_flag |= I2C_DIRECTION_FLAG; retVal = i2c_master_send( nfc_client, (unsigned char *)I2CDMAWriteBuf_pa, count); my_pr_debug( "%s rcv count: %d \n", __func__, retVal); if( retVal < 0) { //my_pr_err( "%s i2c_master_send fail. retVal: %d ", __func__, retVal); goto end; } if( retVal != count) { //my_pr_err( "%s i2c_master_send retVal != count. retVal: %d ", __func__, retVal); retVal = -EIO; goto end; } end: FUNC_END(); return retVal; }
//============================ // MotorTestMultiple // // Test every motor connected on // startPort to (startPort + numMotors - 1) //============================ void MotorTestMultiple( int startPort, int numMotors, int motorSpeed, float waitTime ) { int i; FUNC_BEGIN("MotorTestMultiple"); if (waitTime < 1) printf("WARNING: waitTime is lower than 1 second: %f\n", waitTime); for (i = 0; i < numMotors; i++) Motor(startPort + i, motorSpeed); wait( waitTime ); for (i = 0; i < numMotors; i++) Motor(startPort + i, MOTOR_OFF); FUNC_END("MotorTestMultiple"); }
int32_t fs_opr_t::join_conference(const char* name, const char* dest_disp, const char* destno, CONF_MODE mode, uint64_t sessionid) { FUNC_BEGIN(); snprintf(szcmd, LEN_512, CMD_JOINCONFERENCE_FMT, dest_disp, dest_disp, sessionid, destno, name, ((CONF_LISTEN == mode) ? "+flags{mute}" : "")); TRACE_LOG("join_conference(%s)", szcmd); if (esl_send_recv(&_handle, szcmd) == ESL_SUCCESS) { if (is_result_ok(fs_resp = esl_event_get_header(_handle.last_sr_event, "Reply-Text"))) { ret = IMS_SUCCESS; } else { WARNING_LOG("fs:join_conference(%s,%s,%s,%u,%lu);ret(%s)", name, dest_disp, destno, mode, sessionid, fs_resp); } } FUNC_END(); }
int32_t fs_opr_t::unjoin_conference(const char* name, const char* uuid) { FUNC_BEGIN(); snprintf(szcmd, LEN_512, "api uuid_transfer %s -aleg 'set:hangup_after_bridge=false,set:park_after_bridge=true,park:' inline \n\n", uuid); TRACE_LOG("unjoin_conference(%s)", szcmd); if (esl_send_recv(&_handle, szcmd) == ESL_SUCCESS) { if (is_result_ok(fs_resp = esl_event_get_body(_handle.last_sr_event))) { ret = IMS_SUCCESS; } else { WARNING_LOG("fs:unjoin_conference(%s,%s);ret(%s)", name, uuid, fs_resp); } } FUNC_END(); }
///////////////////////////////////// 呼叫 START ///////////////////////////////////////////////// int32_t fs_opr_t::originate(const char* ani, const char* dnis, const char* caller_disp, const char* called_disp, uint64_t sessionid, uint32_t timeout) { FUNC_BEGIN(); snprintf(szcmd, LEN_512, CMD_ORIGINATE_FMT, caller_disp, caller_disp, sessionid, ani, called_disp, called_disp, timeout, sessionid, dnis); TRACE_LOG("originate(%s)", szcmd); if (esl_send_recv(&_handle, szcmd) == ESL_SUCCESS && is_result_ok(fs_resp = esl_event_get_header(_handle.last_sr_event, "Reply-Text"))) { ret = IMS_SUCCESS; break; } else { WARNING_LOG("fs:originate(%s,%s,%s,%s,%u,%lu);ret(%s)", ani, dnis, caller_disp, called_disp, timeout, sessionid, fs_resp); } FUNC_END(); }
int32_t fs_opr_t::uuid_exists(const char* uuid) { FUNC_BEGIN(); const char* uuid_exists = "api uuid_exists %s"; snprintf(szcmd, LEN_512, uuid_exists, uuid); TRACE_LOG("uuid_exists(%s)", szcmd); if (esl_send_recv(&_handle, szcmd) == ESL_SUCCESS) { fs_resp = esl_event_get_body(_handle.last_sr_event); if (fs_resp && strncasecmp(fs_resp, "true", 4) == 0) { TRACE_LOG("uuid=%s exists.", uuid); ret = IMS_SUCCESS; } else { WARNING_LOG("fs:uuid=%s not exists;ret(%s)", uuid, fs_resp); } } FUNC_END(); }
int32_t fs_opr_t::uuid_bridge(const char* uuid1, const char* uuid2, char* uuid_output, uint32_t output_len) { FUNC_BEGIN(); snprintf(szcmd, LEN_512, CMD_UUIDBRIDGE_FMT, uuid1, uuid2); TRACE_LOG("uuid_bridge(%s)", szcmd); if (set_channel_attribute(uuid1, "bypass_media=false") && set_channel_attribute(uuid2, "bypass_media=false")) { if (esl_send_recv(&_handle, szcmd) == ESL_SUCCESS) { if (is_result_ok(fs_resp = esl_event_get_body(_handle.last_sr_event))) { fs_resp += 3; while (*fs_resp && ' ' == *fs_resp) { fs_resp++; } if (*fs_resp && uuid_output && output_len > 0) { strncpy(uuid_output, fs_resp, output_len); uint32_t idx = 0; do { if ('\n' == uuid_output[idx]) { uuid_output[idx] = '\0'; break; } ++idx; } while (uuid_output[idx]); } ret = IMS_SUCCESS; } else { WARNING_LOG("fs:uuid_bridge(%s,%s,%s);ret(%s)", uuid1, uuid2, uuid_output, fs_resp); } } } else { WARNING_LOG("fs:uuid_bridge(%s,%s) failed(set channel attribute err)", uuid1, uuid2); } FUNC_END(); }
LiveCDFS::LiveCDFS(struct list_head *cfg, struct dir_cache *cache, struct credentials *cred, const string &mount, Path *path, Whiteout *whiteout) { FUNC_START("cfg=%p, cache=%p, cred=%p, mount='%s', path=%p, whiteout=%p", cfg, cache, cred, mount.c_str(), path, whiteout); this->cfg = cfg; this->cache = cache; this->cred = cred; this->mount = mount; this->path = path; this->whiteout = whiteout; this->handles = new Handles(); FUNC_END(); }
void LiveCDFS::destroy(LiveCDFS *fs) { FUNC_START("fs=", fs); t_active_livecdfs *active = findActive(fs); if (active != NULL) { active->count--; if (active->count == 0) { TRACE("fs=%p not active anymore, destroying", fs); activefs.erase((vector<t_active_livecdfs>::iterator)active); delete fs; } else { TRACE("fs=%p still has %u references", fs, active->count); } } else { ERROR("fs=%p not found, cannot destroy", fs); } FUNC_END(); }
static ssize_t msr3110_dev_read(struct file *filp, char __user *buf, size_t count, loff_t *offset) { ssize_t retVal = 0; unsigned char tmp[MSR3110_DEV_READ_MAX]; int loopIdx = 0; int readByteCount = 0;; FUNC_START(); my_pr_debug( "%s count: %d\n", __func__, count); if( count > MSR3110_DEV_READ_MAX) { count = MSR3110_DEV_READ_MAX; } nfc_client->addr = ( MSR3110_CMD_I2C_ID & I2C_MASK_FLAG); nfc_client->ext_flag = I2C_DMA_FLAG; nfc_client->ext_flag |= I2C_DIRECTION_FLAG; SET_NFC_CLIENT_TIMING(); SET_NFC_CLIENT_BUS_LOG(); for( loopIdx = 0; loopIdx < MSR3110_DEV_READ_RETRY_COUNT; loopIdx++) { retVal = i2c_master_recv( nfc_client, (unsigned char *)I2CDMAReadBuf_pa, count); my_pr_debug( "%s loopIdx: %d, recv retVal: %d \n", __func__, loopIdx, retVal); if( retVal == count) { my_pr_debug( "%s SUCCESS: recv. \n", __func__); break; } if( retVal < 0) { //my_pr_err( "%s FAIL: recv. CONTINUE. \n", __func__); usleep_range( 900, 1000); continue; } if( retVal > 2) { //my_pr_err( "%s FAIL: recv too many bytes. goto end. \n", __func__); //retVal = -EIO; retVal = 0; goto end; } } if( retVal < 0) { my_pr_err( "%s FAIL: recv. out of retry count, goto end. \n", __func__); retVal = 0; goto end; } readByteCount = retVal; #if 0 for( loopIdx = 0; loopIdx < MSR3110_DEV_READ_RETRY_COUNT; loopIdx++) { msleep(MSR3110_DEV_READ_RETRY_DELAY); retVal = i2c_master_recv( nfc_client, tmp, 2); my_pr_info( "%s loopIdx: %d, recv retVal: %d \n", __func__, loopIdx, retVal); if( retVal == 2) { my_pr_info( "%s SUCCESS: recv. \n", __func__); break; } if( retVal < 0) { my_pr_err( "%s FAIL: recv. CONTINUE. \n", __func__); continue; } if( retVal > 2) { my_pr_err( "%s FAIL: recv too many bytes. goto end. \n", __func__); retVal = -EIO; goto end; } } if( retVal < 0) { my_pr_err( "%s FAIL: recv. out of retry count, goto end. \n", __func__); goto end; } readByteCount = 2; if( tmp[1] > 0) { for( loopIdx = 0; loopIdx < MSR3110_DEV_READ_RETRY_COUNT; loopIdx++) { msleep(1); retVal = i2c_master_recv( nfc_client, &tmp[2], tmp[1] + 2); my_pr_info( "%s loopIdx: %d, recv retVal: %d", __func__, loopIdx, retVal); if( retVal == ( tmp[1] + 2)) { my_pr_info( "%s SUCCESS: recv data.", __func__); break; } if( retVal < 0) { my_pr_err( "%s FAIL: recv. CONTINUE.", __func__); continue; } if( retVal > ( tmp[1] + 2)) { my_pr_err( "%s FAIL: recv too many bytes. goto end.", __func__); retVal = -EIO; goto end; } } } if( retVal < 0) { my_pr_err( "%s FAIL: recv. out of retry count, goto end.", __func__); goto end; } readByteCount += tmp[1] + 2; retVal = readByteCount; #endif if ( copy_to_user( buf, I2CDMAReadBuf, readByteCount)) { my_pr_err("%s : failed to copy to user space\n", __func__); retVal = 0; goto end; } end: //for( loopIdx = 0; loopIdx < readByteCount; loopIdx++) //{ // my_pr_debug( "%s %02X", __func__, tmp[loopIdx]); //} FUNC_END(); return retVal; }