⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 mfw_bta.c

📁 是一个手机功能的模拟程序
💻 C
📖 第 1 页 / 共 5 页
字号:
#endif
      MFREE(profile_cnf_data);
      return TRUE;
  }

  switch ((USHORT) opc)
  {
    case BTP_RECONFIG_PROFILE_CNF:
      /* BTI confirms reconfiguration of profile */
      MALLOC(profile_cnf_data, sizeof(T_MFW_BT_PROFILE_CNF));
      memset(profile_cnf_data, 0, sizeof(T_MFW_BT_PROFILE_CNF));
      profile_cnf_data->service = ((T_BTP_RECONFIG_PROFILE_CNF *)data)->device;
      profile_cnf_data->result_bd = ((T_BTP_RECONFIG_PROFILE_CNF *)data)->result;
      profile_cnf_data->subtype = ((T_BTP_RECONFIG_PROFILE_CNF *)data)->subtype;
      profile_cnf_data->mfw_opp_mode = ((T_BTP_RECONFIG_PROFILE_CNF *)data)->opp_mode;
      profile_cnf_data->mfw_sync_mode = ((T_BTP_RECONFIG_PROFILE_CNF *)data)->sync_serv_mode;
      profile_cnf_data->mfw_syn_aut_mode = ((T_BTP_RECONFIG_PROFILE_CNF *)data)->sync_init_auth;
      bt_signal(BT_RECONFIG_PROFILE_CNF, profile_cnf_data);
#ifdef _SIMULATION_
      if(profile_cnf_data->service EQ MFW_BT_SYNC)
      {
        TRACE_EVENT_P4("reconf cnf = %d, %d, %d, %d", profile_cnf_data->service, profile_cnf_data->subtype, profile_cnf_data->mfw_sync_mode, profile_cnf_data->mfw_syn_aut_mode);
      }
      else
      {
        TRACE_EVENT_P2("reconf cnf = %d, %d", profile_cnf_data->service, profile_cnf_data->subtype);
      }
#endif
      MFREE(profile_cnf_data);
      return TRUE;

    case BTP_RESTORE_LIST_RESULT:
      /* BTI confirms restoring of default device list */
      MALLOC(restore_configuration, sizeof(T_MFW_BT_REST_CONFIG));
      memset(restore_configuration, 0, sizeof(T_MFW_BT_REST_CONFIG));
      restore_configuration->service = ((T_BTP_RESTORE_LIST_RESULT *)data)->device;
      restore_configuration->cause = ((T_BTP_RESTORE_LIST_RESULT *)data)->cause;
      bt_signal(BT_RESTORE_LIST_RESULT, restore_configuration);
#ifdef _SIMULATION_
      if(restore_configuration->cause EQ MFW_BT_REST_LIST_ERR)
      {
          TRACE_EVENT("restore list err");
      }
      else if(restore_configuration->cause EQ MFW_BT_REST_CONFIG_ERR)
      {
          TRACE_EVENT("restore conf err");
      }
      else
      {
          TRACE_EVENT("restore conf no err");
      }
#endif
      MFREE(restore_configuration);
      return TRUE;

    case BTP_RESTORE_CONF_RESULT:
      /* BTI confirms restoring of configuration parameters */
      MALLOC(restore_configuration, sizeof(T_MFW_BT_REST_CONFIG));
      memset(restore_configuration, 0, sizeof(T_MFW_BT_REST_CONFIG));
      restore_configuration->service = ((T_BTP_RESTORE_CONF_RESULT *)data)->device;
      restore_configuration->cause = ((T_BTP_RESTORE_CONF_RESULT *)data)->cause;
      bt_signal(BT_RESTORE_CONF_RESULT, restore_configuration);
#ifdef _SIMULATION_
      if(restore_configuration->cause EQ MFW_BT_REST_LIST_ERR)
      {
          TRACE_EVENT("restore list err");
      }
      else if(restore_configuration->cause EQ MFW_BT_REST_CONFIG_ERR)
      {
          TRACE_EVENT("restore conf err");
      }
      else
      {
          TRACE_EVENT("restore conf no err");
      }
#endif
      MFREE(restore_configuration);
      return TRUE;

     case BTP_DEVICE_FOUND_IND:
      /* BTI confirms finding of bluetooth device with bd_addr and service id's)*/
      MALLOC(device_indication, sizeof(T_MFW_BT_DEVICE_IND));
      memset(device_indication, 0, sizeof(T_MFW_BT_DEVICE_IND));

      memcpy(device_indication->bd_addr, ((T_BTP_DEVICE_FOUND_IND *)data)->bd_addr, MFW_BT_ADDR_MAX_LEN);
      memcpy(device_indication->bd_name, ((T_BTP_DEVICE_FOUND_IND *)data)->bd_name, MFW_BT_NAME_MAX_LEN);
      memcpy(device_indication->cod, ((T_BTP_DEVICE_FOUND_IND *)data)->cod, MFW_BT_DEVICE_CLASS_LEN);
      device_indication->num_services = ((T_BTP_DEVICE_FOUND_IND *)data)->num_services;
      device_indication->services = ((T_BTP_DEVICE_FOUND_IND *)data)->services;

      MALLOC(dev_id, sizeof(T_MFW_BT_DEVICE_ID));/* allocate memory for new device id */
      if(!dev_id)
        return FALSE; /* no more memory */

      memset(dev_id, 0, sizeof(T_MFW_BT_DEVICE_ID));
      idd_ptr = &service_list;    /* pointer to list of services */
      if(!idd_ptr->device_id)      /* test if any device id exist */
      {
        idd_ptr->device_id = dev_id; /* append new device_id */
        memcpy(idd_ptr->device_id->bd_addr, device_indication->bd_addr, MFW_BT_ADDR_MAX_LEN);/* new address */
        memcpy(idd_ptr->device_id->bd_name, device_indication->bd_name, MFW_BT_NAME_MAX_LEN);/* new name */
        memcpy(idd_ptr->device_id->cod, device_indication->cod, MFW_BT_DEVICE_CLASS_LEN);/* new cod */
        idd_ptr->device_id->num_services = device_indication->num_services;
        idd_ptr->device_id->services = device_indication->services;
        idd_ptr->device_id->next = NULL; /* finish chain */
#ifdef _SIMULATION_
          TRACE_EVENT_P2("dev found ind = %x %s", service_list.device_id->services, service_list.device_id->bd_addr);
#endif
      }
      else
      {
        help_serv_id = idd_ptr->device_id;/* first element */
        while(help_serv_id->next)        /* look for next device_id                 */
        {
          help_serv_id = help_serv_id->next;
        }
        help_serv_id->next = dev_id;/* append new device_id */
        memcpy(help_serv_id->next->bd_addr, device_indication->bd_addr, MFW_BT_ADDR_MAX_LEN);/* new address */
        memcpy(help_serv_id->next->bd_name, device_indication->bd_name, MFW_BT_NAME_MAX_LEN);/* new name */
        memcpy(help_serv_id->next->cod, device_indication->cod, MFW_BT_DEVICE_CLASS_LEN);/* new cod */
        help_serv_id->next->num_services = device_indication->num_services;/* number of services */
        help_serv_id->next->services = device_indication->services;/* service id bitmap */
        help_serv_id->next->next = NULL;/* finish chain */
#ifdef _SIMULATION_
          TRACE_EVENT_P2("dev found ind = %x %s ", help_serv_id->next->services, help_serv_id->next->bd_addr);
#endif
      }
      bt_signal(BT_DEVICE_FOUND_IND, device_indication);
      MFREE(device_indication);
      return TRUE;

    case BTP_SERVICE_FOUND_IND:
      /* BTI confirms finding of service names and bd_addr to the desired device typ (service id)*/
      MALLOC(service_indication, sizeof(T_MFW_BT_SERVICE_IND));
      memset(service_indication, 0, sizeof(T_MFW_BT_SERVICE_IND));

      service_indication->service = ((T_BTP_SERVICE_FOUND_IND *)data)->device;
      memcpy(service_indication->bd_addr, ((T_BTP_SERVICE_FOUND_IND *)data)->bd_addr, MFW_BT_ADDR_MAX_LEN);
      memcpy(service_indication->bd_name, ((T_BTP_SERVICE_FOUND_IND *)data)->bd_name, MFW_BT_NAME_MAX_LEN);
      memcpy(service_indication->cod, ((T_BTP_SERVICE_FOUND_IND *)data)->cod, MFW_BT_DEVICE_CLASS_LEN);
      memcpy(service_indication->service_name, ((T_BTP_SERVICE_FOUND_IND *)data)->serv_name, MFW_BT_SERVICE_NAME_MAX_LEN);
/* information of new device(service) will be collected in list of found devices, but only after BT_SERVICE_SEARCH_CNF */
/* the list will be sent to MMI */
      if(service_indication->service EQ MFW_BT_HEADSET)
      {
        MALLOC(service_id, sizeof(T_MFW_BT_SERVICE_ID));/* allocate memory for new device id */
        if(!service_id)
          return FALSE;
        memset(service_id, 0, sizeof(T_MFW_BT_SERVICE_ID));
        len = sizeof(service_indication->service_name);
        id_ptr = &found_headset;    /* pointer to list of founded headset devices */
        if(!id_ptr->device_id)      /* test if does any device id exist */
        {
          id_ptr->device_id = service_id; /* append new device_id */
          memcpy(id_ptr->device_id->bd_addr, service_indication->bd_addr, MFW_BT_ADDR_MAX_LEN);/* new address */

          memcpy(id_ptr->device_id->bd_name, service_indication->bd_name, MFW_BT_NAME_MAX_LEN);
          memcpy(id_ptr->device_id->cod, service_indication->cod, MFW_BT_DEVICE_CLASS_LEN);
          memcpy(id_ptr->device_id->service_name, service_indication->service_name, MFW_BT_SERVICE_NAME_MAX_LEN);/* new name */

          id_ptr->device_id->next = NULL; /* finish chain */
#ifdef _SIMULATION_
          TRACE_EVENT_P1("hsg found ind =  %s", found_headset.device_id->bd_name);
#endif
        }
        else
        {
          help_id = id_ptr->device_id;/* first element */
          while(help_id->next)        /* look for next device_id                 */
          {
            help_id = help_id->next;
          }

          help_id->next = service_id;/* append new device_id */
          memcpy(help_id->next->bd_addr, service_indication->bd_addr, MFW_BT_ADDR_MAX_LEN);/* new address */
          memcpy(id_ptr->device_id->bd_name, service_indication->bd_name, MFW_BT_NAME_MAX_LEN);
          memcpy(id_ptr->device_id->cod, service_indication->cod, MFW_BT_DEVICE_CLASS_LEN);
          memcpy(id_ptr->device_id->service_name, service_indication->service_name, MFW_BT_SERVICE_NAME_MAX_LEN);/* new name */

          help_id->next->next = NULL;/* finish chain */
#ifdef _SIMULATION_
          TRACE_EVENT_P1("hsg found ind =  %s", help_id->next->bd_name);
#endif
        }
      }
      else if(service_indication->service EQ MFW_BT_DIAL_UP)
      {
        MALLOC(service_id, sizeof(T_MFW_BT_SERVICE_ID));/* allocate memory for new device id */
        if(!service_id)
          return FALSE;
        memset(service_id, 0, sizeof(T_MFW_BT_SERVICE_ID));
        len = sizeof(service_indication->service_name);
        id_ptr = &found_dial_up;    /* pointer to list of detected dial up network services */
        if(!id_ptr->device_id)      /* test if does any device id exist */
        {

          id_ptr->device_id = service_id; /* append new device_id */
          memcpy(id_ptr->device_id->bd_addr, service_indication->bd_addr, MFW_BT_ADDR_MAX_LEN);/* new address */
          memcpy(id_ptr->device_id->bd_name, service_indication->bd_name, MFW_BT_NAME_MAX_LEN);
          memcpy(id_ptr->device_id->cod, service_indication->cod, MFW_BT_DEVICE_CLASS_LEN);
          memcpy(id_ptr->device_id->service_name, service_indication->service_name, MFW_BT_SERVICE_NAME_MAX_LEN);/* new name */
          id_ptr->device_id->next = NULL; /* finish chain */
#ifdef _SIMULATION_
          TRACE_EVENT_P1("dun found ind =  %s", found_dial_up.device_id->bd_name);
#endif
        }
        else
        {
          help_id = id_ptr->device_id;/* first element */
          while(help_id->next)        /* look for next device_id                 */
          {
            help_id = help_id->next;
          }

          help_id->next = service_id;/* append new device_id */
          memcpy(help_id->next->bd_addr, service_indication->bd_addr, MFW_BT_ADDR_MAX_LEN);/* new address */
          memcpy(id_ptr->device_id->bd_name, service_indication->bd_name, MFW_BT_NAME_MAX_LEN);
          memcpy(id_ptr->device_id->cod, service_indication->cod, MFW_BT_DEVICE_CLASS_LEN);
          memcpy(id_ptr->device_id->service_name, service_indication->service_name, MFW_BT_SERVICE_NAME_MAX_LEN);/* new name */

          help_id->next->next = NULL;/* finish chain */
#ifdef _SIMULATION_
          TRACE_EVENT_P1("dun found ind =  %s", help_id->next->bd_name);
#endif
        }
      }
      else if(service_indication->service EQ MFW_BT_FAX_GW)
      {
        MALLOC(service_id, sizeof(T_MFW_BT_SERVICE_ID));/* allocate memory for new device id */
        if(!service_id)
          return FALSE;
        memset(service_id, 0, sizeof(T_MFW_BT_SERVICE_ID));
        len = sizeof(service_indication->service_name);
        id_ptr = &found_fax;    /* pointer to list of detected fax services */
        if(!id_ptr->device_id)      /* test if does any device id exist */
        {

          id_ptr->device_id = service_id; /* append new device_id */
          memcpy(id_ptr->device_id->bd_addr, service_indication->bd_addr, MFW_BT_ADDR_MAX_LEN);/* new address */
          memcpy(id_ptr->device_id->bd_name, service_indication->bd_name, MFW_BT_NAME_MAX_LEN);
          memcpy(id_ptr->device_id->cod, service_indication->cod, MFW_BT_DEVICE_CLASS_LEN);
          memcpy(id_ptr->device_id->service_name, service_indication->service_name, MFW_BT_SERVICE_NAME_MAX_LEN);/* new name */
          id_ptr->device_id->next = NULL; /* finish chain */
#ifdef _SIMULATION_
          TRACE_EVENT_P1("fax found ind =  %s", found_fax.device_id->bd_name);
#endif
        }
        else
        {
          help_id = id_ptr->device_id;/* first element */
          while(help_id->next)        /* look for next device_id                 */
          {
            help_id = help_id->next;
          }

          help_id->next = service_id;/* append new device_id */
          memcpy(help_id->next->bd_addr, service_indication->bd_addr, MFW_BT_ADDR_MAX_LEN);/* new address */
          memcpy(id_ptr->device_id->bd_name, service_indication->bd_name, MFW_BT_NAME_MAX_LEN);
          memcpy(id_ptr->device_id->cod, service_indication->cod, MFW_BT_DEVICE_CLASS_LEN);

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -