⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 mfw_sat.c

📁 GSM手机设计软件代码
💻 C
📖 第 1 页 / 共 5 页
字号:

    if (res > 1)
    {
        t->len = curLen;                /* data len                 */
        curData -= curLen;
        memcpy(curData,curVal,curLen);  /* data itself              */
        t->data = (U16) (curData - (U8*) t); /* save the offset     */
        return 1;
    }

    return res;
}


/*
+--------------------------------------------------------------------+
| PROJECT : MMI-Framework (8417)        MODULE  : MFW_SAT            |
| STATE   : code                        ROUTINE : decText            |
+--------------------------------------------------------------------+

  PURPOSE : decode TLV: text string

*/

static U8 decText (SatTxt *t, U8 tagWanted, U8 mandatory)
{
    U8 res;

    TRACE_FUNCTION("decText()");

    res = decTLV(tagWanted,mandatory,"text");

    if (res > 1)
    {
        t->len = curLen - 1;            /* text len (not dcs)       */
        if (t->len)
            t->code = *curVal;          /* data coding scheme       */
        else
            t->code = 0;
        curData -= t->len;
        memcpy(curData,curVal+1,t->len); /* text itself             */
        t->text = (U16) (curData - (U8*) t); /* save the offset     */
        return 1;
    }

    return res;
}


/*
+--------------------------------------------------------------------+
| PROJECT : MMI-Framework (8417)        MODULE  : MFW_SAT            |
| STATE   : code                        ROUTINE : decAddrSS          |
+--------------------------------------------------------------------+

  PURPOSE : decode TLV: address or SS string

*/

static U8 decAddrSS (SatAddress *t, U8 tagWanted, U8 mandatory)
{
    U8 res;

    TRACE_FUNCTION("decAddr-SS()");

    res = decTLV(tagWanted,mandatory,"Addr-SS");

    if (res > 1)                        /* address or ss string     */
    {
        t->len = curLen - 1;            /* number len wo ton/npi    */
        curData -= t->len;
        t->ton = *curVal;               /* type of number, npi      */
        memcpy(curData,curVal+1,t->len); /* number itself           */
        t->number = (U16) (curData - (U8*) t); /* offset            */
        return 1;
    }

    return res;
}


/*
+--------------------------------------------------------------------+
| PROJECT : MMI-Framework (8417)        MODULE  : MFW_SAT            |
| STATE   : code                        ROUTINE : decAlpha           |
+--------------------------------------------------------------------+

  PURPOSE : decode TLV: alpha identifier

*/

static U8 decAlpha (SatTxt *t, U8 mandatory)
{
    U8 res;

    TRACE_FUNCTION("decAlpha()");

    res = decTLV(0x05,mandatory,"Alpha");

    if (curTag == 0x05)
    {
        t->len = curLen;                /* text len                 */
        if (t->len)
            t->code = 0x04;             /* data coding scheme       */
        else
            t->code = 0;
        curData -= t->len;
        memcpy(curData,curVal,t->len);  /* text itself              */
        t->text = (U16) (curData - (U8*) t); /* save the offset     */
        return 1;
    }

    return res;
}



/*
+--------------------------------------------------------------------+
| PROJECT : MMI-Framework (8417)        MODULE  : MFW_SAT            |
| STATE   : code                        ROUTINE : decSMS             |
+--------------------------------------------------------------------+

  PURPOSE : decode TLV: SMS TPDU

*/

static U8 decSMS (SatSmsPdu *t, U8 mandatory)
{
    U8 res;

    TRACE_FUNCTION("decSMS()");

    res = decTLV(0x0B,mandatory,"SMS TPDU");

    if (res > 1)
    {
        t->len = curLen;                /* SMS len                  */
        curData -= t->len;
        memcpy(curData,curVal,t->len);  /* SMS itself               */
        t->data = (U16) (curData - (U8*) t); /* save the offset     */
        return 1;
    }

    return res;
}


/*
+--------------------------------------------------------------------+
| PROJECT : MMI-Framework (8417)        MODULE  : MFW_SAT            |
| STATE   : code                        ROUTINE : decItem            |
+--------------------------------------------------------------------+

  PURPOSE : decode TLV: item

*/

static U8 decItem (SatItem *t, U8 mandatory)
{
    U8 res;

    TRACE_FUNCTION("decItem()");

    res = decTLV(0x0F,mandatory,"Item");

    if (res > 1)
    {
        if (!curLen)                    /* no item: remove menu     */
        {
            t->id = 0;                  /* no id                    */
            t->len = 0;                 /* no length                */
        }
        else
        {
            t->id = *curVal;
            t->len = curLen - 1;        /* without item id          */
        }
        t->action = 0;                  /* filled in later          */
        t->icon = 0;                    /* filled in later          */
        curData -= t->len;
        memcpy(curData,curVal+1,t->len); /* item data               */
        t->text = (U16) (curData - (U8*) t); /* save the offset     */
        return 1;
    }

    return res;
}


/*
+--------------------------------------------------------------------+
| PROJECT : MMI-Framework (8417)        MODULE  : MFW_SAT            |
| STATE   : code                        ROUTINE : decNextAction      |
+--------------------------------------------------------------------+

  PURPOSE : decode TLV: next action

*/

static U8 decNextAction (SatItem *t, U8 nItems, U8 mandatory)
{
    U8 res;

    TRACE_FUNCTION("decNextAction()");

    res = decTLV(0x18,mandatory,"Next Action");

    if (res > 1)
    {
        if (nItems > curLen)
            nItems = curLen;
        while (nItems--)
        {
            t->action = *curVal++;      /* next action identifier   */
            t++;
        }
        return 1;
    }

    return res;
}


