4 * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
7 * Sooyoung Ha <yoosah.ha@samsung.com>
8 * Sungmin Ha <sungmin82.ha@samsung.com>
9 * YeongKyoon Lee <yeongkyoon.lee@samsung.com>
11 * This library is free software; you can redistribute it and/or modify it under
12 * the terms of the GNU Lesser General Public License as published by the
13 * Free Software Foundation; either version 2.1 of the License, or (at your option)
16 * This library is distributed in the hope that it will be useful, but WITHOUT ANY
17 * WARRANTY; without even the implied warranty of MERCHANTABILITY or
18 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
19 * License for more details.
21 * You should have received a copy of the GNU Lesser General Public License
22 * along with this library; if not, write to the Free Software Foundation, Inc., 51
23 * Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
31 /////////////////////////////////////////////////////////////////////
40 static HDLCFrame_t s_FrameSentInfo;
41 static HDLCFrame_t s_FrameRecvInfo;
43 // Last sent HDLC frame info
44 void ATSetLastSentHDLCFrameInfo(HDLCFrame_t const* pframe)
46 s_FrameSentInfo.m_CtrlInfo = pframe->m_CtrlInfo;
47 s_FrameSentInfo.m_Length = pframe->m_Length;
50 HDLCFrame_t const* ATGetLastSentHDLCFrameInfo(void)
52 return &s_FrameSentInfo;
55 // Last receive HDLC frame info
56 void ATSetLastRecvHDLCFrameInfo(HDLCFrame_t const* pframe)
58 // TRACE(MSGL_VGSM_INFO, "\n");
59 s_FrameRecvInfo.m_CtrlInfo = pframe->m_CtrlInfo;
60 s_FrameRecvInfo.m_Length = pframe->m_Length;
63 HDLCFrame_t const* ATGetLastRecvHDLCFrameInfo(void)
65 return &s_FrameRecvInfo;
68 static char* s_ATSentInfo;
69 static char* s_ATRecvInfo;
71 // Last sent AT frame info
72 void SetLastSentAT(char* atmsg)
77 char* GetLastSentAT(void)
83 void SetLastRecvAT(char* atmsg)
88 char* GetLastRecvAT(void)
93 // For multi HDLC frame.
94 typedef struct tagHDLCNode {
95 struct tagHDLCNode* m_pNext;
96 HDLCFrame_t m_HDLCNode;
99 HDLCNode* g_ATpHead = NULL;
100 HDLCNode* g_ATpTail = NULL;
102 void ATFreeAllMultiNodeList(void)
104 TRACE(MSGL_VGSM_INFO, "\n");
107 HDLCNode* pnode = g_ATpHead;
110 pnode = pnode->m_pNext;
113 if (pnode_tmp->m_HDLCNode.m_pValue)
114 free(pnode_tmp->m_HDLCNode.m_pValue);
118 g_ATpHead = g_ATpTail = NULL;
122 ++ Name : PushHDLCMultiFrameInfo
123 ++ Args : HDLCFrame_t const* pframe
124 ++ Multi frame ÀÏ ¶§, ID¸¦ check ÇÏ´Â ºÎºÐÀÌ ¾ø´Ù.
125 ++ ID ºñ±³Çؼ ÀÌ°ÍÀÌ single messageÀÎÁö multiple messageÀÎÁö ÆÇ´ÜÇÏ´Â ºÎºÐÀÌ ÇÊ¿äÇÏ´Ù.
127 void ATPushHDLCMultiFrameInfo(HDLCFrame_t const* pframe)
129 TRACE(MSGL_VGSM_INFO, "\n");
133 HDLCNode* pnode = malloc(sizeof(HDLCNode));
138 memset(pnode, 0, sizeof(HDLCNode));
140 pnode->m_HDLCNode.m_Length = pframe->m_Length;
141 pnode->m_HDLCNode.m_CtrlInfo = pframe->m_CtrlInfo;
143 if (pframe->m_Length - 3 > 0) {
144 pnode->m_HDLCNode.m_pValue = malloc(pframe->m_Length - 3);
145 memcpy(pnode->m_HDLCNode.m_pValue, pframe->m_pValue, pframe->m_Length - 3);
152 g_ATpTail->m_pNext = pnode;
158 HDLCFrame_t const* ATGetLastRecvHDLCMultiFrameInfo(void)
160 // TRACE(MSGL_VGSM_INFO, "\n");
163 return &(g_ATpTail->m_HDLCNode);
168 char* ConvertHDLCMultiFrameToAT(void)
170 TRACE(MSGL_VGSM_INFO, "\n");
172 unsigned char* atmsg_data = NULL;
173 unsigned char* ptr = NULL;
175 HDLCNode* pnode = g_ATpHead;
178 at_size += pnode->m_HDLCNode.m_Length - 3;
179 pnode = pnode->m_pNext;
183 atmsg_data = malloc(at_size);
187 memcpy(ptr, pnode->m_HDLCNode.m_pValue, pnode->m_HDLCNode.m_Length - 3);
188 ptr += pnode->m_HDLCNode.m_Length - 3;
190 pnode = pnode->m_pNext;
194 ATFreeAllMultiNodeList();
196 return (char*)atmsg_data;