add mmi
authorRonny Strutz <ronny.strutz@multimedia-labs.de>
Fri, 12 Aug 2005 20:22:28 +0000 (20:22 +0000)
committerRonny Strutz <ronny.strutz@multimedia-labs.de>
Fri, 12 Aug 2005 20:22:28 +0000 (20:22 +0000)
lib/dvb_ci/Makefile.am
lib/dvb_ci/dvbci_mmi.cpp [new file with mode: 0644]
lib/dvb_ci/dvbci_mmi.h [new file with mode: 0644]
lib/dvb_ci/dvbci_session.cpp

index f260028..85940da 100644 (file)
@@ -5,5 +5,5 @@ noinst_LIBRARIES = libenigma_dvb_ci.a
 
 libenigma_dvb_ci_a_SOURCES = dvbci.cpp dvbci_session.cpp dvbci_resmgr.cpp \
                                                                                                                 dvbci_appmgr.cpp dvbci_camgr.cpp \
-                                                                                                                dvbci_datetimemgr.cpp
+                                                                                                                dvbci_datetimemgr.cpp dvbci_mmi.cpp
 
diff --git a/lib/dvb_ci/dvbci_mmi.cpp b/lib/dvb_ci/dvbci_mmi.cpp
new file mode 100644 (file)
index 0000000..463c91b
--- /dev/null
@@ -0,0 +1,92 @@
+/* DVB CI MMI */
+
+#include <lib/dvb_ci/dvbci_mmi.h>
+
+int eDVBCIMMISession::receivedAPDU(const unsigned char *tag, const void *data, int len)
+{
+       printf("SESSION(%d)/MMI %02x %02x %02x: ", session_nb, tag[0], tag[1],tag[2]);
+       for (int i=0; i<len; i++)
+               printf("%02x ", ((const unsigned char*)data)[i]);
+       printf("\n");
+
+       if ((tag[0]==0x9f) && (tag[1]==0x88))
+       {
+               switch (tag[2])
+               {
+                       case 0x01:
+                       printf("MMI display control\n");
+                       if (((unsigned char*)data)[0] != 1)
+                               printf("kann ich nicht. aber das sag ich dem modul nicht.\n");
+                       state=stateDisplayReply;
+                       return 1;
+               case 0x09:
+               case 0x0c:
+               {
+                       unsigned char *d=(unsigned char*)data;
+                       unsigned char *max=((unsigned char*)d) + len;
+                       printf("Tmenu_last\n");
+                       if (d > max)
+                               break;
+                       int n=*d++;
+                       if (n == 0xFF)
+                               n=0;
+                       else
+                               n++;
+                       printf("%d texts\n", n);
+                       for (int i=0; i < (n+3); ++i)
+                       {
+                               int textlen;
+                               if ((d+3) > max)
+                                       break;
+                               printf("text tag: %02x %02x %02x\n", d[0], d[1], d[2]);
+                               d+=3;
+                               d+=parseLengthField(d, textlen);
+                               printf("%d bytes text\n", textlen);
+                               if ((d+textlen) > max)
+                                       break;
+                               while (textlen--)
+                                       printf("%c", *d++);
+                               printf("\n");
+                       }
+                       break;
+               }
+               default:
+                       printf("unknown APDU tag 9F 88 %02x\n", tag[2]);
+                       break;
+               }
+       }
+       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=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;
+}
+
diff --git a/lib/dvb_ci/dvbci_mmi.h b/lib/dvb_ci/dvbci_mmi.h
new file mode 100644 (file)
index 0000000..2339fb3
--- /dev/null
@@ -0,0 +1,16 @@
+#ifndef __dvbci_dvbci_mmi_h
+#define __dvbci_dvbci_mmi_h
+
+#include <lib/dvb_ci/dvbci_session.h>
+
+class eDVBCIMMISession: public eDVBCISession
+{
+       enum {
+               stateDisplayReply=statePrivate, stateFakeOK, stateIdle
+       };
+       int receivedAPDU(const unsigned char *tag, const void *data, int len);
+       int doAction();
+public:
+};
+
+#endif
index a9c26d1..72495a9 100644 (file)
@@ -5,6 +5,7 @@
 #include <lib/dvb_ci/dvbci_appmgr.h>
 #include <lib/dvb_ci/dvbci_camgr.h>
 #include <lib/dvb_ci/dvbci_datetimemgr.h>
+#include <lib/dvb_ci/dvbci_mmi.h>
 
 int eDVBCISession::buildLengthField(unsigned char *pkt, int len)
 {
@@ -143,7 +144,7 @@ eDVBCISession *eDVBCISession::createSession(eDVBCISlot *slot, const unsigned cha
                printf("DATE-TIME\n");
                break;
        case 0x00400041:
-//             session=new eDVBCIMMISession;
+               session=new eDVBCIMMISession;
                printf("MMI\n");
                break;
        case 0x00100041: