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
ee5e69a4
Commit
ee5e69a4
authored
4 years ago
by
schneider
Browse files
Options
Downloads
Patches
Plain Diff
change(ble): More reliability for ble uart
parent
15e030fc
No related branches found
No related tags found
1 merge request
!446
Initial MicroPython BLE support (GATTS)
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
epicardium/ble/ble_api.h
+13
-0
13 additions, 0 deletions
epicardium/ble/ble_api.h
epicardium/ble/ble_main.c
+2
-13
2 additions, 13 deletions
epicardium/ble/ble_main.c
epicardium/ble/uart.c
+27
-18
27 additions, 18 deletions
epicardium/ble/uart.c
epicardium/ble/uart.h
+3
-0
3 additions, 0 deletions
epicardium/ble/uart.h
with
45 additions
and
31 deletions
epicardium/ble/ble_api.h
+
13
−
0
View file @
ee5e69a4
...
@@ -29,3 +29,16 @@ void bleValueUpdate(attEvt_t *pMsg);
...
@@ -29,3 +29,16 @@ void bleValueUpdate(attEvt_t *pMsg);
void
bleDiscCback
(
dmConnId_t
connId
,
uint8_t
status
);
void
bleDiscCback
(
dmConnId_t
connId
,
uint8_t
status
);
void
ble_trigger_event
(
enum
ble_event_type
event
);
void
ble_trigger_event
(
enum
ble_event_type
event
);
void
ble_epic_att_api_init
(
void
);
void
ble_epic_att_api_init
(
void
);
/**************************************************************************************************
Data Types
**************************************************************************************************/
/*! Application message type */
typedef
union
{
wsfMsgHdr_t
hdr
;
dmEvt_t
dm
;
attsCccEvt_t
ccc
;
attEvt_t
att
;
}
bleMsg_t
;
This diff is collapsed.
Click to expand it.
epicardium/ble/ble_main.c
+
2
−
13
View file @
ee5e69a4
...
@@ -52,19 +52,6 @@ static struct epic_scan_report scan_reports[SCAN_REPORTS_NUM];
...
@@ -52,19 +52,6 @@ static struct epic_scan_report scan_reports[SCAN_REPORTS_NUM];
static
int
scan_reports_head
;
static
int
scan_reports_head
;
static
int
scan_reports_tail
;
static
int
scan_reports_tail
;
/**************************************************************************************************
Data Types
**************************************************************************************************/
/*! Application message type */
typedef
union
{
wsfMsgHdr_t
hdr
;
dmEvt_t
dm
;
attsCccEvt_t
ccc
;
attEvt_t
att
;
}
bleMsg_t
;
/**************************************************************************************************
/**************************************************************************************************
Configurable Parameters
Configurable Parameters
**************************************************************************************************/
**************************************************************************************************/
...
@@ -734,6 +721,7 @@ static void bleProcMsg(bleMsg_t *pMsg)
...
@@ -734,6 +721,7 @@ static void bleProcMsg(bleMsg_t *pMsg)
case
ATTS_HANDLE_VALUE_CNF
:
case
ATTS_HANDLE_VALUE_CNF
:
HidProcMsg
(
&
pMsg
->
hdr
);
HidProcMsg
(
&
pMsg
->
hdr
);
UartProcMsg
(
pMsg
);
break
;
break
;
case
ATTS_CCC_STATE_IND
:
case
ATTS_CCC_STATE_IND
:
...
@@ -768,6 +756,7 @@ static void bleProcMsg(bleMsg_t *pMsg)
...
@@ -768,6 +756,7 @@ static void bleProcMsg(bleMsg_t *pMsg)
connOpen
->
peerAddr
[
1
],
connOpen
->
peerAddr
[
0
]);
connOpen
->
peerAddr
[
1
],
connOpen
->
peerAddr
[
0
]);
bleESS_ccc_update
();
bleESS_ccc_update
();
HidProcMsg
(
&
pMsg
->
hdr
);
HidProcMsg
(
&
pMsg
->
hdr
);
UartProcMsg
(
pMsg
);
e
.
hdr
.
event
=
ATT_CONNECTION_OPENED
;
e
.
hdr
.
param
=
connOpen
->
hdr
.
param
;
e
.
hdr
.
event
=
ATT_CONNECTION_OPENED
;
e
.
hdr
.
param
=
connOpen
->
hdr
.
param
;
send_att_event
(
&
e
);
send_att_event
(
&
e
);
break
;
break
;
...
...
This diff is collapsed.
Click to expand it.
epicardium/ble/uart.c
+
27
−
18
View file @
ee5e69a4
...
@@ -126,6 +126,8 @@ static uint8_t UARTWriteCback(
...
@@ -126,6 +126,8 @@ static uint8_t UARTWriteCback(
}
}
static
int
ble_uart_lasttick
=
0
;
static
int
ble_uart_lasttick
=
0
;
static
bool
done
;
static
bool
again
;
void
ble_uart_flush
(
void
)
void
ble_uart_flush
(
void
)
{
{
...
@@ -136,21 +138,23 @@ void ble_uart_flush(void)
...
@@ -136,21 +138,23 @@ void ble_uart_flush(void)
dmConnId_t
connId
=
AppConnIsOpen
();
dmConnId_t
connId
=
AppConnIsOpen
();
if
(
connId
!=
DM_CONN_ID_NONE
)
{
if
(
connId
!=
DM_CONN_ID_NONE
)
{
if
(
AttsCccEnabled
(
connId
,
UART_TX_CH_CCC_IDX
))
{
if
(
AttsCccEnabled
(
connId
,
UART_TX_CH_CCC_IDX
))
{
int
x
=
xTaskGetTickCount
()
-
ble_uart_lasttick
;
done
=
false
;
if
(
x
<
100
)
{
again
=
true
;
/*
* TODO: Ugly hack if we already
// TODO: Modify for no initial delay
* sent something recently.
while
(
!
done
&&
((
xTaskGetTickCount
()
-
* Use ATTS_HANDLE_VALUE_CNF instead.
ble_uart_lasttick
)
<
1000
))
{
*/
if
(
again
)
{
vTaskDelay
(
100
-
x
);
again
=
false
;
AttsHandleValueNtf
(
connId
,
UART_TX_HDL
,
ble_uart_buf_tx_fill
,
ble_uart_tx_buf
);
}
vTaskDelay
(
5
);
}
}
AttsHandleValueNtf
(
connId
,
UART_TX_HDL
,
ble_uart_buf_tx_fill
,
ble_uart_tx_buf
);
ble_uart_lasttick
=
xTaskGetTickCount
();
ble_uart_lasttick
=
xTaskGetTickCount
();
}
}
}
}
...
@@ -191,13 +195,18 @@ void bleuart_init(void)
...
@@ -191,13 +195,18 @@ void bleuart_init(void)
AttsAddGroup
(
&
uartCfgGroup
);
AttsAddGroup
(
&
uartCfgGroup
);
}
}
void
UartProcMsg
(
wsfMsgHdr
_t
*
pMsg
)
void
UartProcMsg
(
bleMsg
_t
*
pMsg
)
{
{
if
(
pMsg
->
event
==
ATTS_HANDLE_VALUE_CNF
)
{
if
(
pMsg
->
hdr
.
event
==
ATTS_HANDLE_VALUE_CNF
)
{
if
(
pMsg
->
status
==
ATT_SUCCESS
)
{
if
(
pMsg
->
att
.
handle
==
UART_TX_HDL
)
{
if
(
pMsg
->
hdr
.
status
==
ATT_SUCCESS
)
{
done
=
true
;
}
else
if
(
pMsg
->
hdr
.
status
==
ATT_ERR_OVERFLOW
)
{
again
=
true
;
}
}
}
}
}
if
(
pMsg
->
event
==
DM_CONN_OPEN_IND
)
{
if
(
pMsg
->
hdr
.
event
==
DM_CONN_OPEN_IND
)
{
ble_uart_buf_tx_fill
=
0
;
ble_uart_buf_tx_fill
=
0
;
}
}
}
}
This diff is collapsed.
Click to expand it.
epicardium/ble/uart.h
+
3
−
0
View file @
ee5e69a4
#pragma once
#pragma once
#include
"ble_api.h"
#define UART_START_HDL 0x800
/*!< \brief Service start handle. */
#define UART_START_HDL 0x800
/*!< \brief Service start handle. */
#define UART_END_HDL (UART_MAX_HDL - 1)
/*!< \brief Service end handle. */
#define UART_END_HDL (UART_MAX_HDL - 1)
/*!< \brief Service end handle. */
...
@@ -13,4 +15,5 @@ enum { UART_SVC_HDL = UART_START_HDL, /*!< \brief UART service declaration */
...
@@ -13,4 +15,5 @@ enum { UART_SVC_HDL = UART_START_HDL, /*!< \brief UART service declaration */
UART_MAX_HDL
/*!< \brief Maximum handle. */
UART_MAX_HDL
/*!< \brief Maximum handle. */
};
};
void
UartProcMsg
(
bleMsg_t
*
pMsg
);
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