CC2640 MAC地址理解、使用和更改

第一章CC2640 MAC地址使用、理解和更改

说明:一般BLE在出厂时都有唯一的标识地址,俗称MAC地址,其在广播时,随设备名一起广播出去。请看用Packet Sniffer抓包结果:

ADVA 0X0AD0AD0AD0AD 就是MAC 地址。

可以修改,对应代码如下:

static void SimpleBLEPeripheral_init(void)
{
  // ******************************************************************
  // N0 STACK API CALLS CAN OCCUR BEFORE THIS CALL TO ICall_registerApp
  // ******************************************************************
  // Register the current thread as an ICall dispatcher application
  // so that the application can send and receive messages.
  ICall_registerApp(&selfEntity, &sem);           //ICall 注册当前线程任务

  // 以下功能为修改mac地址
  // Hard code the BD Address till CC2650 board gets its own IEEE address
  uint8 bdAddress[B_ADDR_LEN] = { 0xAD, 0xD0, 0x0A, 0xAD, 0xD0, 0x0A };
  HCI_EXT_SetBDADDRCmd(bdAddress);

  // Set device's Sleep Clock Accuracy
  HCI_EXT_SetSCACmd(40);

  // Create an RTOS queue for message from profile to be sent to app.
  appMsgQueue = Util_constructQueue(&appMsg); //建立与RTOS队列

其中:bdAddress[B_ADDR_LEN] 为要修改的MAC地址数组,B_ADDR_LENMAC地址数组长度,一般为6.

HCI_EXT_SetBDADDRCmd(bdAddress);执行MAC地址修改。执行之后要延时一段时间。使用函数HCI_EXT_SetSCACmd(40);

由函数可知 MAC地址的实现一般都是由HCI层来进行的。

如果将这两行代码屏蔽后会有什么现象呢?

static void SimpleBLEPeripheral_init(void)
{
  // ******************************************************************
  // N0 STACK API CALLS CAN OCCUR BEFORE THIS CALL TO ICall_registerApp
  // ******************************************************************
  // Register the current thread as an ICall dispatcher application
  // so that the application can send and receive messages.
  ICall_registerApp(&selfEntity, &sem);           //ICall 注册当前线程任务

  // 以下功能为修改mac地址
  // Hard code the BD Address till CC2650 board gets its own IEEE address
  //uint8 bdAddress[B_ADDR_LEN] = { 0xAD, 0xD0, 0x0A, 0xAD, 0xD0, 0x0A };
  //HCI_EXT_SetBDADDRCmd(bdAddress);

  // Set device's Sleep Clock Accuracy
  //HCI_EXT_SetSCACmd(40);

  // Create an RTOS queue for message from profile to be sent to app.
  appMsgQueue = Util_constructQueue(&appMsg); //建立与RTOS队列

Packet Sniffer 抓包结果如下:

此时AdvA0XA0E6F807ACD2。此为本BLE默认的MAC地址。

 

 

  • 2
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值