?? dial.c
字號:
#include "handsfree_private.h"
#include "handsfree.h"
#include <message.h>
#include <stdlib.h>
#include <string.h>
/*
TODO: Set up the state machine so even if the driver sends
unexpected cmds e.g ATA when already connected then those are
ignored or an error is flagged.
*/
/* Contains functions for dialing from the hands-free device */
/*
storeNumber
Store a number (or memory location) to dial while a connection is
being set up.
*/
static void storeNumber(uint16 num_length, const uint8 *dial_num)
{
HFstate.numberLength = num_length;
if (HFstate.numberLength)
{
HFstate.numberToDial = (uint8 *)hfAlloc(num_length);
memcpy(HFstate.numberToDial, dial_num, num_length);
}
else
{
HFstate.numberToDial = 0;
}
}
/*
sendDialMessage
If possible send a request to the Audio GAteway to perform
remote dialling from the hands-free. Three types of remote dialling
specified by the profile - hands-free supplied number, number in
memory location supplied by the hands-free and last number redial
*/
static uint16 sendDialMessage(dial_type_t dial, const uint8 *number, uint16 length)
{
/*
If one of those flags s set then there is a dial request already
pending so reject this one.
*/
if (!HFstate.dialNumberPending && !HFstate.dialMemoryPending &&
!HFstate.dialLastNumberPending)
{
/*
If a connection exists send the dial request to the framework
otherwise try setting up a connection first
*/
if (isLocalStateConnected())
{
/* Create message and send it to hands free lib */
MAKE_MSG(HANDSFREE_REMOTE_DIAL_REQ);
msg->type = dial;
msg->length = length;
/* Check we actually have data to send */
if (length)
{
msg->number = (uint8 *)hfAlloc(length);
memcpy(msg->number, number, length);
}
else
{
msg->number = 0;
}
putMsg(msg);
/* Sent message off ok so return success. */
return 1;
}
else
{
/* Need to store the number for when the connection is set up */
storeNumber(length, number);
/* Send the connect request */
connectReqAction();
/* Dial request still pending to be sent on. */
return 0;
}
}
else
{
/* Signal an error to the interface */
handleErrorInd(HfErrorDialRequestPendingAlready);
return 0;
}
}
/*
hfCheckDialPendingFlags
Called when a connection has been set up to check whether there
was a dial action pending.
*/
void hfCheckDialPendingFlags(void)
{
if (HFstate.dialNumberPending)
{
/* Reset the dial pending flag because we can't keep retrying */
HFstate.dialNumberPending = 0;
/* Try to send the dial request */
(void) sendDialMessage(handsfreeDialNumber, HFstate.numberToDial, HFstate.numberLength);
}
else if (HFstate.dialMemoryPending)
{
/* Reset the dial pending flag because we can't keep retrying */
HFstate.dialMemoryPending = 0;
/* Try to send the dial request */
(void) sendDialMessage(handsfreeDialMemory, HFstate.numberToDial, HFstate.numberLength);
}
else if (HFstate.dialLastNumberPending)
{
/* Reset the dial pending flag because we can't keep retrying */
HFstate.dialLastNumberPending = 0;
/* Try to send the dial request */
(void) sendDialMessage(handfreeDialLastNumber, 0, 0);
}
/*
If we had stored a number free it since we're not going to try
sending this again
*/
if (HFstate.numberLength)
{
HFstate.numberLength = 0;
free(HFstate.numberToDial);
}
}
/*
dialNumberAction
Send a request to dial the number provided by the interface.
*/
void dialNumberAction(uint8 *dial_number, uint16 num_length)
{
if (sendDialMessage(handsfreeDialNumber, dial_number, num_length))
HFstate.dialNumberPending = 0;
else
HFstate.dialNumberPending = 1;
}
/*
dialMemoryAction
Dial the requested memory location.
*/
void dialMemoryAction(uint8 *mem, uint16 length)
{
if (sendDialMessage(handsfreeDialMemory, mem, length))
HFstate.dialMemoryPending = 0;
else
HFstate.dialMemoryPending = 1;
}
/*
lastNumberRedial
Request to redial the last number dialled.
*/
void lastNumberRedialAction(void)
{
if (sendDialMessage(handfreeDialLastNumber, 0, 0))
HFstate.dialLastNumberPending = 0;
else
HFstate.dialLastNumberPending = 1;
}
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -