コード例 #1
0
ファイル: HTTPS.c プロジェクト: eggfly/LinkIt_Assist_2502_SDK
static void https_send_read_request_rsp_cb(VMUINT16 request_id, VMUINT8 result, 
                                         VMUINT16 status, VMINT32 cause, VMUINT8 protocol, 
                                         VMUINT32 content_length,VMBOOL more,
                                         VMUINT8 *content_type, VMUINT8 content_type_len,  
                                          VMUINT8 *new_url, VMUINT32 new_url_len,
                                         VMUINT8 *reply_header, VMUINT32 reply_header_len,  
                                         VMUINT8 *reply_segment, VMUINT32 reply_segment_len)
{
    VMINT ret = -1;
    vm_log_debug("https_send_request_rsp_cb()");
    if (result != 0) {
        vm_https_cancel(request_id);
        vm_https_unset_channel(g_channel_id);
    }
    else {
        vm_log_debug("reply_content:%s", reply_segment);
        ret = vm_https_read_content(request_id, ++g_read_seg_num, 100);
        if (ret != 0) {
            vm_https_cancel(request_id);
            vm_https_unset_channel(g_channel_id);
        }
    }
}
コード例 #2
0
vm_phb_req_error_enum vm_sal_phb_search_contact_syn(vm_phb_search_req_struct* req_info)
{
    srv_phb_sdk_search_req_struct  req;
    srv_phb_sdk_contact_struct * contact = NULL;
    VMINT result = -1;
    vm_phb_req_error_enum res = VM_PHB_REQ_ERROR;

    vm_log_debug("vm_sal_phb_search_contact_syn: start");

    contact = vm_calloc(sizeof(srv_phb_sdk_contact_struct));
    if(contact == NULL)
    {
        vm_log_error("vm_sal_phb_search_contact_syn:contact == NULL");
        return VM_PHB_REQ_ERROR;	
    }

    memset(&req, 0, sizeof(req));	  

    req.contact_ptr = contact;

    vm_wstrncpy((VMWSTR)req.pattern_ucs2, req_info->pattern_ucs2,  SRV_PHB_SEARCH_LENGTH-1);
    req.search_type = (srv_phb_search_type_enum)req_info->search_type;
      
    vm_log_debug("vm_sal_phb_search_contact_syn: req.search_type=%d,req.pattern_ucs2=%s", req.search_type, vm_gb2312_string((VMWSTR)req.pattern_ucs2));
    result = srv_phb_sdk_search_contact(&req);
    if(result == SRV_PHB_NO_ERROR)  
    {
        vm_phb_build_contact_ptr(req_info->contact_ptr, req.contact_ptr);
        res = VM_PHB_REQ_NO_ERROR;
    }

    vm_free(contact);
    vm_log_debug("vm_sal_phb_search_contact_syn:srv_phb_sdk_search_contact end");

    return res;

}
コード例 #3
0
void app_client_register_client_callback(void *context_handle, VMBOOL status, VMUINT8 app_uuid[16])
{
    vm_log_debug("[AppClient] reg_cb status %d state %d!\n", status, g_appc_cntx.state);
    if(memcmp(app_uuid, g_appc_cntx.uid, sizeof(g_appc_cntx.uid)) == 0)
    {
        if(g_appc_cntx.state == APPC_STATUS_ENABLING)
        {
            if(status == 0)
            {
                vm_log_debug("[AppClient] reg_cb status_ok %d state_ok %d!\n", status, g_appc_cntx.state);
                g_appc_cntx.context_handle = context_handle;
                g_appc_cntx.state = APPC_STATUS_ENABLED;
                //vm_bt_gatt_client_listen(context_handle, VM_TRUE);
                vm_bt_gatt_client_scan(context_handle, VM_TRUE);
            }
            else
            {
                g_appc_cntx.context_handle = NULL;
                g_appc_cntx.state = APPC_STATUS_DISABLED;
            }
        }
        else if(g_appc_cntx.state == APPC_STATUS_DISABLING)
        {
            if(status == 0)
            {
                g_appc_cntx.context_handle = NULL;
                g_appc_cntx.state = APPC_STATUS_DISABLED;
            }
            else
            {
                g_appc_cntx.state = APPC_STATUS_ENABLED;
            }
        }
    }
    vm_log_debug("[AppClient] reg_cb -!\n");
}
コード例 #4
0
/*****************************************************************************
 * FUNCTION
 *  mre_dump_to_file
 *
 * DESCRIPTION
 *  Write response data to specified file. Show alert if failed.
 *
 * PARAMETERS
 *  tcp_buffer              [IN]   buffer pointer containing address of received buffer
 *  size                    [IN]   size of received data
 *  VMINT *layer_hdl		[IN]
 *
 * RETURNS
 *  VOID
*****************************************************************************/
void mre_dump_to_file(VMCHAR *tcp_buffer, VMINT size, VMINT *layer_hdl)
{
    VMFILE  handle;
	VMWCHAR wfile_name[MRE_FILE_NAME_MAX_SIZE ];
	VMCHAR  file_name[2 * MRE_FILE_NAME_MAX_SIZE];
	VMUINT length;
	VMINT write_status;

	sprintf(file_name,"%c:\\%s",mre_get_drv(),"TCP.txt");
	vm_ascii_to_ucs2(wfile_name, 100, file_name);
	handle = vm_file_open(wfile_name, MODE_APPEND, TRUE);
	if(handle < 0)
	{
		//mre_display_home_top_screen_ascii("File Handle Fail");
		mre_display_home_top_screen_ascii("File Handle Fail", layer_hdl);
		//vertical_scrolling_text("File Handle Fail....");
	}

	if (handle)
    {
   
	/* log information */
	vm_log_debug("File handle is %d.", handle);
	/* write response to tcp_buffer.txt file */
	write_status =  vm_file_write(handle, tcp_buffer, size, &length);

	if (write_status < 0)
	{
		 vm_log_debug("unable to write");
	}
	/* log information */
    vm_log_debug("%d bytes has been written to file.", length);
    }

	vm_file_close(handle);
}
コード例 #5
0
void app_client_search_result_callback(vm_bt_gatt_connection_t *conn, vm_bt_gatt_service_info_t *uuid)
{
    //VMINT type = -1;

    vm_log_debug("[AppClient] app_client_search_result_callback !\n");
    //type = get_appc_service_type(uuid->uuid);
    //if(type == -1)
    //    return;
    //else if (type == 0)
    if(memcmp(&(uuid->uuid.uuid.uuid),&appc_srv_uuid, (sizeof(VMUINT8) * 16)) == 0)
    {
        //vm_log_debug("[AppClient] find in list !\n");
        vm_log_debug("[AppClient]service2 has been find !\n");
        if(appc_conn_cntx->connection_handle == conn->connection_handle)
        {
            //appc_srv_uuid = (vm_bt_gatt_service_info_t *)vm_malloc(sizeof(vm_bt_gatt_service_info_t));
            //memset(appc_srv_uuid, 0x0, sizeof(vm_bt_gatt_service_info_t));
            //appc_srv_uuid = uuid;
            vm_log_debug("[AppClient] to get character !\n");
            vm_bt_gatt_client_get_characteristic(conn, uuid, NULL);
            return;
        }
    }
}
コード例 #6
0
ファイル: vmtel.c プロジェクト: WayWingsDev/testmywatch
static mmi_ret vm_callout_ucm_callback(mmi_event_struct * param)
{
	//srv_ucm_status_change_evt_struct *evt = (srv_ucm_status_change_evt_struct *)param;
	VMINT resid = -1;
	VM_CALLOUT_RESPONSE_T callout_callback;
	VMWSTR phonenum = NULL;
	VMINT size = 0;

	VMINT callcount = 0;

	callcount = srv_ucm_query_call_count(SRV_UCM_CALL_STATE_ALL, SRV_UCM_CALL_TYPE_ALL, NULL);
	vm_log_debug("vm_callout_ucm_callback : callcount=%d", callcount);
	if (callcount > 0)
	{
		vm_callout_status = VM_CALLOUT_BUSY;
	}
	else
	{
		vm_callout_status = VM_CALLOUT_IDEL;
		
	}

	if ((resid = vm_res_findfirst(-1, VM_RES_TYPE_CALLOUT)) != VM_RES_NOT_FIND)
	{
		VM_P_HANDLE phandle = vm_res_get_process_handle(VM_RES_TYPE_CALLOUT, resid);
		vm_res_get_callback(VM_RES_TYPE_CALLOUT, resid, (void**)&callout_callback);
		vm_res_get_data(VM_RES_TYPE_CALLOUT, resid, (void**)&phonenum, &size);

		if (vm_pmng_set_ctx(phandle) == VM_PMNG_OP_OK)
		{
			if (callout_callback != NULL)
			{
				callout_callback(phonenum, vm_callout_status);
			}

			vm_pmng_reset_ctx();
		}

		if (vm_callout_status == VM_CALLOUT_IDEL)
		{
			vm_res_release_data(VM_RES_TYPE_CALLOUT, resid);
		}
		
		vm_res_findclose(VM_RES_TYPE_CALLOUT);
		
	}
	return MMI_RET_OK;
}
コード例 #7
0
/*****************************************************************************
*
* #define MODE_READ					1
* #define MODE_WRITE					2
* #define MODE_CREATE_ALWAYS_WRITE	4
* #define MODE_APPEND					8
*****************************************************************************/
VMFILE mre_open_file(VMSTR file_path, VMUINT mode, VMUINT binary){
	VMFILE file_handle;
	VMWSTR wfile_path;
	VMINT wfile_size;

	wfile_size = (strlen(file_path) + 1) * 2;
	wfile_path = vm_malloc(wfile_size);

	vm_ascii_to_ucs2 (wfile_path, MRE_STR_SIZE_MAX, file_path);

	/* Opening the file */
	file_handle = vm_file_open (wfile_path, mode, binary);
    vm_log_debug("file open handle : %d", file_handle);

	return file_handle;
}
コード例 #8
0
void vm_main(void) {
    /* initialize layer handle */
    //layer_hdl[0] = -1;

    ///* register system events handler */
    //vm_reg_sysevt_callback(handle_sysevt);
    //
    ///* register keyboard events handler */
    //vm_reg_keyboard_callback(handle_keyevt);
    //
    ///* register pen events handler */
    //vm_reg_pen_callback(handle_penevt);

    /* Init MRE resource */
    //vm_res_init();

    VM_TIMER_ID_NON_PRECISE timer_id = 0;
    timer_id = vm_timer_create_non_precise(1000, (vm_timer_non_precise_callback)timer_cb, 0x1);
    vm_log_debug("create timer [%d]", timer_id);
}
コード例 #9
0
ファイル: vmtel.c プロジェクト: WayWingsDev/testmywatch
static void vm_callout_finialize(void)
{
	VMINT callcount = 0;

	vm_res_type_set_notify_callback(VM_RES_TYPE_CALLOUT, NULL);

	mmi_frm_cb_dereg_event(EVT_ID_SRV_UCM_STATUS_CHANGE, vm_callout_ucm_callback, NULL);
	
	callcount = srv_ucm_query_call_count(SRV_UCM_CALL_STATE_ALL, SRV_UCM_CALL_TYPE_ALL, NULL);	

	if (callcount > 0)
	{
		vm_callout_status = VM_CALLOUT_BUSY;
	}
	else
	{
		vm_callout_status = VM_CALLOUT_IDEL;
	}

	vm_log_debug("vm_callout_finialize : callcount=%d, status=%d", callcount, vm_callout_status);
}
コード例 #10
0
VMINT app_client_deinit(void)
{
    vm_log_debug("[AppClient] app_client_deinit state %d!\n", g_appc_cntx.state);
    if((g_appc_cntx.state == APPC_STATUS_DISABLED)
        || (g_appc_cntx.state == APPC_STATUS_DISABLING))
        return 0;

    if(g_appc_cntx.state == APPC_STATUS_ENABLED)
    {
        {
            client_gatt_conn.context_handle = g_appc_cntx.context_handle;
            client_gatt_conn.connection_handle = appc_conn_cntx->connection_handle;
            if((appc_conn_cntx->conn_status == APPC_STATUS_CONNECTED)
                || (appc_conn_cntx->conn_status == APPC_STATUS_CONNECTING))
            {
                client_bd_addr = (vm_bt_gatt_address_t *)vm_malloc(sizeof(vm_bt_gatt_address_t));
                memset(client_bd_addr, 0x0, sizeof(vm_bt_gatt_address_t));
                memcpy(client_bd_addr->data, appc_conn_cntx->bdaddr, VM_BT_GATT_ADDRESS_SIZE);
                vm_bt_gatt_client_disconnect(&client_gatt_conn, client_bd_addr);
            }
        }
    }

    vm_bt_gatt_client_deregister(g_appc_cntx.context_handle);
    g_appc_cntx.state = APPC_STATUS_DISABLED;
    //vm_free(appc_srv_uuid);

    if (appc_conn_cntx)
    {
        vm_free(appc_conn_cntx);
    }
    if (client_bd_addr)
    {
        vm_free(client_bd_addr);
    }
    return 1;
}
コード例 #11
0
//----------------------------------------------------------------------------------------------------
static void https_send_request_set_channel_rsp_cb(VMUINT32 req_id, VMUINT8 channel_id, VMUINT8 result)
{
    VMINT ret = -1;

    g_channel_id = channel_id;
    ret = vm_https_send_request(0,							// Request ID
                                VM_HTTPS_METHOD_GET,		// HTTP Method Constant
                                VM_HTTPS_OPTION_NO_CACHE,	// HTTP request options
                                VM_HTTPS_DATA_TYPE_BUFFER,	// Reply type (wps_data_type_enum)
								REPLY_SEGMENT_LENGTH,		// bytes of data to be sent in reply at a time.
                                 	 	 	 	 	 	 	// If data is more that this, multiple response would be there
								g_https_url,				// The request URL
                                strlen(g_https_url),		// The request URL length
                                NULL,                		// The request header
                                0,                   		// The request header length
                                NULL,						// post segment
                                0							// post segment length
								);

    if(ret != 0) {
        vm_https_unset_channel(channel_id);
    }
    vm_log_debug("[HTTPS] GET req to %s, result %d", g_https_url, ret);
}
コード例 #12
0
ファイル: HTTPS.c プロジェクト: Frank-KunLi/LinkItProjects
static void https_send_read_read_content_rsp_cb(VMUINT16 request_id,
		VMUINT8 seq_num, VMUINT8 result, VMBOOL more, VMUINT8 *reply_segment,
		VMUINT32 reply_segment_len) {
	VMINT ret = -1;
	vm_log_debug("reply_content:%s", reply_segment);
	if (more > 0) {
		ret = vm_https_read_content(request_id, /* Request ID */
		++g_read_seg_num, /* Sequence number (for debug purpose) */
		100); /* The suggested segment data length of replied data in the peer buffer of
		 response. 0 means use reply_segment_len in MSG_ID_WPS_HTTP_REQ or
		 read_segment_length in previous request. */
		if (ret != 0) {
			vm_https_cancel(request_id);
			vm_https_unset_channel(g_channel_id);
		}
	} else {
		/* don't want to send more requests, so unset channel */
		vm_https_cancel(request_id);
		vm_https_unset_channel(g_channel_id);
		g_channel_id = 0;
		g_read_seg_num = 0;

	}
}
コード例 #13
0
ファイル: HTTPS.c プロジェクト: Frank-KunLi/LinkItProjects
static void https_send_release_all_req_rsp_cb(VMUINT8 result) {
	vm_log_debug("https_send_release_all_req_rsp_cb()");
}
コード例 #14
0
ファイル: HTTPS.c プロジェクト: Frank-KunLi/LinkItProjects
static void https_unset_channel_rsp_cb(VMUINT8 channel_id, VMUINT8 result) {
	vm_log_debug("https_unset_channel_rsp_cb()");
}
コード例 #15
0
ファイル: HTTPS.c プロジェクト: Frank-KunLi/LinkItProjects
static void https_send_status_query_rsp_cb(VMUINT8 status) {
	vm_log_debug("https_send_status_query_rsp_cb()");
}
コード例 #16
0
ファイル: HTTPS.c プロジェクト: Frank-KunLi/LinkItProjects
static void https_send_cancel_rsp_cb(VMUINT16 request_id, VMUINT8 result) {
	vm_log_debug("https_send_cancel_rsp_cb()");
}
コード例 #17
0
void reboot_non_precise_timer_callback(VM_TIMER_ID_NON_PRECISE timer_id, void* user_data){
    vm_log_debug("reboot again");
    /* Calls the reboot API */
    vm_pwr_reboot();
}
コード例 #18
0
ファイル: WLANScan.c プロジェクト: mandl/LinkIt_Assist_2502
static void wlan_scan_callback(
            VMUINT32 job_id,
            void *user_data,
            vm_wlan_scan_result_t* scan_result)
{
    VMINT i;
    vm_log_debug("scan result:%d", scan_result->result);
    if(VM_WLAN_SCAN_SUCCESS == scan_result->result)
    {
        for(i = 0; i < scan_result->ap_list_number; i++)
        {
            vm_log_debug("-----------------------------------");
            vm_log_debug("SSID:%s", scan_result->ap_list[i].ssid);
            vm_log_debug("bssid: %s", scan_result->ap_list[i].bssid);
            vm_log_debug("rssi:%d", scan_result->ap_list[i].rssi);
            vm_log_debug("channel_number:%d", scan_result->ap_list[i].channel_number);
            vm_log_debug("max_rate:%d", scan_result->ap_list[i].max_rate);
            vm_log_debug("privacy:%d", scan_result->ap_list[i].privacy);
            vm_log_debug("network_type:%d", scan_result->ap_list[i].network_type);
            vm_log_debug("authorize_mode:%d", scan_result->ap_list[i].authorize_mode);
            vm_log_debug("encrypt_mode:%d", scan_result->ap_list[i].encrypt_mode);
        }
    }
}
コード例 #19
0
void app_client_get_characteristic_callback(vm_bt_gatt_connection_t *conn, VMBOOL status,
                                    vm_bt_gatt_client_characteristic_t *ch, VM_BT_GATT_CHAR_PROPERTIES properties)
{
    //VMUINT16               char_uuid= appc_convert_array_to_uuid16(*ch->ch_uuid);
    //VMUINT16               svc_uuid = appc_convert_array_to_uuid16(ch->svc_uuid->uuid);

    vm_log_debug("[AppClient] app_client_get_characteristic_callback status %d!\n", status);
    if(appc_conn_cntx->connection_handle == conn->connection_handle)
    {
        if(memcmp(&(ch->svc_uuid->uuid.uuid.uuid),&appc_srv_uuid, (sizeof(VMUINT8) * 16)) == 0)
        {
            if(memcmp(&(ch->ch_uuid->uuid.uuid),&appc_char_uuid, (sizeof(VMUINT8) * 16)) == 0)
            {
                vm_log_debug("[AppClient]service2 has been find !\n");
                if(status == 0)
                {
                    if (properties & (VM_BT_GATT_CHAR_PROPERTY_READ))
                    {
                        vm_log_debug("[AppClient] read service2  !\n");
                        vm_bt_gatt_client_read_characteristic(conn,ch,VM_BT_GATT_CLIENT_AUTH_REQ_NONE);
                    }
                    else if (properties & (VM_BT_GATT_CHAR_PROPERTY_WRITE || VM_BT_GATT_CHAR_PROPERTY_WRITE_WO_RESPONSE))
                    {
                        char_value.data[0] = 0;
                        char_value.length = 1;
                        vm_log_debug("[AppClient] write service2 !\n");
                        vm_bt_gatt_client_write_characteristic(conn,
                                                       ch,
                                                       &char_value,
                                                       VM_BT_GATT_CLIENT_WRITE_TYPE_PREPARE,
                                                       VM_BT_GATT_CLIENT_AUTH_REQ_NONE);
                    }
                }
            }

        }
        #if 0
        if((char_uuid == ALERT_LEVEL_CHAR_UUID)
            && (svc_uuid == IMMEDIATE_ALERT_SERVICE))
        {
            vm_log_debug("[AppClient] is immediately service find !\n");
            if(status == 0)
            {
                if (properties == (VM_BT_GATT_CHAR_PROPERTY_WRITE || VM_BT_GATT_CHAR_PROPERTY_WRITE_WO_RESPONSE))
                {
                    char_value.value[0] = 0;
                    char_value.len = 1;
                    vm_log_debug("[AppClient] immediately service write !\n");
                    vm_bt_gatt_client_write_characteristic(conn,
                                                   ch,
                                                   &char_value,
                                                   VM_BT_GATTC_WRITE_TYPE_PREPARE,
                                                   VM_BT_GATTC_AUTH_REQ_NONE);
                }
                else if (properties == VM_BT_GATT_CHAR_PROPERTY_READ)
                {
                    vm_log_debug("[AppClient] immediately service read !\n");
                    vm_bt_gatt_client_read_characteristic(conn,ch,VM_BT_GATTC_AUTH_REQ_NONE);
                }
            }
        }
        #endif
        else
        {
            if(status == 0)
            {
                vm_bt_gatt_client_get_characteristic(conn, ch->svc_uuid, ch->ch_uuid);
            }
        }
    }
    return ;
}
コード例 #20
0
ファイル: vmtel.c プロジェクト: WayWingsDev/testmywatch
VMINT vm_callout_ex(VMWSTR phnum, VM_CALLOUT_RESPONSE_T callback)
{
	VM_P_HANDLE phandle =  vm_pmng_get_current_handle();
//	VMINT resid = -1;
	
	mmi_ucm_make_call_para_struct  make_call_para;
	VMUINT16 gid = 0;  

	if (vm_pmng_state(phandle) != VM_PMNG_FOREGROUND)
	{
		vm_log_debug("vm_callout: state is not foreground");
		return VM_CALLOUT_ERR_STATE;
	}
#ifdef __MRE_SAL_SIM__
 
	if (vm_sim_card_count() <= 0)
	{
		vm_log_debug("vm_callout: no sim card");
		return VM_CALLOUT_ERR_NO_SIM;
	}
#endif
 
	if (!srv_mode_switch_is_network_service_available())
	{
		vm_log_debug("vm_callout: flight mode");
		return VM_CALLOUT_ERR_FLIGHT;
	}
 
	if (vm_callout_status != VM_CALLOUT_IDEL)
	{
		vm_log_debug("vm_callout: device is busy now");
		return VM_CALLOUT_ERR_BUSY;
	}
	 
	if (phnum == NULL)
	{
		vm_log_debug("vm_callout : the ptr of phnum is NULL");
		return VM_CALLOUT_ERR_PHONE_NUM;
	}
	if ((vm_wstrlen(phnum) <= 0) || (vm_wstrlen(phnum) >= 40))
	{
		vm_log_debug("vm_callout : the len of phnum is error");
		return VM_CALLOUT_ERR_PHONE_NUM;
	}
	if (vm_available_phnum(phnum) == FALSE)
	{
		vm_log_debug("vm_callout : the content of phnum is error");
		return VM_CALLOUT_ERR_PHONE_NUM;
	}
	if (phandle < 0)
	{
		vm_log_debug("vm_callout : phandle is error");
		return VM_CALLOUT_ERR_PROCESS;
	}
	 
	if ((vm_res_save_data(VM_RES_TYPE_CALLOUT, phnum, (vm_wstrlen(phnum) * 2), (void*)callback, phandle)) < 0)
	{
	    VMINT resid = -1;
	    if ((resid = vm_res_findfirst(-1, VM_RES_TYPE_CALLOUT)) != VM_RES_NOT_FIND)
    	{
    		vm_res_release_data(VM_RES_TYPE_CALLOUT, resid);   		
    		vm_res_findclose(VM_RES_TYPE_CALLOUT);    		
    	}
		
		if ((vm_res_save_data(VM_RES_TYPE_CALLOUT, phnum, (vm_wstrlen(phnum) * 2), (void*)callback, phandle)) < 0)
		{
		    vm_log_debug("vm_callout: res save error");
		    return VM_CALLOUT_ERR_NO_RES;
		}
	}

 
	vm_log_debug("vm_callout : before mmi_ucm_init_call_para");
	mmi_ucm_init_call_para(&make_call_para);  
	vm_log_debug("vm_callout : after mmi_ucm_init_call_para");

    switch (vm_sim_get_active_sim_card())
    {
    case 1:
        make_call_para.dial_type = SRV_UCM_VOICE_CALL_TYPE;
        break;
    case 2:
        make_call_para.dial_type = SRV_UCM_VOICE_CALL_TYPE_SIM2;
        break;
    case 3:
        make_call_para.dial_type = SRV_UCM_VOICE_CALL_TYPE_SIM3;
        break;
    case 4:
        make_call_para.dial_type = SRV_UCM_VOICE_CALL_TYPE_SIM4;
        break;
    default:
        return VM_CALLOUT_ERR_NO_SIM;
    }
    
	make_call_para.ucs2_num_uri = (U16*)phnum;
    
	vm_log_debug("vm_callout : before mmi_ucm_call_launch");
	mmi_ucm_call_launch(gid, &make_call_para);	
	vm_log_debug("vm_callout : after mmi_ucm_call_launch");
	
	return VM_CALLOUT_NO_ERR;
}
コード例 #21
0
VMINT vm_sal_phb_search_contact_list(vm_phb_search_list_req_struct* req_info, vm_phb_contact_pos_struct* pos_array, VMINT post_array_len)
{
	srv_phb_contact_pos_struct  *contact_array = NULL;
	srv_phb_sdk_get_req_struct  req;
	srv_phb_sdk_contact_struct * contact = NULL;
	VMINT used_nums = 0;
	VMINT res = 0;
	VMINT j = 0;
	VMINT i = 0;

    used_nums = srv_phb_sdk_get_used_contacts(contact_array, vm_sal_phb_trans_storage(VM_PHB_STORAGE_LOC_BOTH));

    if(used_nums < 0)  
    {
        vm_log_error("vm_sal_phb_search_contact_list:used_nums < 0");
        return VM_PHB_REQ_ERROR;
    }

    if(used_nums == 0)  
        return used_nums;

    contact_array = vm_calloc(sizeof(srv_phb_contact_pos_struct)*used_nums);

    if(contact_array == NULL)
    {
        vm_log_error("vm_sal_phb_search_contact_list:contact_array == NULL");
        return VM_PHB_REQ_ERROR;	
    }
  
	used_nums = srv_phb_sdk_get_used_contacts(contact_array, vm_sal_phb_trans_storage(VM_PHB_STORAGE_LOC_BOTH));
	
	vm_log_debug("vm_sal_phb_search_contact_list:used_nums=%d", used_nums);

	contact = vm_calloc(sizeof(srv_phb_sdk_contact_struct));
	if(contact == NULL)
	{
		vm_free(contact_array);
		vm_log_error("vm_sal_phb_search_contact_list:contact == NULL");
		return VM_PHB_REQ_ERROR;	
      }
	
       for(i=0; i< used_nums; i++)
       {
       	memset(&req, 0, sizeof(srv_phb_sdk_get_req_struct));
		memset(contact, 0, sizeof(srv_phb_sdk_contact_struct));
		req.contact_ptr = contact;
		req.pos.index= contact_array[i].index;
		req.pos.storage= contact_array[i].storage;	  
		contact->pos.index = contact_array[i].index;
		contact->pos.storage = contact_array[i].storage;	  
		  
		vm_log_debug("vm_sal_phb_search_contact_list  contact_array[%d].index=%d",  i, contact_array[i].index);
		vm_log_debug("vm_sal_phb_search_contact_list  contact_array[%d].storage=%d", i, contact_array[i].storage);
		res = srv_phb_sdk_get_contact(&req);
		if(res == SRV_PHB_NO_ERROR)
		{
			if(contact != NULL )
			{
				vm_log_debug("vm_sal_phb_search_contact_list:search_req->search_type=%d",req_info->search_type);
			
				if(req_info->search_type == VM_PHB_SEARCH_TYPE_NAME)
				{
					vm_log_debug("vm_sal_phb_search_contact_list:search_req->pattern_ucs2=%s",vm_gb2312_string(req_info->pattern_ucs2));
					vm_log_debug("vm_sal_phb_search_contact_list:contact_ptr->name=%s",vm_gb2312_string((VMWSTR)contact->name));
					if(vm_wstrcmp((VMWSTR)req_info->pattern_ucs2, (VMWSTR)&contact->name) == 0)
					{
						pos_array[j].index = 	contact->pos.index;
						pos_array[j].storage = vm_sal_phb_trans_storage_ex(contact->pos.storage);
						j++;
						
					}
				}  
		   		else if(req_info->search_type == VM_PHB_SEARCH_TYPE_NUM)
				{
					vm_log_debug("vm_sal_phb_search_contact_list:search_req->pattern_ucs2=%s",vm_gb2312_string(req_info->pattern_ucs2));
					vm_log_debug("vm_sal_phb_search_contact_list:contact_ptr->number=%s",vm_gb2312_string((VMWSTR)contact->number));
					if(vm_wstrcmp((VMWSTR)req_info->pattern_ucs2, (VMWSTR)&contact->number) == 0)
					{
						pos_array[j].index = 	contact->pos.index;
						pos_array[j].storage = vm_sal_phb_trans_storage_ex(contact->pos.storage);
						j++;
					}
				} 
				else
				{
					vm_log_error("vm_sal_phb_search_contact_list: req_info->search_type =%d",req_info->search_type);
				}
			}
			
			if(j == post_array_len)
			{
				break;
			}
		}
		
       }
	   
	vm_free(contact_array);
	vm_free(contact);

	return j;     
	 
}
コード例 #22
0
ファイル: shell.c プロジェクト: loboris/RePhone_on_Linux
//-----------------------------------------------------------------
int _get_paramstr(char **param_buf, char **par_end, char **var_ptr)
{
	int psize, err = 0;

	psize = vm_fs_app_data_get_free_space();
	if (psize > MAX_SYSTEM_PARAMS_SIZE) {
		// no parameters
    	vm_log_debug("parameters not found");
		return -1;
	}

	char *parambuf = vm_calloc(MAX_SYSTEM_PARAMS_SIZE+1);
	if (parambuf == NULL) {
    	vm_log_error("error allocating buffer");
		return -2;
	}

	VM_FS_HANDLE phandle = vm_fs_app_data_open(VM_FS_MODE_READ, VM_FALSE);
	if (phandle < VM_FS_SUCCESS) {
    	vm_log_error("error opening params");
		return -3;
	}

	if (vm_fs_app_data_read(phandle, parambuf, MAX_SYSTEM_PARAMS_SIZE, &psize) < 0) {
    	vm_log_error("error reading params");
    	vm_fs_app_data_close(phandle);
		return -4;
	}

	vm_fs_app_data_close(phandle);

	parambuf[psize] = '\0';

	// === Check crc ===
	char *parend = strstr(parambuf, "\n__SYSVAR=\"");	// end of __SYSPAR table
	if (parend == NULL) {
		err = -5;
		goto exit;
	}

	char *varptr = parend + 11;					// start of __SSVAR
	char *varend = strstr(varptr, "\"");	// end of __SYSVAR
	if (varend == NULL){
		err = -6;
		goto exit;
	}
	if ((varend - varptr) != SYSVAR_SIZE) {
		err = -7;
		goto exit;
	}

	// calculate crc
	CRC16_Context contex;
	uint16_t parcrc;
	CRC16_Init( &contex );
	CRC16_Update( &contex, parambuf, (varptr - parambuf) + SYSVAR_SIZE - 4);
	CRC16_Final( &contex, &parcrc );
	// compare
	char crcstr[5] = {'\0'};
	memcpy(crcstr, varptr + SYSVAR_SIZE - 4, 4);
	uint16_t crc = (uint16_t)strtol(crcstr, NULL, 16);
	if (crc != parcrc) {
		err = -8;
	}
	else {
		*param_buf = parambuf;
		*par_end = parend;
		*var_ptr = varptr;
		return 0;
	}

exit:
	vm_log_error("SYSPAR wrong format");
	return err;
}
コード例 #23
0
ファイル: gsm.c プロジェクト: WayenWeng/Lua_for_RePhone
/* The callback of sending SMS, for checking if an SMS is sent successfully. */
void _gsm_text_callback(vm_gsm_sms_callback_t* callback_data){
    if(callback_data->action == VM_GSM_SMS_ACTION_SEND){
        vm_log_debug("send sms callback, result = %d", callback_data->result);
    }
}
コード例 #24
0
ファイル: HTTPS.c プロジェクト: Frank-KunLi/LinkItProjects
static void https_send_termination_ind_cb(void) {
	vm_log_debug("https_send_termination_ind_cb()");
}
コード例 #25
0
//------------------------------------------------------------------------
static void https_unset_channel_rsp_cb(VMUINT8 channel_id, VMUINT8 result)
{
    vm_log_debug("https_unset_channel_rsp_cb()");
    g_request_id = -1;
    free_post_buffers();
}
コード例 #26
0
//==========================
int https_post(lua_State* L)
{
	int ret;

	vm_https_callbacks_t callbacks = { (vm_https_set_channel_response_callback)https_post_request_set_channel_rsp_cb,
    								   (vm_https_unset_channel_response_callback)https_unset_channel_rsp_cb,
									   (vm_https_release_all_request_response_callback)https_send_release_all_req_rsp_cb,
									   (vm_https_termination_callback)https_send_termination_ind_cb,
                                       (vm_https_send_response_callback)https_send_read_request_rsp_cb,
									   (vm_https_read_content_response_callback)https_send_read_read_content_rsp_cb,
                                       (vm_https_cancel_response_callback)https_send_cancel_rsp_cb,
									   (vm_https_status_query_response_callback)https_send_status_query_rsp_cb };

	size_t sl;
    const char* url = luaL_checklstring(L, 1, &sl);

    free_post_buffers();

    g_https_url = vm_calloc(sl+1);
	if (g_https_url == NULL) {
		return luaL_error(L, "url buffer allocation error");
	}
    strncpy(g_https_url, url, sl);
    int totalalloc = (sl+1);

    if ((!lua_istable(L, 2)) && (!lua_isstring(L, 2))) {
      free_post_buffers();
      return luaL_error(L, "POST data arg missing" );
    }

	if (lua_isstring(L, 2)) {
		g_post_type = 0;
		const char* pdata = luaL_checklstring(L, 2, &sl);
		if ((sl <= 0) || (pdata == NULL)) {
		    free_post_buffers();
			return luaL_error(L, "wrong post data");
		}
		g_postdata = vm_calloc(sl+1);
		if (g_postdata == NULL) {
		    free_post_buffers();
			return luaL_error(L, "buffer allocation error");
		}
	    totalalloc += (sl+1);

		strncpy(g_postdata, pdata, sl);
		g_postdata[sl] = '\0';
		g_postdata_len = sl;
	    vm_log_debug("[POST]: allocated memory = %d", totalalloc);
    }
    else if (lua_istable(L, 2)) {
		g_post_type = 1;

		// ** iterate the table to find number of entries and total data size
		int pdata_size = 0;
		int nentries = 0;
		int fnames_size = 0;
		int filenames_size = 0;
		int pathnames_size = 0;
        int err = 0;
        int nfileentry = 0;

	    lua_pushnil(L);  // first key
	    while (lua_next(L, 2) != 0) {
	      // Pops a key from the stack, and pushes a key-value pair from the table
	      // 'key' (at index -2) and 'value' (at index -1)
	      if ((lua_isstring(L, -1)) && (lua_isstring(L, -2))) {
	        size_t klen = 0;
	        size_t vlen = 0;
	        const char* key = lua_tolstring(L, -2, &klen);
	        const char* value = lua_tolstring(L, -1, &vlen);
	        if ((klen > 0) && (vlen > 0)) {
	        	nentries++;
	        	fnames_size += (klen+1);
	  	    	if (strstr(key, "file") == key) {
	  	    		if (nfileentry < 1) {
						nfileentry++;
						filenames_size += (vlen+1);

						char fn[128];
						short wfn[128];
						sprintf(fn, "C:\\%s", value);
						vm_chset_ascii_to_ucs2((VMWSTR)wfn, 256, fn);
						int fh = vm_fs_open(wfn, VM_FS_MODE_READ, VM_TRUE);
						if (fh < 0) {
							err++;
							vm_log_debug("[POST]: File '%s' not found",fn);
						}
						else vm_fs_close(fh);
						int fnmlen = (vm_wstr_string_length(wfn)+1)*2;
						pathnames_size += fnmlen;
	  	    		}
	  	    		else {
						vm_log_debug("[POST]: Only 1 file allowed!");
	  	    		}
		        }
	  	    	else pdata_size += (vlen+sizeof(int));
	        }
	      }
	      lua_pop(L, 1);  // removes 'value'; keeps 'key' for next iteration
	    }

	    if (nentries == 0) {
	        free_post_buffers();
			return luaL_error(L, "no post entries");
	    }
	    if (err != 0) {
	        free_post_buffers();
			return luaL_error(L, "file not found");
	    }

		// ** Allocate buffers
        g_post_context = vm_calloc(sizeof(vm_https_request_context_t));
		if (g_post_context == NULL) {
		    free_post_buffers();
			return luaL_error(L, "buffer allocation error 1");
		}
	    totalalloc += sizeof(vm_https_request_context_t);

	    g_post_content = vm_calloc(sizeof(vm_https_content_t)*nentries);
 		if (g_post_content == NULL) {
 		    free_post_buffers();
			return luaL_error(L, "buffer allocation error 2");
    	}
	    totalalloc += (sizeof(vm_https_content_t)*nentries);

	    if (pdata_size > 0) {
			g_postdata = vm_calloc(pdata_size);
			if (g_postdata == NULL) {
				free_post_buffers();
				return luaL_error(L, "buffer allocation error 3");
			}
		    totalalloc += pdata_size;
 		}

	    g_https_field_names = vm_calloc(fnames_size);
  		if (g_https_field_names == NULL) {
  		    free_post_buffers();
			return luaL_error(L, "buffer allocation error 4");
  		}
	    totalalloc += fnames_size;

	    if (filenames_size > 0) {
			g_https_file_names = vm_calloc(filenames_size);
			if (g_https_file_names == NULL) {
				free_post_buffers();
				return luaL_error(L, "buffer allocation error 5");
			}
		    totalalloc += filenames_size;
  		}
  		if (pathnames_size > 0) {
			g_https_path_names = vm_calloc(pathnames_size);
			if (g_https_path_names == NULL) {
				free_post_buffers();
				return luaL_error(L, "buffer allocation error 6");
			}
		    totalalloc += pathnames_size;
  		}
	    vm_log_debug("[POST]: allocated memory = %d", totalalloc);

        sprintf(g_https_url, url);

        g_post_context->number_entries = 0;
    	g_post_context->content = (vm_https_content_t *)g_post_content;
        g_post_context->header = CONTENT_TYPE_FORMDATA;
        g_post_context->header_length = strlen(CONTENT_TYPE_FORMDATA);
        g_post_context->post_segment = NULL;
        g_post_context->post_segment_length = 0;
        g_post_context->url = g_https_url;
        g_post_context->url_length = strlen(g_post_context->url);

		// ** iterate the table and populate data buffers
		vm_https_content_t cc;
		g_postdata_len = 0;
		fnames_size = 0;
		filenames_size = 0;
		pathnames_size = 0;
		nfileentry = 0;

	    lua_pushnil(L);
	    while (lua_next(L, 2) != 0) {
	      if ((lua_isstring(L, -1)) && (lua_isstring(L, -2))) {
	        size_t klen = 0;
	        size_t vlen = 0;
	        const char* key = lua_tolstring(L, -2, &klen);
	        const char* value = lua_tolstring(L, -1, &vlen);
	        if ((klen > 0) && (vlen > 0)) {
	          // field key & value are OK
			  g_post_context->number_entries++;

  	    	  if (strstr(key, "file") == key) {
  	    		if (nfileentry < 1) {
					nfileentry++;
					cc.data_type = VM_HTTPS_DATA_TYPE_FILE;
					cc.content_type = CONTENT_TYPE_OCTET;
					cc.content_type_length = strlen(CONTENT_TYPE_OCTET);

					// save file name & length
					sprintf(g_https_file_names+filenames_size, "%s", value);
					cc.filename = g_https_file_names+filenames_size;
					cc.filename_length = vlen;
					filenames_size += (vlen+1);

					// save local file path/name & length
					char fn[128];
					short wfn[128];
					sprintf(fn, "C:\\%s", value);
					vm_chset_ascii_to_ucs2((VMWSTR)wfn, 256, fn);
					int wfnlen = vm_wstr_copy(g_https_path_names+pathnames_size, wfn);
					cc.file_path_name = g_https_path_names+pathnames_size;
					cc.file_path_name_length = vm_wstr_string_length(cc.file_path_name);
					pathnames_size += ((cc.file_path_name_length+1)*2);

					// get file size
					int fh = vm_fs_open(cc.file_path_name, VM_FS_MODE_READ, VM_TRUE);
					VMUINT fsz;
					if (vm_fs_get_size(fh, &fsz) == 0)  cc.data_length = fsz;
					else cc.data_length = 0;
					vm_fs_close(fh);
  	    		}
	          }
	          else {
		       	cc.data_type = VM_HTTPS_DATA_TYPE_BUFFER;
  		        cc.content_type = CONTENT_TYPE_TEXT;
	  		    cc.content_type_length = strlen(CONTENT_TYPE_TEXT);
    	        cc.filename = "";
    	        cc.filename_length = 0;
    	  		cc.file_path_name = (VMWSTR)"\0\0";
    		    cc.file_path_name_length = 0;
				cc.data_length = vlen;       // field data length

				int dlen = vlen;
				memcpy(g_postdata+g_postdata_len, &dlen, sizeof(int));
				memcpy(g_postdata+g_postdata_len+sizeof(int), value, vlen);
	            g_postdata_len += (vlen+sizeof(int));
	          }

  	          cc.charset = VM_HTTPS_CHARSET_ASCII;
  	          // save field name & length
  		      sprintf(g_https_field_names+fnames_size, "%s", key);
  	          cc.name = g_https_field_names+fnames_size;
  	          cc.name_length = klen;  // field name length
  	          fnames_size += (klen+1);

  	          memcpy(g_post_content + (sizeof(vm_https_content_t) * (g_post_context->number_entries-1)), &cc, sizeof(vm_https_content_t));
	        }
	      }
	      // removes 'value'; keeps 'key' for next iteration
	      lua_pop(L, 1);
	    }
    }


    ret = vm_https_register_context_and_callback(gprs_bearer_type, &callbacks);
    if (ret != 0) {
		free_post_buffers();
        l_message(NULL, "register context & cb failed");
    }
    else {
    	ret = vm_https_set_channel(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
    }
    lua_pushinteger(L, ret);

	return 1;
}
コード例 #27
0
ファイル: WLANScan.c プロジェクト: mandl/LinkIt_Assist_2502
static void wlan_scan(void)
{
	vm_log_debug("wlan scan");
	vm_wlan_mode_set(VM_WLAN_MODE_STA, wlan_callback, NULL);
}
コード例 #28
0
/*****************************************************************************
 * FUNCTION
 *  vm_log_file
 * DESCRIPTION
 *  Logs message to pre set log file 
 * PARAMETERS
 *  VMSTR	message		[IN]      log line message in VMSTR
 * RETURNS
 *	VMINT MRE_FILE_NOT_WRITTEN if fail, MRE_SCILENT for success
*****************************************************************************/
VMINT vm_log_file(VMSTR message){
	vm_log_debug(message);
	return mre_write_line_to_file("log.txt", message);
}