Example #1
0
int CardDevice::at_response_clip(char* str, size_t len)
{
    if (m_initialized && m_needring == 0)
    {
	m_incoming = 1;
	String clip = at_parse_clip(str, len);
	if (clip.null())
	    Debug(DebugAll, "[%s] Error parsing CLIP: %s", c_str(), str);
	if(incomingCall(clip) == false)
	{
	    Debug(DebugAll, "[%s] Unable to allocate channel for incoming call", c_str());
	    m_commandQueue.append(new ATCommand("AT+CHUP", CMD_AT_CHUP));
	    return -1;
	}
	m_needchup = 1;
	m_needring = 1;
    }
    return 0;
}
Example #2
0
static inline int at_response_clip (pvt_t* pvt, char* str, size_t len)
{
	struct ast_channel*	channel;
	char*			clip;

	if (pvt->initialized && pvt->has_voice && pvt->needring == 0)
	{
		pvt->incoming = 1;

		if ((clip = at_parse_clip (pvt, str, len)) == NULL)
		{
			ast_log (LOG_ERROR, "[%s] Error parsing CLIP: %s\n", pvt->id, str);
		}

		// pvt->number ? pvt->number : pvt->exten???
		if (!(channel = channel_new (pvt, AST_STATE_RING, clip, pvt->number ? pvt->number : NULL, NULL)))
		{
			ast_log (LOG_ERROR, "[%s] Unable to allocate channel for incoming call\n", pvt->id);

			if (at_send_chup (pvt) || at_fifo_queue_add (pvt, CMD_AT_CHUP, RES_OK))
			{
				ast_log (LOG_ERROR, "[%s] Error sending AT+CHUP command\n", pvt->id);
			}

			return -1;
		}

		pvt->needchup = 1;
		pvt->needring = 1;

		if (ast_pbx_start (channel))
		{
			ast_log (LOG_ERROR, "[%s] Unable to start pbx on incoming call\n", pvt->id);
			channel_ast_hangup (pvt);

			return -1;
		}
	}

	return 0;
}