コード例 #1
0
ファイル: l2cap.c プロジェクト: Simu3/RobotLog
void l2cap_unregister_service_internal(void *connection, uint16_t psm){
    l2cap_service_t *service = l2cap_get_service(psm);
    if (!service) return;
    linked_list_remove(&l2cap_services, (linked_item_t *) service);
    btstack_memory_l2cap_service_free(service);
    
    // disable page scan when no services registered
    if (!linked_list_empty(&l2cap_services)) return;
    hci_connectable_control(0);
}
コード例 #2
0
ファイル: msg_q.c プロジェクト: AniruddhC/c1905-device-tree
/*===========================================================================

  FUNCTION:   msg_q_rcv

  ===========================================================================*/
msq_q_err_type msg_q_rcv(void* msg_q_data, void** msg_obj)
{
   msq_q_err_type rv;
   if( msg_q_data == NULL )
   {
      LOC_LOGE("%s: Invalid msg_q_data parameter!\n", __FUNCTION__);
      return eMSG_Q_INVALID_HANDLE;
   }

   if( msg_obj == NULL )
   {
      LOC_LOGE("%s: Invalid msg_obj parameter!\n", __FUNCTION__);
      return eMSG_Q_INVALID_PARAMETER;
   }

   msg_q* p_msg_q = (msg_q*)msg_q_data;

   LOC_LOGD("%s: Waiting on message\n", __FUNCTION__);

   pthread_mutex_lock(&p_msg_q->list_mutex);

   if( p_msg_q->unblocked )
   {
      LOC_LOGE("%s: Message queue has been unblocked.\n", __FUNCTION__);
      pthread_mutex_unlock(&p_msg_q->list_mutex);
      return eMSG_Q_UNAVAILABLE_RESOURCE;
   }

   /* Wait for data in the message queue */
   while( linked_list_empty(p_msg_q->msg_list) && !p_msg_q->unblocked )
   {
      pthread_cond_wait(&p_msg_q->list_cond, &p_msg_q->list_mutex);
   }

   rv = convert_linked_list_err_type(linked_list_remove(p_msg_q->msg_list, msg_obj));

   pthread_mutex_unlock(&p_msg_q->list_mutex);

   LOC_LOGD("%s: Received message 0x%08X rv = %d\n", __FUNCTION__, *msg_obj, rv);

   return rv;
}