summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorFlorian Baumann <derflob@derflob.de>2015-12-26 11:51:11 +0100
committerFlorian Baumann <derflob@derflob.de>2015-12-26 11:51:11 +0100
commit030493db1b565fec0e6befa2fdf6fadc2fc35430 (patch)
treeb91b8763b79538a9ee8cbaab69013e9cf77f5af4
parentef4544026a81836b8f8a29eeea636585d3603d3c (diff)
downloadmFeTAp-030493db1b565fec0e6befa2fdf6fadc2fc35430.tar.gz
mFeTAp-030493db1b565fec0e6befa2fdf6fadc2fc35430.tar.bz2
dial a radio fq with 723<fq>
-rw-r--r--mFeTAp.ino52
1 files changed, 45 insertions, 7 deletions
diff --git a/mFeTAp.ino b/mFeTAp.ino
index 1415b1a..06b3eb8 100644
--- a/mFeTAp.ino
+++ b/mFeTAp.ino
@@ -64,6 +64,7 @@ enum adv_states {
BUSY,
INCOMING,
READING_SMS,
+ FM,
} adv_state;
void setup() {
@@ -127,6 +128,7 @@ void process_input_RI() {
switch (adv_state) {
case IDLE:
+ case FM:
if (digitalRead(PIN_INCOMING) == LOW) {
if (pin_down == 0) {
pin_down = millis();
@@ -197,8 +199,16 @@ void process_input_hangup() {
case READING_SMS:
if (digitalRead(PIN_HANGUP) == HIGH) {
- sms_available = 0;
Serial.println("IDLE: SMS reading abort");
+ sms_available = 0;
+ adv_state = IDLE;
+ }
+ break;
+
+ case FM:
+ if (digitalRead(PIN_HANGUP) == HIGH) {
+ Serial.println("IDLE: FM hung up");
+ fona.FMradio(0, 0);
adv_state = IDLE;
}
break;
@@ -207,8 +217,8 @@ void process_input_hangup() {
case DIALING:
case BUSY:
if (digitalRead(PIN_HANGUP) == HIGH) {
- MsTimer2::stop();
Serial.println("IDLE: Hang up abort");
+ MsTimer2::stop();
delete_number();
play_dial_tone(false);
enableGSMBusy(false);
@@ -229,12 +239,16 @@ void process_input_digit() {
number[number_len] = d;
number_len++;
+ Serial.print("Dialed: ");
+ Serial.println(digit);
+
play_dial_tone(false);
delay(50);
fona.playDTMF(d);
digit_playing = millis();
}
+
digit = 0;
digit_dialed = 0;
}
@@ -254,12 +268,23 @@ void process_input_number() {
if (number_dialed) {
Serial.println("DIALING: number dialed");
adv_state = DIALING;
- if (call_current_number(number, &number_len)) {
- Serial.println("SPEAKING: Calling");
- adv_state = SPEAKING;
+ char radio[4] = "723";
+ if (strncmp(number, radio, 3) == 0) {
+ if (start_radio(number, &number_len)) {
+ Serial.println("FM: radio");
+ adv_state = FM;
+ } else {
+ Serial.println("IDLE: Radio tuning failed");
+ adv_state = IDLE;
+ }
} else {
- Serial.println("IDLE: Call failed");
- adv_state = IDLE;
+ if (call_current_number(number, &number_len)) {
+ Serial.println("SPEAKING: Calling");
+ adv_state = SPEAKING;
+ } else {
+ Serial.println("IDLE: Call failed");
+ adv_state = IDLE;
+ }
}
delete_number();
number_dialed = 0;
@@ -525,6 +550,19 @@ int call_current_number(char *number, int *number_len) {
return fona.callPhone(full);
}
+int start_radio(char *number, int *number_len) {
+
+ uint16_t fq = 0;
+ fq = strtoul(number+3, NULL, 10);
+ play_dial_tone(0);
+ if (fona.FMradio(1, 0)) {
+ fona.setFMVolume(4);
+ return fona.tuneFMradio(fq);
+ }
+
+ return false;
+}
+
void sig_commit_digit() {
digit_dialed = 1;