找回密码
 立即注册

使用微信账号登录

只需一步,快速开始

查看: 5672|回复: 9

[BC5系列] 如何获得远端设备名称?

[复制链接]
连续签到天数:1天
签到总天数:405天
签到总奖励:3173金币
发表于 2014-5-28 11:14:39 | 显示全部楼层 |阅读模式
积分商城 - 让您的金币更有价值!||官方Q群 - 让您的沟通更加及时!
连续签到天数:1天
签到总天数:885天
签到总奖励:15306金币
发表于 2014-5-28 14:40:21 | 显示全部楼层
积分商城 - 让您的金币更有价值!||官方Q群 - 让您的沟通更加及时!
回复 支持 反对

使用道具 举报

连续签到天数:1天
签到总天数:104天
签到总奖励:1701金币
发表于 2014-5-28 14:54:10 | 显示全部楼层
profile support
找相应profile里参数
积分商城 - 让您的金币更有价值!||官方Q群 - 让您的沟通更加及时!
回复 支持 反对

使用道具 举报

连续签到天数:1天
签到总天数:405天
签到总奖励:3173金币
 楼主| 发表于 2014-5-29 08:37:49 | 显示全部楼层
legendflying 发表于 2014-5-28 14:54
profile support
找相应profile里参数

可以具体点吗?是远端名称,不是本地名称哦。谢谢。
积分商城 - 让您的金币更有价值!||官方Q群 - 让您的沟通更加及时!
回复 支持 反对

使用道具 举报

连续签到天数:1天
签到总天数:104天
签到总奖励:1701金币
发表于 2014-5-29 13:50:54 | 显示全部楼层
bluelab4.1里面的EIR a,可以把附近搜索到的设备名称打印出来
我把main。c文件贴给看看
/* Copyright (C) Cambridge Silicon Radio Limited 2008-2009 */
/* Part of BlueLab 4.1-Release */

#include <stdio.h>
#include <stdlib.h>
#include <connection.h>
#include <panic.h>

#ifdef DEBUG_ENABLED
#   define DEBUG(x) x
#else
#   define DEBUG(x)
#endif

static TaskData task;           /* application task */

/* application local messages */
enum
{
    APP_INQUIRE = 0,            /* Inquire devices */

    APP_MESSAGE_TOP
};

/* EIR data types as defined in Bluetooth Assigned Numbers */
#define EIR_UUID16_PART         0x02    /* More 16-bit UUIDs available */
#define EIR_UUID16              0x03    /* Complete list of 16-bit UUIDs */
#define EIR_UUID32_PART         0x04    /* More 32-bit UUIDs available */
#define EIR_UUID32              0x05    /* Complete list of 32-bit UUIDs */
#define EIR_UUID128_PART        0x06    /* More 128-bit UUIDs available */
#define EIR_UUID128             0x07    /* Complete list of 128-bit UUIDs */
#define EIR_NAME_PART           0x08    /* Shortened local name */
#define EIR_NAME                0x09    /* Complete local name */
#define EIR_TXPOWER             0x0a    /* TX Power level */
#define EIR_OOB_COD             0x0d    /* SSP OOB Class of Device */
#define EIR_OOB_C               0x0e    /* SSP OOB Hash C */
#define EIR_OOB_R               0x0f    /* SSP OOB Randomizer R */
#define EIR_ID                  0x10    /* Device ID */
#define EIR_MANUFACTURER        0xff    /* Manufacturer Specific Data */

static const char *hex = "0123456789abcdef";
static uint8 *bd_format(const bdaddr *addr)
{
    /* this uses 18 bytes globals but is OK for this example */
    static uint8 rc[18];

    /* return Bluetooth address in human readable format */
    rc[ 0] = hex[(addr->nap >> 12) & 0xf];
    rc[ 1] = hex[(addr->nap >>  8) & 0xf];
    rc[ 3] = hex[(addr->nap >>  4) & 0xf];
    rc[ 4] = hex[(addr->nap >>  0) & 0xf];
   
    rc[ 6] = hex[(addr->uap >>  4) & 0xf];
    rc[ 7] = hex[(addr->uap >>  0) & 0xf];

    rc[ 9] = hex[(addr->lap >> 24) & 0xf];
    rc[10] = hex[(addr->lap >> 16) & 0xf];
    rc[12] = hex[(addr->lap >> 12) & 0xf];
    rc[13] = hex[(addr->lap >>  8) & 0xf];
    rc[15] = hex[(addr->lap >>  4) & 0xf];
    rc[16] = hex[(addr->lap >>  0) & 0xf];

    rc[2] = rc[5] = rc[8] = rc[11] = rc[14] = ':';
    rc[17] = 0;

    return rc;
}

static void parse_eir(const uint8 *eir_data, uint8 *endp)
{
    const char *footer[] = { "...", "" };
    const uint8 *p;
    uint16 i;

    for (p = eir_data; p < endp && p[0]; p += 1 + p[0])
    {
        switch (p[1])
        {
        case EIR_NAME_PART:
        case EIR_NAME:
            printf("    EIR name       ");
            for (i = 1; i < p[0]; i++)
                printf("%c", p[1 + i]);
            printf("%s\n", footer[p[1] - EIR_NAME_PART]);
            break;
            
        case EIR_TXPOWER:
            printf("    EIR TX power   %d\n", p[2]);
            break;
            
        default:
            printf("    Unhandled EIR data type %x\n", p[1]);
            break;
        }
    }
}

static void app_handler(Task task, MessageId id, Message message)
{
    switch (id)
    {
    case APP_INQUIRE:
        ConnectionInquire(task, 0x9e8b33, 10, 8, 0);
        break;
   
    case CL_INIT_CFM:
        if (((CL_INIT_CFM_T*)message)->status != success)
            Panic();
        /* set inquiry mode to Inquiry with EIR */
        ConnectionWriteInquiryMode(task, inquiry_mode_eir);
        break;

    case CL_DM_INQUIRE_RESULT:
    {
        CL_DM_INQUIRE_RESULT_T *inq = (CL_DM_INQUIRE_RESULT_T*)message;

        switch (inq->status)
        {
        case inquiry_status_ready:
            /* inquiry completed, start new round after 1 second */
            MessageSendLater(task, APP_INQUIRE, NULL, 1000);
            break;

        case inquiry_status_result:
            printf("%s, RSSI %d\n", bd_format(&inq->bd_addr), inq->rssi);
            /* Extended Inquiry Response data available, print it */
            if (inq->size_eir_data)
                parse_eir(inq->eir_data, inq->eir_data + inq->size_eir_data);
            break;
        } /* switch (inq->status) */
        break;
    }
   
    case CL_DM_WRITE_INQUIRY_MODE_CFM:
        if (((CL_DM_WRITE_INQUIRY_MODE_CFM_T*)message)->status != success)
            Panic();
        /* Send internal message to start an inquiry */
        MessageSend(task, APP_INQUIRE, NULL);
        break;
        
    default:
        DEBUG(printf("Unhandled message 0x%x\n", id));
    }
}

int main(void)
{
    /* Setup application task */
    task.handler = app_handler;

    /* Initialise Connection handler */
    ConnectionInit(&task);
   
    MessageLoop();

    return 0;
}

/* End-of-File */
积分商城 - 让您的金币更有价值!||官方Q群 - 让您的沟通更加及时!
回复 支持 反对

使用道具 举报

连续签到天数:1天
签到总天数:104天
签到总奖励:1701金币
发表于 2014-5-29 13:51:16 | 显示全部楼层
供参考
积分商城 - 让您的金币更有价值!||官方Q群 - 让您的沟通更加及时!
回复 支持 反对

使用道具 举报

连续签到天数:1天
签到总天数:405天
签到总奖励:3173金币
 楼主| 发表于 2014-5-29 14:35:42 | 显示全部楼层
OK,谢谢。
积分商城 - 让您的金币更有价值!||官方Q群 - 让您的沟通更加及时!
回复 支持 反对

使用道具 举报

连续签到天数:1天
签到总天数:45天
签到总奖励:414金币
发表于 2015-1-12 11:50:58 | 显示全部楼层
非常感谢五楼
积分商城 - 让您的金币更有价值!||官方Q群 - 让您的沟通更加及时!
回复 支持 反对

使用道具 举报

连续签到天数:1天
签到总天数:45天
签到总奖励:414金币
发表于 2015-1-14 11:51:36 | 显示全部楼层
(ADK3.0 CSR8670)但是我跟踪得到 size_eir_data 为 0,eir_data【】也为空,为什么?
积分商城 - 让您的金币更有价值!||官方Q群 - 让您的沟通更加及时!
回复 支持 反对

使用道具 举报

连续签到天数:1天
签到总天数:45天
签到总奖励:414金币
发表于 2015-1-16 15:45:49 | 显示全部楼层
问高手得到了答案
调用函数: ConnectionReadRemoteName
积分商城 - 让您的金币更有价值!||官方Q群 - 让您的沟通更加及时!
回复 支持 反对

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册  

本版积分规则

小黑屋|手机版|我爱蓝牙网 - 52Bluetooth

GMT+8, 2024-5-4 09:22 , Processed in 0.328682 second(s), 23 queries , Gzip On, MemCached On.

Powered by Discuz! X3.5

© 2001-2024 Discuz! Team.

快速回复 返回顶部 返回列表