Contiki-NG
ble-addr.c
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2016, Michael Spoerk
3  * All rights reserved.
4  *
5  * Redistribution and use in source and binary forms, with or without
6  * modification, are permitted provided that the following conditions
7  * are met:
8  * 1. Redistributions of source code must retain the above copyright
9  * notice, this list of conditions and the following disclaimer.
10  * 2. Redistributions in binary form must reproduce the above copyright
11  * notice, this list of conditions and the following disclaimer in the
12  * documentation and/or other materials provided with the distribution.
13  * 3. Neither the name of the copyright holder nor the names of its
14  * contributors may be used to endorse or promote products derived
15  * from this software without specific prior written permission.
16  *
17  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
18  * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
19  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
20  * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
21  * COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
22  * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
23  * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
24  * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
25  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
26  * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
27  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
28  * OF THE POSSIBILITY OF SUCH DAMAGE.
29  *
30  */
31 /**
32  * \file
33  * Driver for the retrieval of an BLE address from flash
34  *
35  * \author
36  * Michael Spoerk <mi.spoerk@gmail.com>
37  */
38 /*---------------------------------------------------------------------------*/
39 #include "contiki-conf.h"
40 #include "net/linkaddr.h"
41 #include <string.h>
42 
43 #include "ble-addr.h"
44 #include "os/dev/ble-hal.h"
45 /*---------------------------------------------------------------------------*/
46 void
47 ble_addr_cpy_to(uint8_t *dst)
48 {
49  int i;
50  uint8_t *location = (uint8_t *)BLE_ADDR_LOCATION;
51 
52  for(i = 0; i < BLE_ADDR_SIZE; i++) {
53  dst[i] = location[BLE_ADDR_SIZE - 1 - i];
54  }
55 }
56 /*---------------------------------------------------------------------------*/
57 void
58 ble_addr_to_eui64(uint8_t *dst, uint8_t *src)
59 {
60  memcpy(dst, src, 3);
61  dst[3] = 0xFF;
62  dst[4] = 0xFE;
63  memcpy(&dst[5], &src[3], 3);
64 }
65 /*---------------------------------------------------------------------------*/
66 void
67 ble_eui64_addr_cpy_to(uint8_t *dst)
68 {
69  uint8_t ble_addr[BLE_ADDR_SIZE];
70  ble_addr_cpy_to(ble_addr);
71  ble_addr_to_eui64(dst, ble_addr);
72 }
Header file for the link-layer address representation
void ble_addr_cpy_to(uint8_t *dst)
Copy the node&#39;s factory BLE address to a destination memory area.
Definition: ble-addr.c:47
void ble_eui64_addr_cpy_to(uint8_t *dst)
Copy the node&#39;s EUI64 address that is based on its factory BLE address to a destination memory area...
Definition: ble-addr.c:67
hardware abstraction for a BLE controller
void ble_addr_to_eui64(uint8_t *dst, uint8_t *src)
Copy the node&#39;s BLE address to a destination memory area and converts it into a EUI64 address in the ...
Definition: ble-addr.c:58
Driver for the retrieval of an BLE address from flash.