Contiki-NG
Toggle main menu visibility
Loading...
Searching...
No Matches
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
int
58
ble_addr_to_eui64
(uint8_t *dst, uint8_t *src)
59
{
60
if
(!dst || !src) {
61
return
-1;
62
}
63
64
memcpy(dst, src, 3);
65
dst[3] = 0xFF;
66
dst[4] = 0xFE;
67
memcpy(&dst[5], &src[3], 3);
68
69
return
0;
70
}
71
/*---------------------------------------------------------------------------*/
72
void
73
ble_eui64_addr_cpy_to
(uint8_t *dst)
74
{
75
uint8_t ble_addr[BLE_ADDR_SIZE];
76
ble_addr_cpy_to
(ble_addr);
77
ble_addr_to_eui64
(dst, ble_addr);
78
}
ble-hal.h
hardware abstraction for a BLE controller
ble_eui64_addr_cpy_to
void ble_eui64_addr_cpy_to(uint8_t *dst)
Copy the node's EUI64 address that is based on its factory BLE address to a destination memory area.
Definition
ble-addr.c:73
ble_addr_cpy_to
void ble_addr_cpy_to(uint8_t *dst)
Copy the node's factory BLE address to a destination memory area.
Definition
ble-addr.c:47
ble_addr_to_eui64
int ble_addr_to_eui64(uint8_t *dst, uint8_t *src)
Copy the node's BLE address to a destination memory area and converts it into a EUI64 address in the ...
Definition
ble-addr.c:58
ble-addr.h
Driver for the retrieval of an BLE address from flash.
linkaddr.h
Header file for the link-layer address representation.
arch
cpu
cc26x0-cc13x0
ble-addr.c
Generated on
for Contiki-NG by
1.17.0