Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
forks
ble
Commits
ba3b00e8
Commit
ba3b00e8
authored
Aug 28, 2017
by
Hasty Granbery
Browse files
Allow overriding device name
parent
f9e565c9
Changes
1
Hide whitespace changes
Inline
Side-by-side
linux/gatt/server.go
View file @
ba3b00e8
...
...
@@ -9,16 +9,23 @@ import (
)
// NewServer ...
func
NewServer
(
)
(
*
Server
,
error
)
{
func
NewServer
WithName
(
name
string
)
(
*
Server
,
error
)
{
return
&
Server
{
svcs
:
defaultServices
(
"Gopher"
),
db
:
att
.
NewDB
(
defaultServices
(
"Gopher"
),
uint16
(
1
)),
name
:
name
,
svcs
:
defaultServices
(
name
),
db
:
att
.
NewDB
(
defaultServices
(
name
),
uint16
(
1
)),
},
nil
}
// NewServer ...
func
NewServer
()
(
*
Server
,
error
)
{
return
NewServerWithName
(
"Gopher"
)
}
// Server ...
type
Server
struct
{
sync
.
Mutex
name
string
svcs
[]
*
ble
.
Service
db
*
att
.
DB
...
...
@@ -37,7 +44,7 @@ func (s *Server) AddService(svc *ble.Service) error {
func
(
s
*
Server
)
RemoveAllServices
()
error
{
s
.
Lock
()
defer
s
.
Unlock
()
s
.
svcs
=
defaultServices
(
"Gopher"
)
s
.
svcs
=
defaultServices
(
s
.
name
)
s
.
db
=
att
.
NewDB
(
s
.
svcs
,
uint16
(
1
))
// ble attrs start at 1
return
nil
}
...
...
@@ -46,7 +53,7 @@ func (s *Server) RemoveAllServices() error {
func
(
s
*
Server
)
SetServices
(
svcs
[]
*
ble
.
Service
)
error
{
s
.
Lock
()
defer
s
.
Unlock
()
s
.
svcs
=
append
(
defaultServices
(
"Gopher"
),
svcs
...
)
s
.
svcs
=
append
(
defaultServices
(
s
.
name
),
svcs
...
)
s
.
db
=
att
.
NewDB
(
s
.
svcs
,
uint16
(
1
))
// ble attrs start at 1
return
nil
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a 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