void EasyVR::playMessageAsync(int8_t index, int8_t speed, int8_t atten) { sendCmd(CMD_PLAY_RP); sendArg(-1); sendArg(index); sendArg((speed << 2) | (atten & 3)); }
void EasyVR::playSoundAsync(int16_t index, int8_t volume) { sendCmd(CMD_PLAY_SX); sendArg((index >> 5) & 0x1F); sendArg(index & 0x1F); sendArg(volume); }
void EasyVR::recordMessageAsync(int8_t index, int8_t bits, int8_t timeout) { sendCmd(CMD_RECORD_RP); sendArg(-1); sendArg(index); sendArg(bits); sendArg(timeout); }
void EasyVR::sendTokenAsync(int8_t bits, uint8_t token) { sendCmd(CMD_SEND_SN); sendArg(bits); sendArg((token >> 5) & 0x1F); sendArg(token & 0x1F); sendArg(0); sendArg(0); }
void EasyVR::detectToken(int8_t bits, int8_t rejection, uint16_t timeout) { sendCmd(CMD_RECV_SN); sendArg(bits); sendArg(rejection); if (timeout > 0) timeout = (timeout * 2 + 53)/ 55; // approx / 27.46 - err < 0.15% sendArg((timeout >> 5) & 0x1F); sendArg(timeout & 0x1F); }
bool EasyVR::checkMessages() { sendCmd(CMD_VERIFY_RP); sendArg(-1); sendArg(0); int rx = recv(STORAGE_TIMEOUT); readStatus(rx); return (_status.v == 0); }
bool EasyVR::setPinOutput(int8_t pin, int8_t value) { sendCmd(CMD_QUERY_IO); sendArg(pin); sendArg(value); if (recv(DEF_TIMEOUT) == STS_SUCCESS) return true; return false; }
bool EasyVR::setMicDistance(int8_t dist) { sendCmd(CMD_MIC_DIST); sendArg(-1); sendArg(dist); if (recv(DEF_TIMEOUT) == STS_SUCCESS) return true; return false; }
bool EasyVR::playPhoneTone(int8_t tone, uint8_t duration) { sendCmd(CMD_PLAY_DTMF); sendArg(-1); // distinguish DTMF from SX sendArg(tone); sendArg(duration - 1); if (recv((tone < 0 ? duration * 1000 : duration * 40) + DEF_TIMEOUT) == STS_SUCCESS) return true; return false; }
bool EasyVR::playSound(int16_t index, int8_t volume) { sendCmd(CMD_PLAY_SX); sendArg((index >> 5) & 0x1F); sendArg(index & 0x1F); sendArg(volume); if (recv(PLAY_TIMEOUT) == STS_SUCCESS) return true; return false; }
bool EasyVR::sendToken(int8_t bits, uint8_t token) { sendCmd(CMD_SEND_SN); sendArg(bits); sendArg((token >> 5) & 0x1F); sendArg(token & 0x1F); sendArg(0); sendArg(0); if (recv(TOKEN_TIMEOUT) == STS_SUCCESS) return true; return false; }
int8_t EasyVR::getPinInput(int8_t pin, int8_t config) { sendCmd(CMD_QUERY_IO); sendArg(pin); sendArg(config); if (recv(DEF_TIMEOUT) == STS_PIN) { int8_t rx; if (recvArg(rx, DEF_TIMEOUT)) return rx; } return -1; }
bool EasyVR::setDelay(uint16_t millis) { sendCmd(CMD_DELAY); if (millis <= 10) sendArg(millis); else if (millis <= 100) sendArg(millis / 10 + 9); else if (millis <= 1000) sendArg(millis / 100 + 18); else return false; if (recv(DEF_TIMEOUT) == STS_SUCCESS) return true; return false; }
// ============================================================================ // RCwrtRegistryClientSession::getAttributeL() // Returns the attribute value for the widget // // ============================================================================ EXPORT_C QVariant RWACRegistryClientSession::getAttributeL( const QString& appId, const QString& attribute, const QVariant& defaultValue ) { const TInt maxSize = 5120; CBufFlat* sendBuf = CBufFlat::NewL( maxSize ); CleanupStack::PushL( sendBuf ); RBufWriteStream stream( *sendBuf ); CleanupClosePushL( stream ); SerializeStringL( stream, appId ); SerializeStringL( stream, attribute ); SerializeStringL( stream, defaultValue.toString() ); CleanupStack::PopAndDestroy( &stream ); CBufFlat* recvBuf = CBufFlat::NewL( maxSize ); CleanupStack::PushL( recvBuf ); recvBuf->ExpandL( 0, maxSize ); TPtr8 sendArg( sendBuf->Ptr(0) ); TPtr8 recvArg( recvBuf->Ptr(0) ); User::LeaveIfError( SendReceive( EOpCodeGetWebAttribute, TIpcArgs( &sendArg, &recvArg ) ) ); // deserialize RDesReadStream rstream( recvArg ); CleanupClosePushL( rstream ); QString attrValue = DeserializeStringL( rstream ); CleanupStack::PopAndDestroy( 3, sendBuf ); // rstream, recvBuf, sendBuf return ( QVariant( attrValue ) ); }
bool EasyVR::embedToken(int8_t bits, uint8_t token, uint16_t delay) { sendCmd(CMD_SEND_SN); sendArg(bits); sendArg((token >> 5) & 0x1F); sendArg(token & 0x1F); delay = (delay * 2 + 27) / 55; // approx / 27.46 - err < 0.15% if (delay == 0) // must be > 0 to embed in some audio delay = 1; sendArg((delay >> 5) & 0x1F); sendArg(delay & 0x1F); if (recv(DEF_TIMEOUT) == STS_SUCCESS) return true; return false; }
bool EasyVR::sleep(int8_t mode) { sendCmd(CMD_SLEEP); sendArg(mode); if (recv(DEF_TIMEOUT) == STS_SUCCESS) return true; return false; }
bool EasyVR::resetAll() { sendCmd(CMD_RESETALL); sendArg(17); if (recv(RESET_TIMEOUT) == STS_SUCCESS) return true; return false; }
bool EasyVR::setLanguage(int8_t lang) { sendCmd(CMD_LANGUAGE); sendArg(lang); if (recv(DEF_TIMEOUT) == STS_SUCCESS) return true; return false; }
bool EasyVR::setKnob(int8_t knob) { sendCmd(CMD_KNOB); sendArg(knob); if (recv(DEF_TIMEOUT) == STS_SUCCESS) return true; return false; }
bool EasyVR::setTimeout(int8_t seconds) { sendCmd(CMD_TIMEOUT); sendArg(seconds); if (recv(DEF_TIMEOUT) == STS_SUCCESS) return true; return false; }
bool EasyVR::changeBaudrate(int8_t baud) { sendCmd(CMD_BAUDRATE); sendArg(baud); if (recv(DEF_TIMEOUT) == STS_SUCCESS) return true; return false; }
bool EasyVR::setLevel(int8_t level) { sendCmd(CMD_LEVEL); sendArg(level); if (recv(DEF_TIMEOUT) == STS_SUCCESS) return true; return false; }
bool EasyVR::eraseCommand(int8_t group, int8_t index) { sendCmd(CMD_ERASE_SD); sendGroup(group); sendArg(index); if (recv(DEF_TIMEOUT) == STS_SUCCESS) return true; return false; }
bool EasyVR::fixMessages(bool wait) { sendCmd(CMD_VERIFY_RP); sendArg(-1); sendArg(1); if (!wait) return true; int timeout = 25; // seconds while (timeout != 0 && _s->available() == 0) { delay(1000); --timeout; } if (_s->read() == STS_SUCCESS) return true; return false; }
bool EasyVR::removeCommand(int8_t group, int8_t index) { sendCmd(CMD_UNGROUP_SD); sendGroup(group); sendArg(index); if (recv(STORAGE_TIMEOUT) == STS_SUCCESS) return true; return false; }
bool EasyVR::addCommand(int8_t group, int8_t index) { sendCmd(CMD_GROUP_SD); sendGroup(group); sendArg(index); int rx = recv(DEF_TIMEOUT); if (rx == STS_SUCCESS) return true; _status.v = 0; if (rx == STS_OUT_OF_MEM) _status.b._memfull = true; return false; }
bool EasyVR::dumpMessage(int8_t index, int8_t& type, int32_t& length) { sendCmd(CMD_DUMP_RP); sendArg(-1); sendArg(index); int sts = recv(STORAGE_TIMEOUT); if (sts != STS_MESSAGE) { readStatus(sts); return false; } // if communication should fail _status.v = 0; _status.b._error = true; if (!recvArg(type)) return false; int8_t rx; length = 0; if (type == 0) return true; // skip reading if empty for (int8_t i = 0; i < 6; ++i) { if (!recvArg(rx)) return false; ((uint8_t*)&length)[i] |= rx & 0x0F; if (!recvArg(rx)) return false; ((uint8_t*)&length)[i] |= (rx << 4) & 0xF0; } _status.v = 0; return true; }
bool EasyVR::setCommandLabel(int8_t group, int8_t index, const char* name) { sendCmd(CMD_NAME_SD); sendGroup(group); sendArg(index); int8_t len = 31; for (const char* p = name; *p != 0 && len > 0; ++p, --len) { if (isdigit(*p)) --len; } len = 31 - len; sendArg(len); for (int8_t i = 0; i < len; ++i) { char c = name[i]; if (isdigit(c)) { send('^'); sendArg(c - '0'); } else if (isalpha(c)) { send(c & ~0x20); // to uppercase } else { send('_'); } } if (recv(DEF_TIMEOUT) == STS_SUCCESS) return true; return false; }
int8_t EasyVR::getGrammarsCount(void) { sendCmd(CMD_DUMP_SI); sendArg(-1); if (recv(DEF_TIMEOUT) == STS_COUNT) { int8_t rx; if (recvArg(rx, DEF_TIMEOUT)) { return rx == -1 ? 32 : rx; } } return -1; }
int8_t EasyVR::getCommandCount(int8_t group) { sendCmd(CMD_COUNT_SD); sendArg(group); if (recv(DEF_TIMEOUT) == STS_COUNT) { int8_t rx; if (recvArg(rx, DEF_TIMEOUT)) { return rx == -1 ? 32 : rx; } } return -1; }