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
f829887f
Commit
f829887f
authored
6 years ago
by
Hauke Petersen
Browse files
Options
Downloads
Patches
Plain Diff
examples/nimble_gatt: simplify example
parent
73534850
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
examples/nimble_gatt/main.c
+19
-31
19 additions, 31 deletions
examples/nimble_gatt/main.c
with
19 additions
and
31 deletions
examples/nimble_gatt/main.c
+
19
−
31
View file @
f829887f
...
@@ -23,11 +23,9 @@
...
@@ -23,11 +23,9 @@
#include
<stdio.h>
#include
<stdio.h>
#include
<string.h>
#include
<string.h>
#include
"nimble_riot.h"
#include
"nimble/nimble_port.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
"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"
...
@@ -93,13 +91,26 @@ static void start_advertise(void)
...
@@ -93,13 +91,26 @@ static void start_advertise(void)
(
void
)
rc
;
(
void
)
rc
;
}
}
static
void
app_ble_sync_cb
(
void
)
int
main
(
void
)
{
{
int
rc
;
puts
(
"NimBLE GATT Server Example"
)
;
rc
=
ble_hs_util_ensure_addr
(
0
);
/* set the device name */
as
se
r
t
(
rc
==
0
);
ble_svc_gap_device_name_
set
(
device_name
);
/* initialize the GAP and GATT services */
ble_svc_gap_init
();
ble_svc_gatt_init
();
/* XXX: seems to be needed to apply the added services */
ble_gatts_start
();
/* make sure synchronization of host and controller is done, this should
* always be the case */
while
(
!
ble_hs_synced
())
{}
/* configure device address */
int
rc
=
ble_hs_util_ensure_addr
(
0
);
assert
(
rc
==
0
);
rc
=
ble_hs_id_infer_auto
(
0
,
&
own_addr_type
);
rc
=
ble_hs_id_infer_auto
(
0
,
&
own_addr_type
);
assert
(
rc
==
0
);
assert
(
rc
==
0
);
(
void
)
rc
;
(
void
)
rc
;
...
@@ -107,31 +118,8 @@ static void app_ble_sync_cb(void)
...
@@ -107,31 +118,8 @@ static void app_ble_sync_cb(void)
/* generate the advertising data */
/* generate the advertising data */
update_ad
();
update_ad
();
/* start to advertise this node */
start_advertise
();
start_advertise
();
}
int
main
(
void
)
{
puts
(
"NimBLE GATT Server Example"
);
/* initialize NimBLE's controller */
nimble_riot_controller_init
();
/* register the synchronization callback that is triggered once the host has
* finished its initialization */
ble_hs_cfg
.
sync_cb
=
app_ble_sync_cb
;
/* initialize NimBLE porting layer and the default GATT and GAP services*/
nimble_port_init
();
ble_svc_gap_init
();
ble_svc_gatt_init
();
/* set the device name */
ble_svc_gap_device_name_set
(
device_name
);
/* and finally run NimBLE's host event loop. The event loop contains a pre-
* configured event which will trigger the hosts initialization */
nimble_port_run
();
return
0
;
return
0
;
}
}
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