1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
|
/* DVB CI MMI */
#include <lib/dvb_ci/dvbci_mmi.h>
#include <lib/dvb_ci/dvbci_ui.h>
#include <string>
/*
PyObject *list = PyList_New(len);
for (i=0; i<len; ++i) {
PyObject *tuple = PyTuple_New(3); // 3 eintrge im tuple
PyTuple_SetItem(tuple, 0, PyString_FromString("eintrag 1"))
PyTuple_SetItem(tuple, 1, PyInt_FromLong(31337));
PyTuple_SetItem(tuple, 2, PyString_FromString("eintrag 3"))
PyList_SetItem(list, i, tuple);
}
return list;
*/
eDVBCIMMISession::eDVBCIMMISession(eDVBCISlot *tslot)
{
slot = tslot;
slot->setMMIManager(this);
}
eDVBCIMMISession::~eDVBCIMMISession()
{
slot->setMMIManager(NULL);
eDVBCI_UI::getInstance()->mmiSessionDestroyed(slot->getSlotID());
}
int eDVBCIMMISession::receivedAPDU(const unsigned char *tag, const void *data, int len)
{
eDebugNoNewLine("SESSION(%d)/MMI %02x %02x %02x: ", session_nb, tag[0], tag[1],tag[2]);
for (int i=0; i<len; i++)
eDebugNoNewLine("%02x ", ((const unsigned char*)data)[i]);
eDebug("");
if ((tag[0]==0x9f) && (tag[1]==0x88))
if (eDVBCI_UI::getInstance()->processMMIData(slot->getSlotID(), tag, data, len) == 1)
{
state=stateDisplayReply;
return 1;
}
return 0;
}
int eDVBCIMMISession::doAction()
{
switch (state)
{
case stateStarted:
state=stateIdle;
break;
case stateDisplayReply:
{
unsigned char tag[]={0x9f, 0x88, 0x02};
unsigned char data[]={0x01, 0x01};
sendAPDU(tag, data, 2);
state=stateIdle;
//state=stateFakeOK;
//return 1;
break;
}
case stateFakeOK:
{
unsigned char tag[]={0x9f, 0x88, 0x0b};
unsigned char data[]={5};
sendAPDU(tag, data, 1);
state=stateIdle;
break;
}
case stateIdle:
break;
default:
break;
}
return 0;
}
int eDVBCIMMISession::stopMMI()
{
eDebug("eDVBCIMMISession::stopMMI()");
unsigned char tag[]={0x9f, 0x88, 0x00};
unsigned char data[]={0x00};
sendAPDU(tag, data, 1);
return 0;
}
int eDVBCIMMISession::answerText(int answer)
{
eDebug("eDVBCIMMISession::answerText(%d)",answer);
unsigned char tag[]={0x9f, 0x88, 0x0B};
unsigned char data[]={0x00};
data[0] = answer & 0xff;
sendAPDU(tag, data, 1);
return 0;
}
int eDVBCIMMISession::answerEnq(char *answer)
{
unsigned int len = strlen(answer);
eDebug("eDVBCIMMISession::answerEnq(%d bytes)", len);
unsigned char data[len+1];
data[0] = 0x01; // answer ok
memcpy(data+1, answer, len);
unsigned char tag[]={0x9f, 0x88, 0x08};
sendAPDU(tag, data, len+1);
return 0;
}
int eDVBCIMMISession::cancelEnq()
{
eDebug("eDVBCIMMISession::cancelEnq()");
unsigned char tag[]={0x9f, 0x88, 0x08};
unsigned char data[]={0x00}; // canceled
sendAPDU(tag, data, 1);
return 0;
}
|