mirror of
https://github.com/arendst/Tasmota.git
synced 2025-07-22 18:26:30 +00:00
allow Berry fast_loop for BLE module (#20281)
This commit is contained in:
parent
e5abd47c86
commit
0e87096bad
@ -46,6 +46,9 @@ module MI32 (scope: global) {
|
||||
|
||||
extern int be_BLE_init(bvm *vm);
|
||||
|
||||
extern void be_BLE_loop(void);
|
||||
BE_FUNC_CTYPE_DECLARE(be_BLE_loop, "", "");
|
||||
|
||||
extern void be_BLE_reg_conn_cb(void* function, uint8_t *buffer);
|
||||
BE_FUNC_CTYPE_DECLARE(be_BLE_reg_conn_cb, "", "cc");
|
||||
|
||||
@ -79,6 +82,7 @@ BE_FUNC_CTYPE_DECLARE(be_BLE_adv_block, "", "@(bytes)~[i]");
|
||||
/* @const_object_info_begin
|
||||
module BLE (scope: global) {
|
||||
init, func(be_BLE_init)
|
||||
loop, ctype_func(be_BLE_loop)
|
||||
conn_cb, ctype_func(be_BLE_reg_conn_cb)
|
||||
set_svc, ctype_func(be_BLE_set_service)
|
||||
run, ctype_func(be_BLE_run)
|
||||
|
@ -76,6 +76,7 @@ extern "C" {
|
||||
** BLE - generic BLE functions
|
||||
********************************************************************/
|
||||
extern bool MI32checkBLEinitialization();
|
||||
extern void MI32BerryLoop();
|
||||
extern void MI32setBerryAdvCB(void* function, uint8_t *buffer);
|
||||
extern void MI32setBerryConnCB(void* function, uint8_t *buffer);
|
||||
extern void MI32setBerryServerCB(void* function, uint8_t *buffer);
|
||||
@ -95,6 +96,10 @@ extern "C" {
|
||||
be_return_nil(vm);
|
||||
}
|
||||
|
||||
void be_BLE_loop(void){
|
||||
MI32BerryLoop();
|
||||
}
|
||||
|
||||
void be_BLE_reg_conn_cb(void* function, uint8_t *buffer);
|
||||
void be_BLE_reg_conn_cb(void* function, uint8_t *buffer){
|
||||
MI32setBerryConnCB(function,buffer);
|
||||
|
@ -707,6 +707,10 @@ extern "C" {
|
||||
return (MI32.mode.init && Settings->flag5.mi32_enable);
|
||||
}
|
||||
|
||||
void MI32BerryLoop(){
|
||||
MI32BLELoop();
|
||||
}
|
||||
|
||||
bool MI32runBerryServer(uint16_t operation, bool response){
|
||||
MI32.conCtx->operation = operation;
|
||||
MI32.conCtx->response = response;
|
||||
@ -1861,15 +1865,10 @@ void MI32ParseResponse(char *buf, uint16_t bufsize, uint8_t addr[6], int RSSI) {
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Launch functions from Core 1 to make race conditions less likely
|
||||
*
|
||||
*/
|
||||
|
||||
void MI32Every50mSecond(){
|
||||
if(MI32.mode.shallTriggerTele){
|
||||
MI32.mode.shallTriggerTele = 0;
|
||||
MI32triggerTele();
|
||||
}
|
||||
* Called automatically every 50 milliseconds or can be triggered from Berry with BLE.loop() - useful from fast_loop
|
||||
*/
|
||||
void MI32BLELoop()
|
||||
{
|
||||
if(MI32.mode.triggerBerryAdvCB == 1){
|
||||
if(MI32.beAdvCB != nullptr){
|
||||
// AddLogBuffer(LOG_LEVEL_DEBUG,MI32.beAdvBuf,40);
|
||||
@ -1945,14 +1944,25 @@ void MI32Every50mSecond(){
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if(MI32.infoMsg > 0){
|
||||
char _message[32];
|
||||
GetTextIndexed(_message, sizeof(_message), MI32.infoMsg-1, kMI32_BLEInfoMsg);
|
||||
AddLog(LOG_LEVEL_DEBUG,PSTR("M32: %s"),_message);
|
||||
MI32.infoMsg = 0;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Launch functions from Core 1 to make race conditions less likely
|
||||
*
|
||||
*/
|
||||
|
||||
void MI32Every50mSecond(){
|
||||
if(MI32.mode.shallTriggerTele){
|
||||
MI32.mode.shallTriggerTele = 0;
|
||||
MI32triggerTele();
|
||||
}
|
||||
MI32BLELoop();
|
||||
}
|
||||
|
||||
/**
|
||||
|
Loading…
x
Reference in New Issue
Block a user