how to get caller id in VoIP example.

alatif
Posts: 2
Joined: Thu Jan 04, 2024 8:29 am

how to get caller id in VoIP example.

Postby alatif » Thu Jan 04, 2024 8:37 am

Hi,
i can run the voip app example without any problem.
https://github.com/espressif/esp-adf/tr ... ocols/voip

is there any way to get caller id when there is incoming call event to esp32.
thank you.

alatif
Posts: 2
Joined: Thu Jan 04, 2024 8:29 am

Re: how to get caller id in VoIP example.

Postby alatif » Fri Jan 05, 2024 2:12 am

in the voip app v2.4 release https://github.com/espressif/esp-adf/tr ... mples/voip
we can get the caller id using this line of code

Code: Select all

ESP_LOGI(TAG, "ringing... RemotePhoneNum %s", (char *)event->data);
how can i get that caller id in the current master branch?

Code: Select all

static int _sip_event_handler(sip_event_msg_t *event)
{
    ip4_addr_t ip;
    switch ((int)event->type) {
        case SIP_EVENT_REQUEST_NETWORK_STATUS:
            ESP_LOGD(TAG, "SIP_EVENT_REQUEST_NETWORK_STATUS");
            ip = _get_network_ip();
            if (ip.addr) {
                return true;
            }
            return ESP_OK;
        case SIP_EVENT_REQUEST_NETWORK_IP:
            ESP_LOGD(TAG, "SIP_EVENT_REQUEST_NETWORK_IP");
            ip = _get_network_ip();
            int ip_len = sprintf((char *)event->data, "%s", ip4addr_ntoa(&ip));
            return ip_len;
        case SIP_EVENT_REGISTERED:
            ESP_LOGI(TAG, "SIP_EVENT_REGISTERED");
            audio_player_int_tone_play(tone_uri[TONE_TYPE_SERVER_CONNECT]);
            break;
        case SIP_EVENT_RINGING:
            ESP_LOGI(TAG, "ringing... RemotePhoneNum %s", (char *)event->data);
            audio_player_int_tone_play(tone_uri[TONE_TYPE_ALARM]);
            break;
        case SIP_EVENT_INVITING:
            ESP_LOGI(TAG, "SIP_EVENT_INVITING Remote Ring...");
            break;
        case SIP_EVENT_ERROR:
            ESP_LOGI(TAG, "SIP_EVENT_ERROR");
            break;
        case SIP_EVENT_HANGUP:
            ESP_LOGI(TAG, "SIP_EVENT_HANGUP");
            break;
        case SIP_EVENT_AUDIO_SESSION_BEGIN:
            ESP_LOGI(TAG, "SIP_EVENT_AUDIO_SESSION_BEGIN");
            recorder_pipeline_open();
            player_pipeline_open();
            audio_pipeline_run(player);
            audio_pipeline_run(recorder);
            break;
        case SIP_EVENT_AUDIO_SESSION_END:
            ESP_LOGI(TAG, "SIP_EVENT_AUDIO_SESSION_END");
            audio_pipeline_stop(player);
            audio_pipeline_wait_for_stop(player);
            audio_pipeline_deinit(player);
            audio_pipeline_stop(recorder);
            audio_pipeline_wait_for_stop(recorder);
            audio_pipeline_deinit(recorder);
            break;
        case SIP_EVENT_READ_AUDIO_DATA:
#if (DEBUG_AEC_INPUT || DEBUG_AEC_OUTPUT)
            vTaskDelay(20 / portTICK_PERIOD_MS);
            memset((char *)event->data, 0, event->data_len);
            return event->data_len;
#else
            return raw_stream_read(raw_read, (char *)event->data, event->data_len);
#endif
        case SIP_EVENT_WRITE_AUDIO_DATA:
            return raw_stream_write(raw_write, (char *)event->data, event->data_len);
        case SIP_EVENT_READ_DTMF:
            ESP_LOGI(TAG, "SIP_EVENT_READ_DTMF ID : %d ", ((char *)event->data)[0]);
            break;
    }
    return 0;
}

Who is online

Users browsing this forum: No registered users and 13 guests