Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
Stefan Haun
firmware
Commits
af026115
Verified
Commit
af026115
authored
Aug 20, 2019
by
Rahix
Browse files
chore(ble): Move ble_shall_start() into ble module
Signed-off-by:
Rahix
<
rahix@rahix.de
>
parent
d4295ca4
Changes
3
Hide whitespace changes
Inline
Side-by-side
epicardium/ble/ble.c
View file @
af026115
#include
"epicardium.h"
#include
"modules/log.h"
#include
"fs_util.h"
...
...
@@ -172,6 +173,37 @@ void wsf_ble_signal_event(void)
notify
();
}
/*************************************************************************************************/
#define BLEMAXCFGBYTES 100
bool
ble_shall_start
(
void
)
{
int
bleConfigFile
=
epic_file_open
(
"ble.txt"
,
"r"
);
if
(
bleConfigFile
<
0
)
{
LOG_INFO
(
"ble"
,
"can not open ble.txt -> BLE is not started"
);
epic_file_close
(
bleConfigFile
);
return
false
;
}
char
cfgBuf
[
BLEMAXCFGBYTES
+
1
];
int
readNum
=
epic_file_read
(
bleConfigFile
,
cfgBuf
,
BLEMAXCFGBYTES
);
epic_file_close
(
bleConfigFile
);
if
(
readNum
<
0
)
{
LOG_WARN
(
"ble"
,
"can not read ble.txt -> BLE is not started"
);
return
false
;
}
cfgBuf
[
readNum
]
=
'\0'
;
char
bleActiveStr
[]
=
"active=true"
;
cfgBuf
[
sizeof
(
bleActiveStr
)
-
1
]
=
'\0'
;
if
(
strcmp
(
cfgBuf
,
"active=true"
)
!=
0
)
{
LOG_INFO
(
"ble"
,
"BLE is disabled."
);
return
false
;
}
else
{
LOG_INFO
(
"ble"
,
"BLE is enabled."
);
return
true
;
}
}
/*************************************************************************************************/
static
void
scheduleTimer
(
void
)
{
bool_t
timerRunning
;
...
...
epicardium/main.c
View file @
af026115
...
...
@@ -9,46 +9,6 @@
#include
<stdlib.h>
#include
<string.h>
#define BLEMAXCFGBYTES 100
int
bleShallStart
(
void
)
{
int
bleConfigFile
=
epic_file_open
(
"ble.txt"
,
"r"
);
if
(
bleConfigFile
<
0
)
{
LOG_INFO
(
"startup"
,
"can not open ble.txt -> BLE is not started"
);
epic_file_close
(
bleConfigFile
);
return
0
;
}
char
cfgBuf
[
BLEMAXCFGBYTES
+
1
];
int
readNum
=
epic_file_read
(
bleConfigFile
,
cfgBuf
,
BLEMAXCFGBYTES
);
epic_file_close
(
bleConfigFile
);
if
(
readNum
<
0
)
{
LOG_INFO
(
"startup"
,
"can not read ble.txt -> BLE is not started"
);
return
0
;
}
cfgBuf
[
readNum
]
=
'\0'
;
char
bleActiveStr
[]
=
"active=true"
;
cfgBuf
[
sizeof
(
bleActiveStr
)
-
1
]
=
'\0'
;
if
(
strcmp
(
cfgBuf
,
"active=true"
)
!=
0
)
{
LOG_INFO
(
"startup"
,
"ble.txt is not
\"
active=true
\"
-> BLE is not started"
);
return
0
;
}
LOG_INFO
(
"startup"
,
"ble.txt is
\"
active=true
\"
-> BLE is starting"
);
return
1
;
}
int
main
(
void
)
{
LOG_INFO
(
"startup"
,
"Epicardium startup ..."
);
...
...
@@ -100,7 +60,7 @@ int main(void)
}
/* BLE */
if
(
ble
S
hall
S
tart
())
{
if
(
ble
_s
hall
_s
tart
())
{
if
(
xTaskCreate
(
vBleTask
,
(
const
char
*
)
"BLE"
,
...
...
epicardium/modules/modules.h
View file @
af026115
...
...
@@ -5,6 +5,7 @@
#include
"semphr.h"
#include
<stdint.h>
#include
<stdbool.h>
/* ---------- Dispatcher --------------------------------------------------- */
void
vApiDispatcher
(
void
*
pvParameters
);
...
...
@@ -33,6 +34,7 @@ void vPmicTask(void *pvParameters);
/* ---------- BLE ---------------------------------------------------------- */
void
vBleTask
(
void
*
pvParameters
);
bool
ble_shall_start
(
void
);
void
ble_uart_write
(
uint8_t
*
pValue
,
uint8_t
len
);
/* ---------- Display ------------------------------------------------------ */
...
...
Write
Preview
Supports
Markdown
0%
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!
Cancel
Please
register
or
sign in
to comment