Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
R
RIOT
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container registry
Model registry
Operate
Environments
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
cm-projects
RIOT
Commits
d6d9d669
Commit
d6d9d669
authored
6 years ago
by
Hauke Petersen
Browse files
Options
Downloads
Patches
Plain Diff
examples/nimble_gatt: use bluetil_ad
parent
23abc896
No related branches found
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
examples/nimble_gatt/Makefile
+3
-0
3 additions, 0 deletions
examples/nimble_gatt/Makefile
examples/nimble_gatt/main.c
+8
-21
8 additions, 21 deletions
examples/nimble_gatt/main.c
with
11 additions
and
21 deletions
examples/nimble_gatt/Makefile
+
3
−
0
View file @
d6d9d669
...
@@ -13,6 +13,9 @@ RIOTBASE ?= $(CURDIR)/../..
...
@@ -13,6 +13,9 @@ RIOTBASE ?= $(CURDIR)/../..
# Include NimBLE
# Include NimBLE
USEPKG
+=
nimble
USEPKG
+=
nimble
# We also use the AD part of the BLE helper module
USEMODULE
+=
bluetil_ad
# Comment this out to disable code in RIOT that does safety checking
# Comment this out to disable code in RIOT that does safety checking
# which is not needed in a production environment but helps in the
# which is not needed in a production environment but helps in the
# development process:
# development process:
...
...
This diff is collapsed.
Click to expand it.
examples/nimble_gatt/main.c
+
8
−
21
View file @
d6d9d669
...
@@ -23,39 +23,26 @@
...
@@ -23,39 +23,26 @@
#include
<stdio.h>
#include
<stdio.h>
#include
<string.h>
#include
<string.h>
#include
"net/bluetil/ad.h"
#include
"host/ble_hs.h"
#include
"host/ble_hs.h"
#include
"host/util/util.h"
#include
"host/util/util.h"
#include
"host/ble_gatt.h"
#include
"host/ble_gatt.h"
#include
"services/gap/ble_svc_gap.h"
#include
"services/gap/ble_svc_gap.h"
#include
"services/gatt/ble_svc_gatt.h"
#include
"services/gatt/ble_svc_gatt.h"
static
const
char
device_name
[]
=
"NimBLE on RIOT"
;
static
const
char
*
device_name
=
"NimBLE on RIOT"
;
static
uint8_t
own_addr_type
;
static
uint8_t
own_addr_type
;
static
void
start_advertise
(
void
);
static
void
start_advertise
(
void
);
static
void
put_ad
(
uint8_t
ad_type
,
uint8_t
ad_len
,
const
void
*
ad
,
uint8_t
*
buf
,
uint8_t
*
len
)
{
buf
[(
*
len
)
++
]
=
ad_len
+
1
;
buf
[(
*
len
)
++
]
=
ad_type
;
memcpy
(
&
buf
[
*
len
],
ad
,
ad_len
);
*
len
+=
ad_len
;
}
static
void
update_ad
(
void
)
static
void
update_ad
(
void
)
{
{
uint8_t
ad
[
BLE_HS_ADV_MAX_SZ
];
uint8_t
buf
[
BLE_HS_ADV_MAX_SZ
];
uint8_t
ad_len
=
0
;
bluetil_ad_t
ad
;
uint8_t
ad_flags
=
BLE_HS_ADV_F_DISC_GEN
|
BLE_HS_ADV_F_BREDR_UNSUP
;
bluetil_ad_init_with_flags
(
&
ad
,
buf
,
sizeof
(
buf
),
BLUETIL_AD_FLAGS_DEFAULT
);
bluetil_ad_add_name
(
&
ad
,
device_name
);
put_ad
(
BLE_HS_ADV_TYPE_FLAGS
,
1
,
&
ad_flags
,
ad
,
&
ad_len
);
ble_gap_adv_set_data
(
ad
.
buf
,
ad
.
pos
);
put_ad
(
BLE_HS_ADV_TYPE_COMP_NAME
,
sizeof
(
device_name
),
device_name
,
ad
,
&
ad_len
);
ble_gap_adv_set_data
(
ad
,
ad_len
);
}
}
static
int
gap_event_cb
(
struct
ble_gap_event
*
event
,
void
*
arg
)
static
int
gap_event_cb
(
struct
ble_gap_event
*
event
,
void
*
arg
)
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
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!
Save comment
Cancel
Please
register
or
sign in
to comment