Exemple #1
0
BtStatus FMP_Close(FmpChannel *channel)
{
    BtStatus status = BT_STATUS_FAILED;

    /* Validate parameters */
    CheckUnlockedParm(BT_STATUS_INVALID_PARM, channel != 0);

    OS_LockStack();

    CheckLockedParm(BT_STATUS_NOT_FOUND, 
                    IsNodeOnList(&FMP(dev_list), &(channel->node)));

    // check state
    if (channel->state == FMP_STATE_OPEN)
    {
        status = GattDisconnect(channel->link);
    }

    if (status == BT_STATUS_SUCCESS)
    {
        FmpClearConnection(channel, status);
    }


    OS_UnlockStack();
    return status;
}
Exemple #2
0
/*****************************************************************************
 * FUNCTION
 *  EVM_Deinit
 * DESCRIPTION
 *  Deinitialize the Event Manager.
 * PARAMETERS
 *  void
 * RETURNS
 *  void
 *****************************************************************************/
void EVM_Deinit(void)
{
    OS_LockStack();

    /* Deinit the radio manager */
    /* RMGR_RadioDeinit(); */
    RMGR_RadioShutdown();

    /* Deinitialize the stack */
    ME_Deinit();

    OS_UnlockStack();
}
Exemple #3
0
/*****************************************************************************
 * FUNCTION
 *  EVM_Process
 * DESCRIPTION
 *  Process all outstanding events.
 * PARAMETERS
 *  void
 * RETURNS
 *  void
 *****************************************************************************/
void EVM_Process(void)
{

    /* Do not permit stack API calls to occur until we're done */
    OS_LockStack();

    /* Let HCI process any events */
    HCI_Process();

    /* Look for timers that might have fired */
    CheckTimers();

    /* Permit stack API calls again */
    OS_UnlockStack();
}
Exemple #4
0
BtStatus FMP_Open(FmpChannel **channel, BD_ADDR *addr)
{
    BtStatus status = BT_STATUS_FAILED;
    FmpChannel *ch; 

    CheckUnlockedParm(BT_STATUS_INVALID_PARM, addr != 0);

    OS_LockStack();

    kal_trace(BT_TRACE_BLE_PROFILES, FMP_OPENCONNECTION);
    if ((*channel != NULL) && IsNodeOnList(&FMP(dev_list), &((*channel)->node)))
    {
        ch = *channel;
    }
    else
    {
        ch = FmpNewChannel();
        if (ch == NULL)
        {
            return BT_STATUS_NO_RESOURCES;
        }
    }

    if (ch->state == FMP_STATE_CLOSED)
    {
        status = CMGR_CreateDataLink(&ch->cmgr_handler, addr);
        kal_trace(BT_TRACE_BLE_PROFILES, FMP_CREATEDATALINK_STATUS, status);
        if (status == BT_STATUS_SUCCESS)
        {
            status = GattClientConnect(ch->cmgr_handler.remDev);
        }

        if (status != BT_STATUS_SUCCESS && status != BT_STATUS_PENDING)
        {
            FmpFreeChannel(ch);
            return status;          
        }

        ch->state = FMP_STATE_OPENING;
        *channel = ch;      
    }

    OS_UnlockStack();
    return status;
}
Exemple #5
0
void FMP_Init(void)
{
    OS_LockStack();

#if XA_CONTEXT_PTR == XA_ENABLED
    OS_MemSet((U8 *)fmpcx, 0, sizeof(FmpContext));
#else /* XA_CONTEXT_PTR == XA_ENABLED */
    OS_MemSet((U8 *)&fmpcx, 0, sizeof(FmpContext));
#endif /* XA_CONTEXT_PTR == XA_ENABLED */
    
    /* Initialize Lists */
    InitializeListHead(&FMP(dev_list));
    
    kal_trace(BT_TRACE_BLE_PROFILES, FMP_INITIALIZED);
    
    OS_UnlockStack();
    
}
Exemple #6
0
void FMPL_QueryGattService(FmpChannel *channel)
{
    BtStatus status;
    BtDeviceRecord record;

    OS_LockStack();
    
    /* check service database first */
    if (SEC_FindDeviceRecord(&channel->link->bdAddr, &record) == BT_STATUS_SUCCESS) // bonded device
    {
        if (FmpReadServiceDB(&channel->link->bdAddr, &channel->servicedb) == BT_STATUS_SUCCESS)
        {
            FmpAppCallback(channel, FMPEVENT_GATT_QUERY_CNF, BT_STATUS_SUCCESS, 0, 0);
            return;     
        }
    }
    else
    {
        FmpRemoveServiceDB(&channel->link->bdAddr);
    }

    channel->servicedb = (FmpServiceDB *)fmp_malloc(sizeof(FmpServiceDB));
    if (channel->servicedb == NULL)
    {
        FmpAppCallback(channel, FMPEVENT_GATT_QUERY_CNF, BT_STATUS_NO_RESOURCES, 0, 0);
        return;		
    }

    OS_MemSet((U8 *)channel->servicedb, 0, sizeof(FmpServiceDB));
    channel->servicedb->bt_addr = channel->link->bdAddr;

    kal_trace(BT_TRACE_BLE_PROFILES, FMP_QUEREYGATTSERVICE);
    /* search IAS service */
    status = FmplFindPrimaryServicesByUuid(channel, BT_UUID_GATT_SERVICE_ALERT, 0x0001, 0xffff);

    if (status != BT_STATUS_PENDING && status !=  BT_STATUS_SUCCESS)
    {
        fmp_free(channel->servicedb);
        FmpAppCallback(channel, FMPEVENT_GATT_QUERY_CNF, status, 0, 0);
    }

    OS_UnlockStack();
}
Exemple #7
0
BtStatus FMP_Register(FmpCallback callback, FmpServiceTypeFlag service_flag)
{
    BtStatus status = BT_STATUS_FAILED;

    OS_LockStack();

    if ((service_flag & FMP_SERVICE_TYPE_LOCATOR_FLAG) &&
	((FMP(service_flag) & FMP_SERVICE_TYPE_LOCATOR_FLAG) == 0))
    {
        status = BT_STATUS_SUCCESS;		
    }

    if ((service_flag & FMP_SERVICE_TYPE_TARGET_FLAG) &&
	((FMP(service_flag) & FMP_SERVICE_TYPE_TARGET_FLAG) == 0))
    {
        status = FmpAttDB_Registration();
    }

    if (status == BT_STATUS_SUCCESS)
    {
        if (FMP(service_flag) == 0)
        {
            /* register the GATT callback to handle connection */
            BT_GattRegisterConnectedEvent(&(FMP(gatt_handler)), FmpGattEventCallback);

            /* register bond callback to obtain bond status */
            FMP(bond_handler).callback = FmpBondingCallback;
            ATTDB_RegisterBondStatus(&FMP(bond_handler));

            FMP(fmp_callback) = callback;
        }
        FMP(service_flag) |= service_flag;
    }

    OS_UnlockStack();
    return status;	
}
Exemple #8
0
BtStatus FMP_Deregister(FmpServiceTypeFlag service_flag)
{
    BtStatus status = BT_STATUS_SUCCESS;

    OS_LockStack();

    if (FMP(service_flag) == 0)
    {
        /* It is actually invalid deregistration, return directly */
        return status;
    }

    if ((service_flag & FMP_SERVICE_TYPE_LOCATOR_FLAG) &&
	(FMP(service_flag) & FMP_SERVICE_TYPE_LOCATOR_FLAG))
    {
        FMP(service_flag) &= ~FMP_SERVICE_TYPE_LOCATOR_FLAG;
    }
	
    if ((service_flag & FMP_SERVICE_TYPE_TARGET_FLAG) &&
	(FMP(service_flag) & FMP_SERVICE_TYPE_TARGET_FLAG))
    {
        FmpAttDB_Deregistration();
        FMP(service_flag) &= ~FMP_SERVICE_TYPE_TARGET_FLAG;
    }

	
    if (FMP(service_flag) == 0)
    {
        BT_GattUnregisterConnectedEvent(&FMP(gatt_handler));
        ATTDB_UnRegisterBondStatus(&FMP(bond_handler));        
        FMP(fmp_callback) = NULL;
    }

    OS_UnlockStack();
    return status;	
}
Exemple #9
0
void OS_LockObex(void)
{
    OS_LockStack();
    OBD(obexLock)++;
}