update DTMF tx and rx
This commit is contained in:
		
							parent
							
								
									6472b103b4
								
							
						
					
					
						commit
						71acbbb975
					
				| 
						 | 
					@ -72,7 +72,7 @@ void setup() {
 | 
				
			||||||
  //radio.setSQOff();
 | 
					  //radio.setSQOff();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  Serial.println("setting frequency to: ");
 | 
					  Serial.println("setting frequency to: ");
 | 
				
			||||||
  freq = 420000;
 | 
					  freq = 432250;
 | 
				
			||||||
  radio.frequency(freq);
 | 
					  radio.frequency(freq);
 | 
				
			||||||
  Serial.print(radio.getFrequency());
 | 
					  Serial.print(radio.getFrequency());
 | 
				
			||||||
  Serial.println("kHz");
 | 
					  Serial.println("kHz");
 | 
				
			||||||
| 
						 | 
					@ -119,9 +119,13 @@ void loop() {
 | 
				
			||||||
    while (j < 4) {
 | 
					    while (j < 4) {
 | 
				
			||||||
      if (radio.getDTMFSample() == 0) {
 | 
					      if (radio.getDTMFSample() == 0) {
 | 
				
			||||||
        j++;
 | 
					        j++;
 | 
				
			||||||
 | 
					      } else {
 | 
				
			||||||
 | 
					        j = 1;
 | 
				
			||||||
      }
 | 
					      }
 | 
				
			||||||
      delay(10);
 | 
					      delay(10);
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					    // reset read
 | 
				
			||||||
 | 
					    //radio.enableDTMFReceive();
 | 
				
			||||||
  } else if (rx_dtmf_idx > 0) {
 | 
					  } else if (rx_dtmf_idx > 0) {
 | 
				
			||||||
    rx_dtmf_buf[rx_dtmf_idx] = '\0'; // NULL terminate the string
 | 
					    rx_dtmf_buf[rx_dtmf_idx] = '\0'; // NULL terminate the string
 | 
				
			||||||
    Serial.println(rx_dtmf_buf);
 | 
					    Serial.println(rx_dtmf_buf);
 | 
				
			||||||
| 
						 | 
					@ -130,6 +134,7 @@ void loop() {
 | 
				
			||||||
  
 | 
					  
 | 
				
			||||||
  // Is it time to send tone?
 | 
					  // Is it time to send tone?
 | 
				
			||||||
  if (Serial.available()) {
 | 
					  if (Serial.available()) {
 | 
				
			||||||
 | 
					    // get first code
 | 
				
			||||||
    uint8_t code = char2code(Serial.read());
 | 
					    uint8_t code = char2code(Serial.read());
 | 
				
			||||||
    
 | 
					    
 | 
				
			||||||
    // start transmitting
 | 
					    // start transmitting
 | 
				
			||||||
| 
						 | 
					@ -137,7 +142,7 @@ void loop() {
 | 
				
			||||||
    radio.setTxSourceTones();
 | 
					    radio.setTxSourceTones();
 | 
				
			||||||
    radio.setModeTransmit();
 | 
					    radio.setModeTransmit();
 | 
				
			||||||
    delay(300); // wait for TX to come to full power
 | 
					    delay(300); // wait for TX to come to full power
 | 
				
			||||||
 | 
					    
 | 
				
			||||||
    bool dtmf_to_tx = true;
 | 
					    bool dtmf_to_tx = true;
 | 
				
			||||||
    while (dtmf_to_tx) {
 | 
					    while (dtmf_to_tx) {
 | 
				
			||||||
      // wait until ready
 | 
					      // wait until ready
 | 
				
			||||||
| 
						 | 
					@ -145,18 +150,20 @@ void loop() {
 | 
				
			||||||
        // wait until we're ready for a new code
 | 
					        // wait until we're ready for a new code
 | 
				
			||||||
        delay(10);
 | 
					        delay(10);
 | 
				
			||||||
      }
 | 
					      }
 | 
				
			||||||
      while (radio.getDTMFTxActive() != 0) {
 | 
					 | 
				
			||||||
        // wait until this code is done
 | 
					 | 
				
			||||||
        delay(10);
 | 
					 | 
				
			||||||
      }
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
      if (Serial.available()) {
 | 
					      if (Serial.available()) {
 | 
				
			||||||
        code = char2code(Serial.read());
 | 
					        code = char2code(Serial.read());
 | 
				
			||||||
        if (code == 255) code = 0xE; // throw a * in there so we don't break things with an invalid code
 | 
					        if (code == 255) code = 0xE; // throw a * in there so we don't break things with an invalid code
 | 
				
			||||||
        radio.setDTMFCode(code); // set first
 | 
					        radio.setDTMFCode(code); // set first
 | 
				
			||||||
      } else {
 | 
					      } else {
 | 
				
			||||||
        dtmf_to_tx = false;
 | 
					        dtmf_to_tx = false;
 | 
				
			||||||
 | 
					        break;
 | 
				
			||||||
      }
 | 
					      }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					      while (radio.getDTMFTxActive() != 0) {
 | 
				
			||||||
 | 
					        // wait until this code is done
 | 
				
			||||||
 | 
					        delay(10);
 | 
				
			||||||
 | 
					      }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
    // done with tone
 | 
					    // done with tone
 | 
				
			||||||
    radio.setModeReceive();
 | 
					    radio.setModeReceive();
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
		Reference in New Issue