Exemplo n.º 1
0
static boolean bt_server_end_spp()
{
    if(g_serverContext.btspp_hdl >= 0)
    {
        vm_btspp_close(g_serverContext.btspp_hdl);
        g_serverContext.btspp_hdl = -1;
    }

    if(g_serverContext.btspp_buf != NULL)
    {
        vm_free(g_serverContext.btspp_buf);
        g_serverContext.btspp_buf = NULL;
    }

    if(g_serverContext.conn_id >= 0)
    {
        g_serverContext.conn_id = -1;
    }

    VMINT ret = vm_btcm_get_power_status();

    if (VM_SRV_BT_CM_POWER_ON == ret)
    {
        VMINT ret = vm_btcm_switch_off();

        if(VM_SRV_BT_CM_RESULT_SUCCESS == ret)
        {
            //wait for callback to process
            g_serverContext.server_status = BT_SERVER_POWERING_OFF;
            return false;
        }
    }
    else if (VM_SRV_BT_CM_POWER_SWITCHING_ON == ret)
    {
        g_serverContext.server_status = BT_SERVER_ENDING;
        return false;
    }
    else if (VM_SRV_BT_CM_POWER_SWITCHING_OFF == ret)
    {
        g_serverContext.server_status = BT_SERVER_POWERING_OFF;
        return false;
    }

    // VM_SRV_BT_CM_POWER_OFF
    if(g_serverContext.btcm_hdl >= 0)
    {
        vm_btcm_exit(g_serverContext.btcm_hdl);
        g_serverContext.btcm_hdl = -1;
    }

    g_serverContext.server_status = BT_SERVER_IDLE;

    return true;

}
Exemplo n.º 2
0
static void vm_btspp_free_resource(VM_P_HANDLE phdl)
{
    VMINT resHandle = 0, bufSize = 0;
    vm_btspp_context_t * ctx_p = NULL;
    
    while ((resHandle = vm_res_findfirst(phdl, VM_RES_TYPE_BTSPP)) 
        != VM_RES_NOT_FIND)
    {
        if (vm_res_get_data(VM_RES_TYPE_BTSPP, 
            resHandle, (void**)&ctx_p, &bufSize) == 0 && ctx_p != NULL)
        {
            vm_btspp_close(ctx_p->srv_hd);
            MMI_TRACE(MMI_MRE_TRC_MOD_VMBTSPP, TRC_MRE_VMBTSPP_132 );
        }
        else
        {
            MMI_TRACE(MMI_MRE_TRC_MOD_VMBTSPP, TRC_MRE_VMBTSPP_136 );
        }
        vm_res_release_data(VM_RES_TYPE_BTSPP, resHandle);
        vm_res_findclose(VM_RES_TYPE_BTSPP); 
    }

}