diff --git a/baresip-test-config.tar.gz b/baresip-test-config.tar.gz new file mode 100644 index 0000000..ce97eca Binary files /dev/null and b/baresip-test-config.tar.gz differ diff --git a/baresip/accounts b/baresip/accounts index d581311..8493601 100644 --- a/baresip/accounts +++ b/baresip/accounts @@ -1 +1 @@ -;auth_pass=zgm-kwx2bug5hwf3YGF;unregister_on_exit=yes \ No newline at end of file +;auth_pass=zgm-kwx2bug5hwf3YGF;unregister_on_exit=yes \ No newline at end of file diff --git a/baresip/old-accounts b/baresip/old-accounts new file mode 100644 index 0000000..8493601 --- /dev/null +++ b/baresip/old-accounts @@ -0,0 +1 @@ +;auth_pass=zgm-kwx2bug5hwf3YGF;unregister_on_exit=yes \ No newline at end of file diff --git a/baresip/old-config b/baresip/old-config new file mode 100644 index 0000000..b5d910e --- /dev/null +++ b/baresip/old-config @@ -0,0 +1,24 @@ +call_max_calls 4 +call_local_timeout 120 + +# Audio +audio_player alsa,default +audio_source alsa,default +audio_alert alsa,default + +# Modules +#------------------------------------------------------------------------------ + +module_path /usr/lib/baresip/modules + +# Audio codec Modules +module g711.so + +# Audio driver Modules +module alsa.so + +# Application Modules +module_app account.so +module_app menu.so + +module httpd.so \ No newline at end of file diff --git a/src/utils/waiting-sounds.ts b/src/utils/waiting-sounds.ts index 4a316ec..3b0c49a 100644 --- a/src/utils/waiting-sounds.ts +++ b/src/utils/waiting-sounds.ts @@ -73,9 +73,12 @@ export class WaitingSounds { log(`🛑 Stopping waiting sounds. Has typingPlayback: ${!!this.typingPlayback}`) if (!this.typingPlayback) return - await Promise.all([this.typingPlayback.stop(), this.speakingPlayback?.finished()]) - log("🛑 Waiting sounds stopped") + // Quicky undefine this to stop the loops + const typingPlayback = this.typingPlayback this.typingPlayback = undefined + + await Promise.all([typingPlayback.stop(), this.speakingPlayback?.finished()]) + log("🛑 Waiting sounds stopped") } } diff --git a/test-baresip-calls.sh b/test-baresip-calls.sh new file mode 100755 index 0000000..adcad3e --- /dev/null +++ b/test-baresip-calls.sh @@ -0,0 +1,64 @@ +#!/bin/bash + +# Test script to call the Pi's baresip every 5 minutes +# This will help verify the NAT connection stays alive + +ACCOUNT_SID="AC1290bf86af061f24406c6762f48fa24e" +AUTH_TOKEN="6bfac57e5e26ea52c841594ef8d99ed1" +FROM_NUMBER="+13476229543" +TO_SIP="sip:yellow@probablycorey.sip.us1.twilio.com" +LOG_FILE="baresip-test-results.log" + +echo "=== Baresip Call Test Started at $(date) ===" | tee -a $LOG_FILE +echo "Will call every 5 minutes. Press Ctrl+C to stop." | tee -a $LOG_FILE +echo "" | tee -a $LOG_FILE + +call_count=0 + +while true; do + call_count=$((call_count + 1)) + echo "[$(date)] Test call #$call_count" | tee -a $LOG_FILE + + # Make the call + CALL_SID=$(curl -s -X POST "https://api.twilio.com/2010-04-01/Accounts/$ACCOUNT_SID/Calls.json" \ + -u "$ACCOUNT_SID:$AUTH_TOKEN" \ + --data-urlencode "Url=http://demo.twilio.com/docs/voice.xml" \ + --data-urlencode "To=$TO_SIP" \ + --data-urlencode "From=$FROM_NUMBER" \ + | jq -r '.sid') + + echo " Call SID: $CALL_SID" | tee -a $LOG_FILE + + # Wait for call to complete + sleep 10 + + # Check status + STATUS=$(curl -s "https://api.twilio.com/2010-04-01/Accounts/$ACCOUNT_SID/Calls/$CALL_SID.json" \ + -u "$ACCOUNT_SID:$AUTH_TOKEN" \ + | jq -r '.status') + + echo " Status: $STATUS" | tee -a $LOG_FILE + + # Check for errors + ERROR=$(curl -s "https://api.twilio.com/2010-04-01/Accounts/$ACCOUNT_SID/Calls/$CALL_SID/Notifications.json" \ + -u "$ACCOUNT_SID:$AUTH_TOKEN" \ + | jq -r '.notifications[0].error_code // "none"') + + if [ "$ERROR" != "none" ]; then + echo " ❌ ERROR: $ERROR" | tee -a $LOG_FILE + ERROR_MSG=$(curl -s "https://api.twilio.com/2010-04-01/Accounts/$ACCOUNT_SID/Calls/$CALL_SID/Notifications.json" \ + -u "$ACCOUNT_SID:$AUTH_TOKEN" \ + | jq -r '.notifications[0].message_text') + echo " Message: $ERROR_MSG" | tee -a $LOG_FILE + elif [ "$STATUS" = "no-answer" ] || [ "$STATUS" = "completed" ]; then + echo " ✓ Success" | tee -a $LOG_FILE + else + echo " ⚠ Unexpected status: $STATUS" | tee -a $LOG_FILE + fi + + echo "" | tee -a $LOG_FILE + + # Wait 5 minutes (minus the 10 seconds we already waited) + echo " Waiting 5 minutes until next call..." | tee -a $LOG_FILE + sleep 290 +done