Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
F
firmware
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
External wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Model registry
Monitor
Service Desk
Analyze
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
card10
firmware
Commits
f88d12f6
Commit
f88d12f6
authored
4 years ago
by
schneider
Browse files
Options
Downloads
Patches
Plain Diff
feat(ble): Add Evironmental Sensing Service
parent
ebc42128
Branches
Branches containing commit
No related tags found
1 merge request
!428
Environmental Sensing Service
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
epicardium/ble/ble.c
+2
-0
2 additions, 0 deletions
epicardium/ble/ble.c
epicardium/ble/ess.c
+124
-0
124 additions, 0 deletions
epicardium/ble/ess.c
epicardium/ble/meson.build
+1
-0
1 addition, 0 deletions
epicardium/ble/meson.build
with
127 additions
and
0 deletions
epicardium/ble/ble.c
+
2
−
0
View file @
f88d12f6
...
...
@@ -69,6 +69,7 @@ extern void StackInit(void);
extern
void
bleuart_init
(
void
);
extern
void
bleFileTransfer_init
(
void
);
extern
void
bleCard10_init
(
void
);
extern
void
bleESS_init
(
void
);
extern
void
BbBleDrvSetTxPower
(
int8_t
power
);
/*************************************************************************************************/
...
...
@@ -432,6 +433,7 @@ void vBleTask(void *pvParameters)
bleuart_init
();
bleFileTransfer_init
();
bleCard10_init
();
bleESS_init
();
lasttick
=
xTaskGetTickCount
();
...
...
This diff is collapsed.
Click to expand it.
epicardium/ble/ess.c
0 → 100644
+
124
−
0
View file @
f88d12f6
#include
"wsf_types.h"
#include
"util/bstream.h"
#include
"wsf_assert.h"
#include
"att_api.h"
#include
"epicardium.h"
#include
<stdio.h>
#include
<string.h>
#include
<stdbool.h>
#include
<machine/endian.h>
/*!< \brief Service start handle. */
#define ESS_START_HDL 0x1000
/*!< \brief Service end handle. */
#define ESS_END_HDL (ESS_MAX_HDL - 1)
enum
{
/*!< \brief environmental sensing services service declaration */
ESS_SVC_HDL
=
ESS_START_HDL
,
/*!< \brief temperature characteristic */
ESS_TEMPERATURE_CH_HDL
,
ESS_TEMPERATURE_VAL_HDL
,
/*!< \brief Maximum handle. */
ESS_MAX_HDL
};
/* clang-format off */
/* BLE UUID for ESS service*/
static
const
uint8_t
UUID_svc
[]
=
{
UINT16_TO_BYTES
(
ATT_UUID_ENVIRONMENTAL_SENSING_SERVICE
)
};
static
const
uint16_t
UUID_svc_len
=
sizeof
(
UUID_svc
);
/* BLE UUID for temperature */
static
const
uint8_t
UUID_char_temperature
[]
=
{
ATT_PROP_READ
,
UINT16_TO_BYTES
(
ESS_TEMPERATURE_VAL_HDL
),
UINT16_TO_BYTES
(
ATT_UUID_TEMPERATURE
)
};
static
const
uint16_t
UUID_char_len
=
sizeof
(
UUID_char_temperature
);
static
uint8_t
initTemperatureValue
[]
=
{
UINT16_TO_BYTES
(
0
)
};
static
uint16_t
initTemperatureLen
=
sizeof
(
initTemperatureValue
);
/* clang-format on */
/*
* BLE service description
*/
static
const
attsAttr_t
ESSSvcAttrList
[]
=
{
{
.
pUuid
=
attPrimSvcUuid
,
.
pValue
=
(
uint8_t
*
)
UUID_svc
,
.
pLen
=
(
uint16_t
*
)
&
UUID_svc_len
,
.
maxLen
=
sizeof
(
UUID_svc
),
.
permissions
=
ATTS_PERMIT_READ
,
},
// Temperature
{
.
pUuid
=
attChUuid
,
.
pValue
=
(
uint8_t
*
)
UUID_char_temperature
,
.
pLen
=
(
uint16_t
*
)
&
UUID_char_len
,
.
maxLen
=
sizeof
(
UUID_char_temperature
),
.
permissions
=
ATTS_PERMIT_READ
,
},
{
.
pUuid
=
attTemperatureChUuid
,
.
pValue
=
initTemperatureValue
,
.
pLen
=
&
initTemperatureLen
,
.
maxLen
=
sizeof
(
initTemperatureValue
),
.
settings
=
ATTS_SET_READ_CBACK
,
.
permissions
=
ATTS_PERMIT_READ
|
ATTS_PERMIT_READ_ENC
|
ATTS_PERMIT_READ_AUTH
,
},
};
// validating that the service really has all charateristics
WSF_CT_ASSERT
(
((
sizeof
(
ESSSvcAttrList
)
/
sizeof
(
ESSSvcAttrList
[
0
]))
==
ESS_END_HDL
-
ESS_START_HDL
+
1
));
/*
* BLE ESS read callback.
*/
static
uint8_t
readESSCB
(
dmConnId_t
connId
,
uint16_t
handle
,
uint8_t
operation
,
uint16_t
offset
,
attsAttr_t
*
pAttr
)
{
uint16_t
i16
=
0
;
switch
(
handle
)
{
// Temperature
case
ESS_TEMPERATURE_VAL_HDL
:
//pAttr->pValue[0] = i16 & 0xFF; //pAttr->pValue[1] = i16 >> 8;
*
((
int16_t
*
)
pAttr
->
pValue
)
=
i16
;
APP_TRACE_INFO1
(
"ble-ess: read temperature: %d
\n
"
,
i16
);
return
ATT_SUCCESS
;
default:
APP_TRACE_INFO0
(
"ble-card10: read no handler found
\n
"
);
return
ATT_ERR_HANDLE
;
}
}
static
attsGroup_t
svcESSGroup
=
{
.
pNext
=
NULL
,
.
pAttr
=
(
attsAttr_t
*
)
ESSSvcAttrList
,
.
readCback
=
readESSCB
,
.
writeCback
=
NULL
,
.
startHandle
=
ESS_START_HDL
,
.
endHandle
=
ESS_END_HDL
,
};
/*
* This registers and starts the BLE card10 service.
*/
void
bleESS_init
(
void
)
{
AttsAddGroup
(
&
svcESSGroup
);
}
This diff is collapsed.
Click to expand it.
epicardium/ble/meson.build
+
1
−
0
View file @
f88d12f6
...
...
@@ -10,5 +10,6 @@ ble_sources = files(
'bondings.c'
,
'uart.c'
,
'card10.c'
,
'ess.c'
,
'filetransfer.c'
,
)
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