NORDIC WAS MAC ADDR

Ble a device, addresses may be divided into two categories

Public Device Address (public address equipment)
Public Public Device Address Device Address is a number 48bits, just and computer mac address, is the world's only general traditional Bluetooth use this address.

Random Device Address (random device address)
is not a fixed allocation, but randomly assigned after the device starts, Random Device Address (random device address) in turn can be divided into two categories
Static Device Address (static device address)
up 2bits is "11",
the remaining 46bits is a random number, not all zeros or all
on one electrical cycle remains constant
at the next power change may be constant
Private Device Address (Private device address)
into two categories
Non-resolvable private address (private address unresolvable)
up 2bits "00"
remaining 46bits random number, not all 0s or all 1s
every periodic update T_GAP
Resolvable private address (private address unresolvable)
high 24bits random number, the highest 2bits "10"
lower 24bits random number and IRK been to the hash function to obtain a hash value, hash = ah (IRK, prand )
peer BLE scanned after such an address, for ah operation with prand local IRK and the address, If the obtained value and the lower 24bits address type is consistent with that subsequent operations.
 
api sdk associated
 obtain a local address mac
 [OUT] p addr
 uint32_t sd_ble_gap_address_get (ble_gap_addr_t * p addr);
123
ble_gap_addr_t structure as follows
. / ** @ Brief the Bluetooth Low Energy address * /
typedef struct
{
  // address type
  uint8_t addr_type; / ** . <BLE_GAP_ADDR_TYPES See @ref * /
  // address for storing an array of 6-byte
  uint8_t addr [BLE_GAP_ADDR_LEN]; / ** <48 'bit-address, the LSB the format * /.
} ble_gap_addr_t;
12345678
[in] addr_cycle_mode:
 / ** < Directly Addresses the SET, NO Automatic address Cycling. * /
 BLE_GAP_ADDR_CYCLE_MODE_NONE 0x00
 / ** <Automatically Update the Generate and Private Addresses. * /
 BLE_GAP_ADDR_CYCLE_MODE_AUTO 0x01
attention when he set up with a static random address Static Device Address, the highest 2bits address must be "11", otherwise invalid
uint32_t sd_ble_gap_address_set (uint8_t addr_cycle_mode, ble_gap_addr_t const * p_addr);

The following is the address of the default setting of +1 function
void mac_set (void)
{
  ble_gap_addr_t addr;
  // get the address
  uint32_t = sd_ble_gap_address_get ERR_CODE is set (& addr);
  APP_ERROR_CHECK (ERR_CODE is set);
  addr.addr [0] + =. 1;
  // write address
  err_code = sd_ble_gap_address_set (BLE_GAP_ADDR_CYCLE_MODE_NONE, & addr );
  APP_ERROR_CHECK (ERR_CODE is set);
}
description link: https: //blog.csdn.net/weixin_41572450/article/details/84000178

Guess you like

Origin www.cnblogs.com/yeshenmeng/p/12010319.html