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

📄 mmi_atc.c

📁 嵌入式展讯mmi层kernel的c 源代码
💻 C
📖 第 1 页 / 共 4 页
字号:
				                uint8 *cmd,  // Point to the command infomation buffer
				                uint32 len,   // The length of command infomation buffer
                                const char* ind_ptr //the indication
				                )
{
    uint8 ind_str[MMI_MAX_INDICATE_LEN + 1] = {0};
    uint16 ind_len = 0;

    SCI_ASSERT(PNULL != cmd);
    SCI_ASSERT(PNULL != ind_ptr);

    ind_len = strlen(ind_ptr);

    strncpy((char *)ind_str, (char *)cmd, ind_len);
    if(0 == strcmp((char *)ind_str, ind_ptr))
    {
        return TRUE;
    }
    else
    {
        return FALSE;
    }
}


/*****************************************************************************/
// 	Description : This function parse at cmd wich from sync tool
//	Global resource dependence : none
//  Author:      lin.lin
//	Note:
/*****************************************************************************/
LOCAL BOOLEAN ParseSyncAtCmd(
					      uint8 *cmd,  // Point to the command infomation buffer
					      uint32 len   // The length of command infomation buffer
					      )
{
    uint8 module_type = 0;
    uint8 operation_type = 0;
    BOOLEAN recode = TRUE;

    if(!MMIATC_IsAtcRun())
    {
        SCI_TRACE_LOW("mmi_atc.c: ParseSyncAtCmd(), mmi atc is not run");
        return FALSE;
    }

    //check length, must be have module type and operation type
    //sync_alarm have only module type
    if(len < 1)
    {
        return FALSE;
    }

    module_type = *(cmd++);
    len--;
    operation_type = *(cmd++);
    len--;

    SCI_TRACE_LOW("mmi_atc.c: ParseSyncAtCmd(), module_type = %c, operation_type = %c", module_type, operation_type);

    switch(module_type)
    {
    case MMI_SYNC_PB:
        switch(operation_type) 
        {
        case MMI_SYNC_GETINFO:
            recode = HandlePbGetInfo(cmd, len);
        	break;

        case MMI_SYNC_ADD:
            recode = HandlePbAdd(cmd, len);
            break;        

        case MMI_SYNC_DELETE:
            recode = HandlePbDelete(cmd, len);
            break;

        case MMI_SYNC_MODIFY:
            recode = HandlePbModify(cmd, len);
            break;

        case MMI_SYNC_GETITEM:
            recode = HandlePbReadItem(cmd, len);
            break;

        default:
            recode = FALSE;
        }
        break;

    case MMI_SYNC_SMS:
        switch(operation_type) 
        {
        case MMI_SYNC_DELETE:
            recode = HandleSmsDelete(cmd, len);
            break;

        default:
            recode = FALSE;
        }
        break;

    case MMI_SYNC_RING:
        switch(operation_type) 
        {
        case MMI_SYNC_GETINFO:
            recode = HandleRingGetInfo(cmd, len);
        	break;
        case MMI_SYNC_ADD:
            recode = HandleRingAdd(cmd, len);
            break;        

        case MMI_SYNC_DELETE:
            recode = HandleRingDelete(cmd, len);
            break;

        case MMI_SYNC_MODIFY:
            recode = HandleRingModify(cmd, len);
            break;

        default:
            recode = FALSE;
        }
        break;

    case MMI_SYNC_PICTURE:
        switch(operation_type) 
        {
        case MMI_SYNC_GETINFO:
            recode = HandlePicGetInfo(cmd, len);
            break;

        case MMI_SYNC_ADD:
            recode = HandlePicAdd(cmd, len);
            break;        

        case MMI_SYNC_DELETE:
            recode = HandlePicDelete(cmd, len);
            break;

        case MMI_SYNC_MODIFY:
            recode = HandlePicModify(cmd, len);
            break;

        default:
            recode = FALSE;
        }
        break;

    case MMI_SYNC_ALARM:
        recode = HandleAlarmSync(cmd, len);
        break;

    default:
        recode = FALSE;
        break;
    }

    return recode;
}


/*****************************************************************************/
// 	Description : This function handle the pb getinfo command
//	Global resource dependence : none
//  Author:      lin.lin
//	Note:
/*****************************************************************************/
LOCAL BOOLEAN HandlePbGetInfo(	
                                uint8 *cmd,  // Point to the command infomation buffer
					            uint32 len   // The length of command infomation buffer
                                )
{
    PB_HEAD_INFO_T  pb_head_info;
    uint8 res_cmd[MAX_RESCMD_LEN] = {0};
    uint16 res_len = 0;    

    BOOLEAN is_in_sim = FALSE;
    if(!JudgePbInSim(&is_in_sim, *cmd))
    {
        return FALSE;
    }
    
    SCI_TRACE_LOW("mmi_atc.c: HandlePbGetInfo(), is_in_sim = %d", is_in_sim);
    
    if(MMIPB_SyncHeadInfo(&pb_head_info, is_in_sim))
    {
        SCI_TRACE_LOW("mmi_atc.c: HandlePbGetInfo(), max_record_num = %d, used_record_num = %d",
                    pb_head_info.max_record_num, pb_head_info.used_record_num);

        strcpy((char *)res_cmd, (char *)MMI_SYNC_INDICATE);
        res_len += strlen((char *)MMI_SYNC_INDICATE);

        *(res_cmd + res_len) = sizeof(PB_HEAD_INFO_T);
        res_len++;

        MMI_MEMCPY(res_cmd + res_len, MAX_RESCMD_LEN - res_len, &pb_head_info, sizeof(PB_HEAD_INFO_T), sizeof(PB_HEAD_INFO_T));
        res_len += sizeof(PB_HEAD_INFO_T);

        MMI_MEMCPY(res_cmd + res_len, MAX_RESCMD_LEN - res_len, (char *)MMI_TO_SYNC_OK_SYMBOL, strlen((char*)MMI_TO_SYNC_OK_SYMBOL), strlen((char*)MMI_TO_SYNC_OK_SYMBOL));
        res_len += strlen((char*)MMI_TO_SYNC_OK_SYMBOL);

        ReturnResponse(res_cmd, res_len);
    }
    else
    {
        ReturnResponse((uint8 *)MMI_TO_SYNC_ERROR_SYMBOL, strlen((char*)MMI_TO_SYNC_ERROR_SYMBOL));
    }
    return TRUE;
}

/*****************************************************************************/
// 	Description : This function handle the pb get one item command
//	Global resource dependence : none
//  Author:      lin.lin
//	Note:
/*****************************************************************************/
LOCAL BOOLEAN HandlePbReadItem(	
                                uint8 *cmd,  // Point to the command infomation buffer
					            uint32 len   // The length of command infomation buffer
                                )
{
    PB_PHONEBOOK_ENTRY_T  pb_item = {0};
    uint8 res_cmd[MAX_RESCMD_LEN] = {0};
    uint16 res_len = 0;    
    uint16 entry_id = 0;

    BOOLEAN is_in_sim = FALSE;
    if(!JudgePbInSim(&is_in_sim, *cmd))
    {
        return FALSE;
    }

    cmd++;    
    entry_id = GetPbEntryId(cmd, len-1) ;    
    SCI_TRACE_LOW("mmi_atc.c: HandlePbReadItem(), is_in_sim = %d, entry_id = %d", is_in_sim, entry_id);

    pb_item.entry_id = entry_id;
    if(MMIPB_SyncRead(&pb_item, is_in_sim))
    {
        SCI_TRACE_LOW("mmi_atc.c: HandlePbReadItem(), entry_id = %d", pb_item.entry_id);    

        strcpy((char *)res_cmd, (char *)MMI_SYNC_INDICATE);
        res_len += strlen((char *)MMI_SYNC_INDICATE);

        *(res_cmd + res_len) = sizeof(PB_PHONEBOOK_ENTRY_T);
        res_len++;

        MMI_MEMCPY(res_cmd + res_len, MAX_RESCMD_LEN - res_len, &pb_item, sizeof(PB_PHONEBOOK_ENTRY_T), sizeof(PB_PHONEBOOK_ENTRY_T));
        res_len += sizeof(PB_PHONEBOOK_ENTRY_T);

        MMI_MEMCPY(res_cmd + res_len, MAX_RESCMD_LEN - res_len, (char *)MMI_TO_SYNC_OK_SYMBOL, strlen((char*)MMI_TO_SYNC_OK_SYMBOL), strlen((char*)MMI_TO_SYNC_OK_SYMBOL));
        res_len += strlen((char*)MMI_TO_SYNC_OK_SYMBOL);

        ReturnResponse(res_cmd, res_len);
    }
    else
    {
        ReturnResponse((uint8 *)MMI_TO_SYNC_ERROR_SYMBOL, strlen((char*)MMI_TO_SYNC_ERROR_SYMBOL));
    }
    return TRUE;
}

/*****************************************************************************/
// 	Description : This function handle the pb add command
//	Global resource dependence : none
//  Author:      lin.lin
//	Note:
/*****************************************************************************/
LOCAL BOOLEAN HandlePbAdd(	
                            uint8 *cmd,  // Point to the command infomation buffer
					        uint32 len   // The length of command infomation buffer
                            )
{
    PB_PHONEBOOK_ENTRY_T pb_entry = {0};
    BOOLEAN is_in_sim = FALSE;

    uint16 pb_entry_size = 0;

    SCI_ASSERT(len >= 1+ sizeof(PB_PHONEBOOK_ENTRY_T));
    if(!JudgePbInSim(&is_in_sim, *cmd))
    {
        return FALSE;
    }

    cmd++;
    //SCI_MEMCPY(&pb_entry, cmd, sizeof(PB_PHONEBOOK_ENTRY_T));
    pb_entry_size = sizeof(PB_PHONEBOOK_ENTRY_T);
    HexCharToBinary(cmd, len-1, (uint8*)&pb_entry, &pb_entry_size);
    SCI_ASSERT(pb_entry_size == sizeof(PB_PHONEBOOK_ENTRY_T));
    SCI_TRACE_LOW("mmi_atc.c: HandlePbAdd(), is_in_sim = %d, entry_id = %d", is_in_sim, pb_entry.entry_id);    

    if(MMIPB_SyncAdd(is_in_sim, &pb_entry))
    {
        //return "ok\r\n" to sync tool;
        ReturnResponse((uint8 *)MMI_TO_SYNC_OK_SYMBOL, strlen((char*)MMI_TO_SYNC_OK_SYMBOL));
    }
    else
    {
        ReturnResponse((uint8 *)MMI_TO_SYNC_ERROR_SYMBOL, strlen((char*)MMI_TO_SYNC_ERROR_SYMBOL));
    }

    return TRUE;
}

/*****************************************************************************/
// 	Description : This function handle the pb delete command
//	Global resource dependence : none
//  Author:      lin.lin
//	Note:
/*****************************************************************************/
LOCAL BOOLEAN HandlePbDelete(	
                                uint8 *cmd,  // Point to the command infomation buffer
					            uint32 len   // The length of command infomation buffer
                                )
{
    uint16 entry_id = 0;
    BOOLEAN is_in_sim = FALSE;
    
    SCI_ASSERT(len >= 1+ sizeof(uint16));
    
    if(!JudgePbInSim(&is_in_sim, *cmd))
    {
        return FALSE;
    }

    cmd++;
    entry_id = GetPbEntryId(cmd, len-1) ;    
    SCI_TRACE_LOW("mmi_atc.c: HandlePbDelete(), is_in_sim = %d, entry_id = %d",is_in_sim, entry_id);    

    if(MMIPB_SyncDelete(is_in_sim, entry_id))
    {
        //return "ok\r\n" to sync tool;
        ReturnResponse((uint8 *)MMI_TO_SYNC_OK_SYMBOL, strlen((char*)MMI_TO_SYNC_OK_SYMBOL));
    }
    else
    {
        ReturnResponse((uint8 *)MMI_TO_SYNC_ERROR_SYMBOL, strlen((char*)MMI_TO_SYNC_ERROR_SYMBOL));
    }

    return TRUE;
}

/*****************************************************************************/
// 	Description : This function handle the pb modify command
//	Global resource dependence : none
//  Author:      lin.lin
//	Note:
/*****************************************************************************/
LOCAL BOOLEAN HandlePbModify(	
                                uint8 *cmd,  // Point to the command infomation buffer
					            uint32 len   // The length of command infomation buffer
                                )
{
    PB_PHONEBOOK_ENTRY_T pb_entry = {0};

⌨️ 快捷键说明

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