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
15e030fc
Commit
15e030fc
authored
4 years ago
by
schneider
Browse files
Options
Downloads
Patches
Plain Diff
change(ble): correctly handle connections in ble uart
parent
a9bd7192
Branches
Branches containing commit
Tags
Tags containing commit
1 merge request
!446
Initial MicroPython BLE support (GATTS)
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
epicardium/ble/uart.c
+27
-11
27 additions, 11 deletions
epicardium/ble/uart.c
with
27 additions
and
11 deletions
epicardium/ble/uart.c
+
27
−
11
View file @
15e030fc
#include
"uart.h"
#include
"cccd.h"
#include
"modules/modules.h"
#include
"wsf_types.h"
#include
"util/bstream.h"
#include
"att_api.h"
#include
"dm_api.h"
#include
"app_api.h"
#include
"FreeRTOS.h"
#include
"timers.h"
...
...
@@ -99,8 +102,6 @@ static const attsAttr_t uartAttrCfgList[] = {
};
dmConnId_t
active_connection
=
0
;
static
uint8_t
UARTWriteCback
(
dmConnId_t
connId
,
uint16_t
handle
,
...
...
@@ -110,7 +111,6 @@ static uint8_t UARTWriteCback(
uint8_t
*
pValue
,
attsAttr_t
*
pAttr
)
{
active_connection
=
connId
;
static
bool
was_r
=
false
;
int
i
;
...
...
@@ -129,27 +129,32 @@ static int ble_uart_lasttick = 0;
void
ble_uart_flush
(
void
)
{
if
(
ble_uart_buf_tx_fill
>
0
)
{
if
(
active_connection
)
{
if
(
ble_uart_buf_tx_fill
==
0
)
{
return
;
}
dmConnId_t
connId
=
AppConnIsOpen
();
if
(
connId
!=
DM_CONN_ID_NONE
)
{
if
(
AttsCccEnabled
(
connId
,
UART_TX_CH_CCC_IDX
))
{
int
x
=
xTaskGetTickCount
()
-
ble_uart_lasttick
;
if
(
x
<
100
)
{
/*
* TODO: Ugly hack if we already
* sent something recently.
* Use ATTS_HANDLE_VALUE_CNF instead.
*/
* TODO: Ugly hack if we already
* sent something recently.
* Use ATTS_HANDLE_VALUE_CNF instead.
*/
vTaskDelay
(
100
-
x
);
}
AttsHandleValueNtf
(
active_connection
,
connId
,
UART_TX_HDL
,
ble_uart_buf_tx_fill
,
ble_uart_tx_buf
);
ble_uart_lasttick
=
xTaskGetTickCount
();
}
ble_uart_buf_tx_fill
=
0
;
}
ble_uart_buf_tx_fill
=
0
;
}
void
ble_uart_write_char
(
uint8_t
c
)
...
...
@@ -185,3 +190,14 @@ void bleuart_init(void)
/* Add the UART service */
AttsAddGroup
(
&
uartCfgGroup
);
}
void
UartProcMsg
(
wsfMsgHdr_t
*
pMsg
)
{
if
(
pMsg
->
event
==
ATTS_HANDLE_VALUE_CNF
)
{
if
(
pMsg
->
status
==
ATT_SUCCESS
)
{
}
}
if
(
pMsg
->
event
==
DM_CONN_OPEN_IND
)
{
ble_uart_buf_tx_fill
=
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