int8_t SIM900GSM::sendSMS(const char *number, const char *message) { portFlushRX(); portWrite( "AT+CMGS=\"%s\"\r\n", number ); if( waitResponse( ">", 5000 ) < 0 ) return (-1); portFlushRX(); portWrite( "%s%c", message, (char)0x1A ); // append CTRL+Z return waitResponse("+CMGS", 10000); }
int16_t SIM900GSM::hasSMS( message_status status ) { portFlushRX(); switch(status) { case REC_UNREAD: writeCommand("AT+CMGL=\"REC UNREAD\""); break; case REC_READ: writeCommand("AT+CMGL=\"REC READ\""); break; case STO_UNSENT: writeCommand("AT+CMGL=\"STO UNSENT\""); break; case STO_SENT: writeCommand("AT+CMGL=\"STO SENT\""); break; case MSG_ALL: writeCommand("AT+CMGL=\"ALL\""); break; default: return (-1); } if( waitResponse("+CMGL: ", 2000) < 0 ) return (-1); return ((int16_t)getIntegerResponse()); }
uint8_t WizFi250SpiDrv::waitResponseCmd(uint32_t check_delay, uint32_t check_count, char* str_find1, char* str_find2, uint8_t debug_print ) { uint8_t nResult = SPI_SUCCESS; char temp_buff[50]; nResult = waitResponse( check_delay, check_count, str_find1, str_find2, debug_print ); if( nResult != SPI_SUCCESS && nResult != SPI_RX_BUFFER_MAX ) return nResult; if ( m_spi_rx_length > 0 ) { char temp_str[MAX_SPI_BUFSIZE]; memcpy(temp_str,m_spi_rx_buffer,MAX_SPI_BUFSIZE); //strcpy(temp_str,(char*)m_spi_rx_buffer); if ( debug_print <= 4 ) { strcpy_P( temp_buff, (char*)pgm_read_word(&debug_str_table[DBG_SPI_RECV]) ); DBG_LN(temp_buff); DBG(temp_str); strcpy_P( temp_buff, (char*)pgm_read_word(&debug_str_table[DBG_SPI_END]) ); DBG_LN(temp_buff); } m_spi_rx_length = 0; } return nResult; }
void SIM900GSM::begin( uint32_t baud ) { SIM900::begin(baud); writeCommand("AT+CMGF=1"); waitResponse("OK", 500); }
/* Function: Write information about the influence function after making * a move to stderr. * Arguments: move, optionally a list of what to show * Fails: never * Returns: nothing */ int QGtp::debugMoveInfluence (QString color, char c, int i,QString list) { fflush(QByteArray("debug_move_influence ")+color.toLatin1()+ " "+c+intToQByteArray(i)+" "+list.toLatin1()); return waitResponse(); }
bool CApoxObj::sendCommandWait( uint8_t cmdcode, responseMsg *pMsg, uint32_t timeout ) { // Send the command if ( USB_OK != sendCommand( cmdcode ) ) return false; return waitResponse( pMsg, timeout ); }
//********************************************************************** //!Wait for ACK response and stores it in the dataRX buffer void getACK(void) { delay(5); waitResponse(); for (int i = 0; i < 5 ; i++) { dataRX[i] = Serial.read(); } }
//!Wait for ACK response and stores it in the dataRX buffer void WaspRFID::getACK(void) { delay(5); waitResponse(); for (int i = 0; i<5 ; i++) { dataRX[i] = Serial.read(_uart); } }
/* Function: Set up fixed placement handicap stones. * Arguments: number of handicap stones * Fails: invalid number of stones for the current boardsize * Returns: list of vertices with handicap stones */ int QGtp::fixedHandicap (int handicap) { if (handicap < 2) return OK; fflush ("fixed_handicap "+intToQByteArray(handicap)); return waitResponse(); }
int8_t SIM900GSM::deleteSMS( int16_t index, delete_flag flag ) { if( index<1 || flag<DEL_INDEX || flag>DEL_ALL ) return (-1); portFlushRX(); //dprint("deleteSMS %d (flag=%d)\r\n", index, flag); portWrite("AT+CMGD=%d,%d\r\n", index, (int)flag); return waitResponse("OK", 5000); }
int QGtp::set_free_handicap(QList<Point> handicap_stones) { QByteArray message("set_free_handicap"); for ( int i=0; i<handicap_stones.length(); ++i ) { message.append(" ").append(encodeCoors(handicap_stones[i].x,handicap_stones[i].y)); } fflush (message); return waitResponse(); }
//********************************************************************** //!Send data stored in dataTX void sendTX(uint8_t *dataTX, uint8_t length, uint8_t outLength) { Serial.print(0x00, BYTE); Serial.print(0x00, BYTE); Serial.print(0xFF, BYTE); for (int i = 0; i < length; i++) { Serial.print(dataTX[i], BYTE); } Serial.print(0x00, BYTE); getACK(); waitResponse();// Receive response getData(outLength); }
void GSwifi::writeCert() { // Binary format, store in memory command( "AT+TCERTADD=cacert,0,753,1", GSCOMMANDMODE_NORMAL ); resetResponse(GSCOMMANDMODE_NORMAL); // ESCAPE 'W' is written in pgm too (thus +2) for (uint16_t i=0; i<753 + 2; i++) { uint8_t read = pgm_read_byte_near(der + i); serial_->write( read ); Serial.print( read, HEX ); } setBusy(true); waitResponse(GS_TIMEOUT); }
void GSwifi::command (const char *cmd, GSCOMMANDMODE res, uint8_t timeout_second) { // GSLOG_PRINT(P("F: 0x")); GSLOG_PRINTLN2( freeMemory(), HEX ); GSLOG_PRINT(P("c> ")); resetResponse(res); serial_->println(cmd); GSLOG_PRINTLN(cmd); if (timeout_second == GS_TIMEOUT_NOWAIT) { return; } setBusy(true); waitResponse(timeout_second); }
/*! \param uint8_t dataTX : pointer to dataTX vector. */ void WaspRFID::sendTX(uint8_t *dataTX, uint8_t length, uint8_t outLength) { printByte(PREAMBLE, _uart); printByte(PREAMBLE, _uart); printByte(STARTCODE2, _uart); for (int i = 0; i<length; i++) { printByte(dataTX[i], _uart); } printByte(POSTAMBLE, _uart); getACK(); waitResponse(); // 1C - receive response getData(outLength); digitalWrite(MUX_USB_XBEE, LOW); delay(_delay); }
/* Function: Compute the score of a finished game. * Arguments: Optional random seed * Fails: never * Returns: Score in SGF format (RE property). */ int QGtp::finalScore (int seed) { fflush("final_score "+intToQByteArray(seed)); return waitResponse(); }
/* Function: Report vertices with a specific final status in a finished game. * Arguments: Status in the form of one of the strings "alive", "dead", * "seki", "white_territory", "black_territory", or "dame". * An optional random seed can be added. * Fails: missing or invalid status string * Returns: Vertices having the specified status. These are split with * one string on each line if the vertices are nonempty (i.e. * for "alive", "dead", and "seki"). */ int QGtp::finalStatusList (QString status, int seed) { fflush(QByteArray("final_status_list ")+status.toLatin1()+" "+intToQByteArray(seed)); return waitResponse(); }
/* Function: Report the final status of a vertex in a finished game. * Arguments: Vertex, optional random seed * Fails: invalid vertex * Returns: Status in the form of one of the strings "alive", "dead", * "seki", "white_territory", "black_territory", or "dame". */ int QGtp::finalStatus (char c, int i, int seed) { fflush("final_status "+c+intToQByteArray(i)+" "+intToQByteArray(seed)); return waitResponse(); }
/* Function: Undo last move * Arguments: int * Fails: If move pointer is 0 * Returns: nothing */ int QGtp::undo (int i) { fflush("undo "+intToQByteArray(i)); return waitResponse(); }
int QGtp::topMovesBlack () { fflush("top_moves_black"); return waitResponse(); }
/* Function: Retrieve the count of life nodes. * Arguments: none * Fails: never * Returns: number of life nodes */ int QGtp::getLifeNodeCounter () { fflush("get_life_node_counter"); return waitResponse(); }
int QGtp::combinationAttack (QString color) { fflush(QByteArray("combination_attack ")+color.toLatin1()); return waitResponse(); }
/* Function: Retrieve the count of reading nodes. * Arguments: none * Fails: never * Returns: number of reading nodes */ int QGtp::getReadingNodeCounter () { fflush("get_reading_node_counter"); return waitResponse(); }
int QGtp::estimateScore () { fflush("estimate_score"); return waitResponse(); }
int QGtp::newScore () { fflush("new_score"); return waitResponse(); }
/* Function: Generate the supposedly best move for either color. * Arguments: color to move, optionally a random seed * Fails: invalid color * Returns: a move coordinate (or "PASS") */ int QGtp::genmove (QString color,int seed) { fflush(QByteArray("gg_genmove ") +color.toLatin1()+" "+intToQByteArray(seed)); return waitResponse(); }
/* Function: Retrieve the count of owl nodes. * Arguments: none * Fails: never * Returns: number of owl nodes */ int QGtp::getOwlNodeCounter () { fflush("get_owl_node_counter"); return waitResponse(); }
int QGtp::topMovesWhite () { fflush("top_moves_white"); return waitResponse(); }
/* Function: Reset the count of trymoves/trykos. * Arguments: none * Fails: never * Returns: nothing */ int QGtp::resetTrymoveCounter () { fflush("reset_trymove_counter"); return waitResponse(); }
/* Function: Return the information in the dragon data structure. * Arguments: intersection * Fails: invalid coordinate * Returns: Dragon data formatted in the corresponding way to gtp_worm__ */ int QGtp::dragonData (char c,int i) { fflush("dragon_data "+c+intToQByteArray(i)); return waitResponse(); }