summaryrefslogtreecommitdiffabout
path: root/gammu/emb/common/protocol/nokia/phonet.c
Unidiff
Diffstat (limited to 'gammu/emb/common/protocol/nokia/phonet.c') (more/less context) (ignore whitespace changes)
-rw-r--r--gammu/emb/common/protocol/nokia/phonet.c9
1 files changed, 9 insertions, 0 deletions
diff --git a/gammu/emb/common/protocol/nokia/phonet.c b/gammu/emb/common/protocol/nokia/phonet.c
index db5bd72..495a1bf 100644
--- a/gammu/emb/common/protocol/nokia/phonet.c
+++ b/gammu/emb/common/protocol/nokia/phonet.c
@@ -1,53 +1,62 @@
1/* (c) 2002-2003 by Marcin Wiacek */ 1/* (c) 2002-2003 by Marcin Wiacek */
2/* Based on some work from Gnokii (www.gnokii.org) 2/* Based on some work from Gnokii (www.gnokii.org)
3 * (C) 1999-2000 Hugh Blemings & Pavel Janik ml. (C) 2001-2004 Pawel Kot 3 * (C) 1999-2000 Hugh Blemings & Pavel Janik ml. (C) 2001-2004 Pawel Kot
4 * GNU GPL version 2 or later 4 * GNU GPL version 2 or later
5 */ 5 */
6/* Due to a problem in the source code management, the names of some of
7 * the authors have unfortunately been lost. We do not mean to belittle
8 * their efforts and hope they will contact us to see their names
9 * properly added to the Copyright notice above.
10 * Having published their contributions under the terms of the GNU
11 * General Public License (GPL) [version 2], the Copyright of these
12 * authors will remain respected by adhering to the license they chose
13 * to publish their code under.
14 */
6 15
7#include "../../gsmstate.h" 16#include "../../gsmstate.h"
8 17
9#if defined(GSM_ENABLE_IRDA) || defined(GSM_ENABLE_PHONETBLUE) || defined(GSM_ENABLE_BLUEPHONET) 18#if defined(GSM_ENABLE_IRDA) || defined(GSM_ENABLE_PHONETBLUE) || defined(GSM_ENABLE_BLUEPHONET)
10 19
11#include <stdio.h> 20#include <stdio.h>
12#include <string.h> 21#include <string.h>
13 22
14#include "../../gsmcomon.h" 23#include "../../gsmcomon.h"
15#include "phonet.h" 24#include "phonet.h"
16 25
17 static GSM_Error PHONET_WriteMessage (GSM_StateMachine *s, 26 static GSM_Error PHONET_WriteMessage (GSM_StateMachine *s,
18 unsigned char *MsgBuffer, 27 unsigned char *MsgBuffer,
19 int MsgLength, 28 int MsgLength,
20 unsigned char MsgType) 29 unsigned char MsgType)
21{ 30{
22 unsigned char *buffer2; 31 unsigned char *buffer2;
23 int sent; 32 int sent;
24 33
25 GSM_DumpMessageLevel3(s, MsgBuffer, MsgLength, MsgType); 34 GSM_DumpMessageLevel3(s, MsgBuffer, MsgLength, MsgType);
26 35
27 buffer2 = (unsigned char *)malloc(MsgLength + 6); 36 buffer2 = (unsigned char *)malloc(MsgLength + 6);
28 37
29 buffer2[0] = PHONET_FRAME_ID, 38 buffer2[0] = PHONET_FRAME_ID,
30 buffer2[1] = PHONET_DEVICE_PHONE; //destination 39 buffer2[1] = PHONET_DEVICE_PHONE; //destination
31 buffer2[2] = PHONET_DEVICE_PC; //source 40 buffer2[2] = PHONET_DEVICE_PC; //source
32 41
33 if (s->ConnectionType==GCT_PHONETBLUE || s->ConnectionType==GCT_BLUEPHONET) { 42 if (s->ConnectionType==GCT_PHONETBLUE || s->ConnectionType==GCT_BLUEPHONET) {
34 buffer2[0] = PHONET_BLUE_FRAME_ID; 43 buffer2[0] = PHONET_BLUE_FRAME_ID;
35 buffer2[1] = PHONET_DEVICE_PHONE;//destination 44 buffer2[1] = PHONET_DEVICE_PHONE;//destination
36 buffer2[2] = PHONET_BLUE_DEVICE_PC;//source 45 buffer2[2] = PHONET_BLUE_DEVICE_PC;//source
37 } 46 }
38 47
39 buffer2[3] = MsgType; 48 buffer2[3] = MsgType;
40 buffer2[4] = MsgLength / 256; 49 buffer2[4] = MsgLength / 256;
41 buffer2[5] = MsgLength % 256; 50 buffer2[5] = MsgLength % 256;
42 51
43 memcpy(buffer2 + 6, MsgBuffer, MsgLength); 52 memcpy(buffer2 + 6, MsgBuffer, MsgLength);
44 53
45 GSM_DumpMessageLevel2(s, buffer2+6, MsgLength, MsgType); 54 GSM_DumpMessageLevel2(s, buffer2+6, MsgLength, MsgType);
46 55
47 /* Sending to phone */ 56 /* Sending to phone */
48 sent = s->Device.Functions->WriteDevice(s,buffer2,MsgLength+6); 57 sent = s->Device.Functions->WriteDevice(s,buffer2,MsgLength+6);
49 58
50 free(buffer2); 59 free(buffer2);
51 60
52 if (sent!=MsgLength+6) return ERR_DEVICEWRITEERROR; 61 if (sent!=MsgLength+6) return ERR_DEVICEWRITEERROR;
53 return ERR_NONE; 62 return ERR_NONE;