/*
+--------------------------------------------------------------------+
| PROJECT : MMI-Framework (8417)        MODULE  : MFW_SAT            |
| STATE   : code                        ROUTINE : decItemIcons       |
+--------------------------------------------------------------------+

  PURPOSE : decode TLV: icon identifier list

*/

static U8 decItemIcons (SatMenu *m, SatItem *t, U8 nItems, U8 mandatory)
{
    U8 res;

    TRACE_FUNCTION("decItemIcons()");

    res = decTLV(0x1F,mandatory,"Item Icon List");

    m->itemIconQual = 0xFF;             /* default: not present     */
    if (res > 1)
    {
        m->itemIconQual = *curVal++;
        curLen--;
        if (nItems > curLen)
            nItems = curLen;
        while (nItems--)
        {
            t->icon = *curVal++;        /* next action identifier   */
            t++;
        }
        return 1;
    }

    return res;
}


/*
+--------------------------------------------------------------------+
| PROJECT : MMI-Framework (8417)        MODULE  : MFW_SAT            |
| STATE   : code                        ROUTINE : decDefItem         |
+--------------------------------------------------------------------+

  PURPOSE : decode TLV: default item

*/

static U8 decDefItem (SatItem *t, U8 nItems, U8 mandatory)
{
    U8 res;

    TRACE_FUNCTION("decDefItem()");

    res = decTLV(0x10,mandatory,"Default Item");

    if (res > 1)
    {
        if (curLen != 1)
            return res;                 /* ES!! error               */
        while (nItems--)
        {
            if (t->id == *curVal)
                t->action |= 0x40;      /* flag as default          */
            t++;
        }
        return 1;
    }

    return res;
}


/*
+--------------------------------------------------------------------+
| PROJECT : MMI-Framework (8417)        MODULE  : MFW_SAT            |
| STATE   : code                        ROUTINE : decTone            |
+--------------------------------------------------------------------+

  PURPOSE : decode TLV: tone

*/

static U8 decTone (U8 mandatory)
{
    U8 res;

    TRACE_FUNCTION("decTone()");

    res = decTLV(0x0E,mandatory,"Tone");

    if (res > 1)
    {
        cmd.c.tone.tone = *curVal;      /* tone type                */
        return 1;
    }

    return res;
}


/*
+--------------------------------------------------------------------+
| PROJECT : MMI-Framework (8417)        MODULE  : MFW_SAT            |
| STATE   : code                        ROUTINE : decDuration        |
+--------------------------------------------------------------------+

  PURPOSE : decode TLV: duration

*/

static U8 decDuration (U8 *dur, U8 mandatory)
{
    U8 res;

    TRACE_FUNCTION("decDuration()");

    res = decTLV(0x04,mandatory,"Duration");

    if (res > 1)
    {
        *dur++ = *curVal++;             /* duration unit            */
        *dur++ = *curVal;               /* duration value           */
        return 1;
    }

    return res;
}


/*
+--------------------------------------------------------------------+
| PROJECT : MMI-Framework (8417)        MODULE  : MFW_SAT            |
| STATE   : code                        ROUTINE : decDevId           |
+--------------------------------------------------------------------+

  PURPOSE : decode TLV: device identities

*/

static U8 decDevId (U8 mandatory)
{
    U8 res;

    TRACE_FUNCTION("decDevId()");

    res = decTLV(0x02,mandatory,"Devices");

    if (res > 1)
    {
        cmd.source = *curVal++;         /* source identifier        */
        cmd.dest = *curVal;             /* destination identifier   */
        return 1;
    }

    return res;
}


/*
+--------------------------------------------------------------------+
| PROJECT : MMI-Framework (8417)        MODULE  : MFW_SAT            |
| STATE   : code                        ROUTINE : decRespLen         |
+--------------------------------------------------------------------+

  PURPOSE : decode TLV: response length

*/

static U8 decRespLen (U8 mandatory)
{
    U8 res;

    TRACE_FUNCTION("decRespLen()");

    res = decTLV(0x11,mandatory,"Response Length");

    if (res > 1)
    {
        cmd.c.inp.rspMin = *curVal++;   /* minimal length           */
        cmd.c.inp.rspMax = *curVal;     /* maximal length           */
        return 1;
    }

    return res;
}


/*
+--------------------------------------------------------------------+
| PROJECT : MMI-Framework (8417)        MODULE  : MFW_SAT            |
| STATE   : code                        ROUTINE : decIconId          |
+--------------------------------------------------------------------+

  PURPOSE : decode TLV: icon identifier

*/

static U8 decIconId (SatIconId *id, U8 mandatory)
{
    U8 res;

    TRACE_FUNCTION("decIconId()");

    res = decTLV(0x1E,mandatory,"IconID");

    if (res > 1)
    {
        id->qual = *curVal++;           /* icon qualifier           */
        id->id = *curVal;               /* icon identifier          */
        return 1;
    }
    else
    {
        id->qual = 0xFF;                /* not present              */
        id->id = 0xFF;
    }

    return res;
}


/*
+--------------------------------------------------------------------+
| PROJECT : MMI-Framework (8417)        MODULE  : MFW_SAT            |
| STATE   : code                        ROUTINE : decRespFlag        |
+--------------------------------------------------------------------+

  PURPOSE : decode TLV: icon identifier

*/

static U8 decRespFlag (U8 *flag, U8 mandatory)
{
    U8 res;

    TRACE_FUNCTION("decRespFlag()");

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -