| #include "kal_public_api.h" |
| #ifdef __GCC_COMPILER__ |
| #include <strings.h> |
| #endif |
| #include <string.h> |
| #include "l5_common.h" |
| #include "l5_msgid.h" |
| #include "custom_l5.h" |
| |
| |
| //type: string type terminated by '\0' |
| //value: uint32 |
| kal_bool l5custom_is_ok_to_write_dipc_config(kal_uint8 *type) |
| { |
| #if 0 |
| /* under construction !*/ |
| /* under construction !*/ |
| /* under construction !*/ |
| /* under construction !*/ |
| #endif |
| return KAL_TRUE; |
| } |
| |
| kal_bool l5custom_is_ok_to_write_nvram(kal_uint32 file_idx) |
| { |
| #if 0 |
| /* under construction !*/ |
| /* under construction !*/ |
| /* under construction !*/ |
| /* under construction !*/ |
| #endif |
| |
| return KAL_FALSE; |
| } |
| |
| typedef struct { |
| kal_char config_type_str[32]; |
| kal_bool is_user_sensitive; |
| kal_uint8 valid_ps_id; //bitmap |
| module_type module_id; |
| } l5_general_modem_config_struct; |
| |
| static l5_general_modem_config_struct gmc_table[] = { |
| {"sample", KAL_FALSE, 0xff, MOD_L5IO}, |
| {"L5_TO_MMTST", KAL_FALSE, 0xff, MOD_MMRF_XL1TST}, |
| {"L5_TO_NL1", KAL_FALSE, 0xff, MOD_NL1}, |
| }; |
| |
| kal_bool l5_general_modem_configure_req_custom(kal_uint8 ps_id, kal_bool is_set, ilm_struct *ilm_ptr) |
| { |
| l5_general_modem_configure_set_req_struct *set_req_ptr; |
| l5_general_modem_configure_get_req_struct *get_req_ptr; |
| //peer_buff_struct *peer_buff_ptr = ilm_ptr->peer_buff_ptr; |
| |
| kal_uint32 i, max; |
| char name [32]; |
| max = sizeof(gmc_table)/sizeof(l5_general_modem_config_struct); |
| |
| if (is_set) { //set |
| set_req_ptr = (l5_general_modem_configure_set_req_struct *)ilm_ptr->local_para_ptr; |
| memcpy(name, (char *)set_req_ptr->config_type, sizeof(name)); |
| } else { //query |
| get_req_ptr = (l5_general_modem_configure_get_req_struct *)ilm_ptr->local_para_ptr; |
| memcpy(name, (char *)get_req_ptr->config_type, sizeof(name)); |
| } |
| |
| for (i = 0; i < max; i++) { |
| if (strcasecmp((char *)gmc_table[i].config_type_str, name) == 0) { |
| if (gmc_table[i].valid_ps_id & (1 << ps_id)) { |
| //set destination module id |
| ilm_ptr->dest_mod_id = gmc_table[i].module_id + ps_id; |
| |
| if (gmc_table[i].is_user_sensitive) { |
| //ilm_ptr->sap_id = |
| } |
| |
| //customization here if necessary |
| if (is_set) { //set operation |
| |
| } else { //get operation |
| |
| } |
| |
| return KAL_TRUE; |
| } else { |
| return KAL_FALSE; |
| } |
| } |
| |
| } |
| |
| return KAL_FALSE; |
| } |
| |
| //this is just for the init function in boot procedure. also can be cfg after boot up |
| //this function only config for <new sms storage> and <read msg> and <write msg>. <new cell broadcast>&<new status report> only support save in HOST now |
| //Even prefer not save in HOST, some special SMS would not save in DEVICE(and use MIPC_IND/CMD to indicate HOST), like supl msg, refer to custom_l5_sms_force_relay_to_HOST |
| kal_uint8 custom_l5_sms_storage_select_init() |
| { |
| return 0; //SM: prefer only save in DEVICE_SIM, new sms would notify HOST(AP, USER) with MIPC_IND which contains memory index |
| // return 1; //ME: prefer save in DEVICE_NVRAM |
| // return 2; //TE: prefer save in HOST, new sms would notify HOST(AP,USER) by MIPC_IND or MIPC_CMD according to ack option |
| // return 4; //MT: prefer save in DEVICE_SIM; if SIM_full or SIM_mem_invalid, then try save in DEVICE_NVRAM |
| } |
| |
| //this is just for the init function in boot procedure. also can be cfg after boot up |
| kal_bool custom_l5_sms_need_ack_init() |
| { |
| //return KAL_TRUE; //If the new SMS not save in DEVICE(DEVICE relay the raw data to HOST), this option would take effect. MIPC_CMD would be userd to notify HOST(AP,USER) for new SMS/DS |
| return KAL_FALSE; //MIPC_IND would be used to notify HOST(AP, USER) for new SMS/DS |
| } |
| |
| //you can decide what sms should relay to HOST use NEW_SMS_IND/CMD even if config save in DEVICE. |
| //If this function return TRUE, SMS would not save in DEVICE and notify HOST using NEW_SMS_IND/CMD according to ack_prefer |
| kal_bool custom_l5_sms_force_relay_to_HOST(const kal_uint8* sms_ptr) |
| { |
| kal_uint8 idx = 0; //init point to sca_len |
| kal_uint8 first_octer = 0; |
| kal_bool tp_udhi = KAL_FALSE; |
| kal_uint8 oa_len = 0; |
| kal_uint8 udh_l = 0; |
| kal_uint8 udh_idx = 0; |
| kal_bool is_need_relay = KAL_FALSE; |
| |
| if(NULL == sms_ptr) { |
| return KAL_FALSE; |
| } |
| idx++; //point to SCA start |
| idx+=sms_ptr[0]; //point to first_octer |
| first_octer = sms_ptr[idx++]; //point to OA_L |
| tp_udhi = 0==(first_octer&0x40) ? KAL_FALSE : KAL_TRUE; |
| oa_len = sms_ptr[idx]; |
| idx+=(1 + 1 + (oa_len+1)/2); //point to PID |
| idx++; //point to DCS |
| //class0 need to relay, this is in MBIM spec |
| if(0x10 == (sms_ptr[idx] & 0x13)) return KAL_TRUE; |
| idx++; //point to SCTS |
| idx+=7; //point to UDL |
| if(KAL_TRUE == tp_udhi) { |
| idx++; //point to UDH_L |
| udh_l = sms_ptr[idx]; |
| for (udh_idx = 1; udh_idx < udh_l; udh_idx++){ |
| //16-bit application port |
| if(0x05 == sms_ptr[idx+udh_idx] && 4 == sms_ptr[idx+udh_idx+1]) { |
| // TODO: Discuss with SMS user to confirm jugde standard |
| kal_uint16 dest_port = (((kal_uint16)(sms_ptr[idx+udh_idx+2]))<<8) + sms_ptr[idx+udh_idx+3]; |
| //using last valid port to judge |
| if(7275 == dest_port || 2948 == dest_port) is_need_relay = KAL_TRUE; |
| else is_need_relay = KAL_FALSE; |
| } |
| udh_idx+=(1+sms_ptr[idx+udh_idx+1]); |
| } |
| } |
| return is_need_relay; |
| } |
| |
| // with MBIM project, we would transfer the 3gpp2_mt_sms -> 3gpp_mt_sms, then save the 3gpp_mt_sms in DEVICE |
| // you can decide what sms should relay to HOST use NEW_SMS_IND even if config save in DEVICE. |
| // currently the format follow CS.0015 |
| // though not support C2K, but datacard project could recv 3gpp2 format SMS using IMS. this api is for 3gpp2 format MT sms. |
| kal_bool custom_l5_sms_force_relay_to_HOST_3gpp2(const kal_uint8* c2k_ptr, kal_uint8 pdu_len) |
| { |
| kal_uint16 c2k_idx=1; |
| |
| for(;c2k_idx<pdu_len;c2k_idx++){ |
| // get Message Identifier tlv first |
| if(0x00 == c2k_ptr[c2k_idx]) { |
| // if PUSH msg, force relay |
| if(c2k_idx+3<pdu_len && 2 == c2k_ptr[c2k_idx+1] && 0x10 == c2k_ptr[c2k_idx+2] && 0x04 == c2k_ptr[c2k_idx+3]){ |
| return KAL_TRUE; |
| } else { |
| return KAL_FALSE; |
| } |
| } |
| c2k_idx += (c2k_ptr[c2k_idx+1]+1); |
| } |
| return KAL_FALSE; |
| } |
| |
| kal_bool custom_l5_custom_device_caps(l5_custom_device_cap_info_struct *device_caps) |
| { |
| /* |
| * If any data of device_caps has been modified, return KAL_TRUE |
| * Example: |
| * device_caps->device_type = 3; |
| * return KAL_TRUE; |
| * If there is no any modification for data of device_cap, return KAL_FALSE |
| */ |
| return KAL_FALSE; |
| } |
| |
| kal_bool custom_l5_custom_provider_name(kal_uint8 *provider_name, kal_uint16 *len, kal_uint32 sbp_id) |
| { |
| /* |
| * If provider_name have assigned value, return KAL_TRUE |
| * Example: |
| * Please provide the buff data |
| * MTK will not do any processing on buff data |
| * switch (sbp_id) { |
| * case 2: |
| * kal_uint8 buff[] = {0x41, 0x00, 0x42, 0x00, 0x43, 0x00}; |
| * memcpy(provider_name, buff, sizeof(buff)); |
| * *len = sizeof(buff); |
| * break; |
| * case 3: |
| * kal_uint8 buff[] = {0x2d, 0x4e, 0xfd, 0x56}; |
| * memcpy(provider_name, buff, sizeof(buff)); |
| * *len = sizeof(buff); |
| * break; |
| * default: |
| * return KAL_FALSE; |
| * } |
| * return KAL_TRUE; |
| * |
| * If there is no any assignment, return KAL_FALSE |
| */ |
| |
| return KAL_FALSE; |
| } |
| |
| kal_bool custom_l5_signal_state_rsrp_threshold(uint32_t *rsrp_threshold) |
| { |
| /* |
| * If rsrp_threshold have assigned value, return KAL_TRUE |
| * Example: |
| * *rsrp_threshold = 5; (Value should not be less than 0) |
| * return KAL_TRUE; |
| * If there is no any assignment, return KAL_FALSE |
| */ |
| return KAL_FALSE; |
| } |
| |
| kal_bool custom_l5_packet_service_speed(uint32_t data_class, kal_uint64 *uplink_speed_ptr, kal_uint64 *downlink_speed_ptr) |
| { |
| /* |
| * If uplink_speed_ptr and downlink_speed_ptr have assigned values, return KAL_TRUE |
| * Example: |
| * *uplink_speed_ptr = 250000000; |
| * *downlink_speed_ptr = 500000000; |
| * return KAL_TRUE; |
| * If there is no any assignment, return KAL_FALSE |
| */ |
| return KAL_FALSE; |
| } |
| |
| kal_bool custom_l5_nw_enable_EONS() |
| { |
| /* |
| *If you want to enable EONS, return KAL_TRUE |
| *If there is no need to enable EONS, return KAL_FALSE |
| */ |
| return KAL_FALSE; |
| } |
| |
| /****************************************************************************** |
| **if you want to disable one or more rat, please modify this array |
| ** 0 means don't disable the rat |
| ** 1 means disable the rat |
| *******************************************************************************/ |
| #if 0 |
| /* under construction !*/ |
| /* under construction !*/ |
| /* under construction !*/ |
| /* under construction !*/ |
| /* under construction !*/ |
| /* under construction !*/ |
| /* under construction !*/ |
| /* under construction !*/ |
| /* under construction !*/ |
| /* under construction !*/ |
| /* under construction !*/ |
| /* under construction !*/ |
| /* under construction !*/ |
| /* under construction !*/ |
| /* under construction !*/ |
| /* under construction !*/ |
| /* under construction !*/ |
| /* under construction !*/ |
| /* under construction !*/ |
| /* under construction !*/ |
| /* under construction !*/ |
| /* under construction !*/ |
| #endif |
| |
| kal_bool custom_l5_nw_enable_EDMFAPP_6_3() |
| { |
| /* |
| If you want to enable EDMFAPP_6_3, return KAL_TRUE, else return KAL_FALSE |
| */ |
| return KAL_FALSE; |
| } |
| |
| kal_bool custom_l5_signal_check(l5_custom_signal_state *signal_state) |
| { |
| if(signal_state->rsrp_snr_count != 0) |
| { |
| for(int i = 0; i < signal_state->rsrp_snr_count; i++) |
| { |
| if(signal_state->signal[i].rsrp_dbm >= -99) |
| signal_state->signal[i].rsrp = 5; |
| else if(signal_state->signal[i].rsrp_dbm >= -109 && -99 > signal_state->signal[i].rsrp_dbm) |
| signal_state->signal[i].rsrp = 4; |
| else if(signal_state->signal[i].rsrp_dbm >= -114 && -109 > signal_state->signal[i].rsrp_dbm) |
| signal_state->signal[i].rsrp = 3; |
| else if(signal_state->signal[i].rsrp_dbm >= -119 && -114 > signal_state->signal[i].rsrp_dbm) |
| signal_state->signal[i].rsrp = 2; |
| else if(signal_state->signal[i].rsrp_dbm >= -120 && -119 > signal_state->signal[i].rsrp_dbm) |
| signal_state->signal[i].rsrp = 1; |
| else if(-120 > signal_state->signal[i].rsrp_dbm) |
| signal_state->signal[i].rsrp = 0; |
| } |
| } |
| |
| /* If any data of signal has been modified, return KAL_TRUE */ |
| return KAL_FALSE; |
| } |
| |
| typedef struct{ |
| kal_uint32 type; |
| kal_uint32 len; |
| kal_uint32 tid; |
| } l5_msg_header; |
| |
| void custom_l5_MBIM_message(void* message_buffer, uint32_t msg_length) |
| { |
| l5_msg_header* p = (l5_msg_header *)message_buffer; |
| kal_prompt_trace(MOD_L5IO, "MBIM_TYPE:%u, MBIM_LEN:%u, MBIM_TID:%u", p->type, p->len, p->tid); |
| |
| return; |
| } |
| |
| //The example of the mapping array for the oper_name by plmn_id and gid1. |
| //the list is the customized,offical release will be comment out. |
| l5u_oper_name_mapping_item g_l5u_oper_name_mapping_table[] = { |
| // plmn_id gid1 gid1_length oper_name |
| {"23430", {0xee}, 1, "EE"}, |
| {"23433", {0xff}, 1, "FF"}, |
| {"23430", {0xc3}, 1, "BT"}, |
| {"23433", {0xb3}, 1, "BT"}, |
| }; |
| |
| /* |
| This func just a example, Customer can redefine implementation method and mapping list according to their own needs. |
| */ |
| kal_bool custom_l5_oper_name_mapping_by_gid1(kal_char *oper_name, kal_char *plmn_id, kal_uint8 plmn_length, kal_uint8 *gid1, kal_uint8 gid1_max_length) |
| { |
| kal_uint32 mapping_table_size = 0; |
| kal_uint32 index = 0; |
| kal_uint8 i = 0; |
| kal_bool result = KAL_FALSE; |
| //kal_uint8 gid1_length = 0; |
| kal_bool is_gid1_match = KAL_TRUE; |
| //kal_uint32 p_gid1 = 0; |
| /* |
| The pointer plmn_id and gid1 points to the value of plmn and gid1,whitch map to the oper_name in the mapping list. |
| if call the func ,it will select the mapping list, and map to oper_name accprding to plmn_id and gid1. |
| if find in the list,it will be return KAL_TRUE; otherwise return KAL_FALSE. |
| |
| Example: |
| If you get a valid oper_name from the list , |
| memcpy(oper_name, g_l5u_oper_name_mapping_table[index].oper_name, sizeof(oper_name)); |
| return KAL_TRUE; |
| If there can't get valid oper_name: |
| return KAL_FALSE; |
| |
| The example code as follow: |
| **this is just a demo,customer shoult according their needs to coding by themself. |
| */ |
| mapping_table_size = (kal_uint32)sizeof(g_l5u_oper_name_mapping_table)/sizeof(g_l5u_oper_name_mapping_table[0]); |
| for (; index <= mapping_table_size - 1; index++) { |
| for (; i <= g_l5u_oper_name_mapping_table[index].gid1_length - 1; i++) { |
| if (g_l5u_oper_name_mapping_table[index].gid1[i] == gid1[i]) { |
| continue; |
| } else { |
| is_gid1_match = KAL_FALSE; |
| break; |
| } |
| } |
| if ((strncmp(g_l5u_oper_name_mapping_table[index].plmn_id, plmn_id, |
| sizeof(g_l5u_oper_name_mapping_table[index].plmn_id) > plmn_length ? plmn_length : sizeof(g_l5u_oper_name_mapping_table[index].plmn_id)) == 0) |
| && is_gid1_match == KAL_TRUE) { |
| memcpy(oper_name, g_l5u_oper_name_mapping_table[index].oper_name, strlen(g_l5u_oper_name_mapping_table[index].oper_name)); |
| result = KAL_TRUE; |
| break; |
| } |
| } |
| return result; |
| } |
| |
| /****************************************************************************** |
| **You can modify this fuction to choose the mode of 5g icon display |
| *******************************************************************************/ |
| kal_uint32 custom_l5_get_5g_icon_display_mode() |
| { |
| #if 0 |
| /* under construction !*/ |
| /* under construction !*/ |
| /* under construction !*/ |
| /* under construction !*/ |
| /* under construction !*/ |
| /* under construction !*/ |
| /* under construction !*/ |
| /* under construction !*/ |
| /* under construction !*/ |
| /* under construction !*/ |
| /* under construction !*/ |
| /* under construction !*/ |
| /* under construction !*/ |
| /* under construction !*/ |
| /* under construction !*/ |
| /* under construction !*/ |
| /* under construction !*/ |
| /* under construction !*/ |
| /* under construction !*/ |
| /* under construction !*/ |
| /* under construction !*/ |
| /* under construction !*/ |
| /* under construction !*/ |
| /* under construction !*/ |
| /* under construction !*/ |
| /* under construction !*/ |
| /* under construction !*/ |
| /* under construction !*/ |
| /* under construction !*/ |
| /* under construction !*/ |
| #endif |
| return L5_5G_ICON_MODE_JP; |
| } |
| |
| /*********************************************************************************** |
| **You can modify this fuction to enable/disable nitz network name cache into NVRAM |
| ***********************************************************************************/ |
| kal_bool custom_l5_nw_enable_nitz_name_cache_to_nvram() |
| { |
| // Return TRUE means default enable the nitz network name cache into nvram and will be used after reboot; |
| // Return FALSE means disable this function. |
| return KAL_TRUE; |
| } |
| |
| /****************************************************************************** |
| **if you want to Ignore Duplicate Registration State Indication Change |
| **ignoreDuplicateRegistrationState parameter as below: |
| ** KAL_FALSE means don't ignoreDuplicateRegistrationState |
| ** KAL_TRUE means ignoreDuplicateRegistrationState |
| *******************************************************************************/ |
| |
| kal_bool custom_l5_custom_ignore_duplicate_registration_state_Ind() |
| { |
| kal_bool ignoreDuplicateRegistrationState = KAL_FALSE; |
| /* To Enable ignoreDuplicateRegistrationState = KAL_TRUE; */ |
| return ignoreDuplicateRegistrationState; |
| } |