Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
François Revol
firmware
Commits
2766e2f1
Commit
2766e2f1
authored
Aug 21, 2019
by
danukeru
Committed by
schneider
Aug 21, 2019
Browse files
During startup of the BLE, the advert name is pulled off the random bytes of the mac in mac.txt.
parent
7df76031
Changes
3
Hide whitespace changes
Inline
Side-by-side
epicardium/ble/ble.c
View file @
2766e2f1
...
...
@@ -90,16 +90,13 @@ static void WsfInit(void)
/* TODO: We need a source of MACs */
static
void
setAddress
(
void
)
{
uint8_t
bdAddr
[
6
]
=
{
0x
02
,
0x
02
,
0x
44
,
0x
8B
,
0x0
5
,
0x00
};
uint8_t
bdAddr
[
6
]
=
{
0x
CA
,
0x
4D
,
0x
10
,
0x
00
,
0x0
0
,
0x00
};
char
buf
[
32
];
int
result
=
fs_read_text_file
(
"mac.txt"
,
buf
,
sizeof
(
buf
));
if
(
result
==
-
1
)
{
APP_TRACE_INFO0
(
"mac.txt not found, generating random MAC"
);
bdAddr
[
0
]
=
0xCA
;
bdAddr
[
1
]
=
0x4D
;
bdAddr
[
2
]
=
0x10
;
epic_trng_read
(
bdAddr
+
3
,
3
);
sprintf
(
buf
,
"%02x:%02x:%02x:%02x:%02x:%02x
\n
"
,
...
...
@@ -123,7 +120,7 @@ static void setAddress(void)
bdAddr
[
4
]
=
b
;
bdAddr
[
5
]
=
a
;
}
LOG_INFO
(
"ble"
,
"Setting MAC address to %02X:%02X:%02X:%02X:%02X:%02X"
,
...
...
epicardium/ble/ble_main.c
View file @
2766e2f1
...
...
@@ -13,9 +13,11 @@
*/
/* clang-format off */
/* clang-formet turned off for easier diffing against orginal file */
#include
<stdio.h>
#include
<string.h>
#include
"wsf_types.h"
#include
"util/bstream.h"
#include
"fs_util.h"
#include
"wsf_msg.h"
#include
"wsf_trace.h"
#include
"hci_api.h"
...
...
@@ -155,12 +157,12 @@ static const uint8_t bleAdvDataDisc[] =
};
/*! scan data, discoverable mode */
static
const
uint8_t
bleScanDataDisc
[]
=
uint8_t
bleScanDataDisc
[]
=
{
/*! device name */
7
,
/*! length */
14
,
/*! length */
DM_ADV_TYPE_LOCAL_NAME
,
/*! AD type */
'c'
,
'a'
,
'r'
,
'd'
,
'1'
,
'0'
'c'
,
'a'
,
'r'
,
'd'
,
'1'
,
'0'
,
'-'
,
'0'
,
'0'
,
'0'
,
'0'
,
'0'
,
'0'
};
/**************************************************************************************************
...
...
@@ -323,6 +325,22 @@ static void bleClose(bleMsg_t *pMsg)
/*************************************************************************************************/
static
void
bleSetup
(
bleMsg_t
*
pMsg
)
{
char
buf
[
32
];
char
a
,
b
,
c
,
d
,
e
,
f
;
if
(
fs_read_text_file
(
"mac.txt"
,
buf
,
sizeof
(
buf
)))
{
if
(
sscanf
(
buf
,
"**:**:**:%c%c:%c%c:%c%c"
,
&
a
,
&
b
,
&
c
,
&
d
,
&
e
,
&
f
)
==
6
)
{
bleScanDataDisc
[
9
]
=
a
;
bleScanDataDisc
[
10
]
=
b
;
bleScanDataDisc
[
11
]
=
c
;
bleScanDataDisc
[
12
]
=
d
;
bleScanDataDisc
[
13
]
=
e
;
bleScanDataDisc
[
14
]
=
f
;
}
}
/* set advertising and scan response data for discoverable mode */
AppAdvSetData
(
APP_ADV_DATA_DISCOVERABLE
,
sizeof
(
bleAdvDataDisc
),
(
uint8_t
*
)
bleAdvDataDisc
);
AppAdvSetData
(
APP_SCAN_DATA_DISCOVERABLE
,
sizeof
(
bleScanDataDisc
),
(
uint8_t
*
)
bleScanDataDisc
);
...
...
flash-all.gdb
View file @
2766e2f1
...
...
@@ -2,6 +2,9 @@ source init.gdb
set confirm off
mon max32xxx mass_erase 0
mon max32xxx mass_erase 1
echo #### BOOTLOADER ####\n
load build/bootloader/bootloader.elf
echo #### EPICARDIUM ####\n
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment