mirror of
https://github.com/Next-Flip/Momentum-Firmware.git
synced 2026-04-24 03:29:57 -07:00
we <3 kostily and velosipedy
reserve more or less ram based on open rpc sessions not at all precise, but roughly leaves enough at all times eg. fill, connect app, fill again, screenshare, can still send
This commit is contained in:
@@ -1,10 +1,11 @@
|
||||
#include "subghz_history.h"
|
||||
#include <lib/subghz/receiver.h>
|
||||
#include <rpc/rpc.h>
|
||||
|
||||
#include <furi.h>
|
||||
|
||||
#define SUBGHZ_HISTORY_MAX 65535 // uint16_t index max, ram limit below
|
||||
#define SUBGHZ_HISTORY_FREE_HEAP 20480
|
||||
#define SUBGHZ_HISTORY_FREE_HEAP (10240 * (3 - MIN(rpc_get_sessions_count(instance->rpc), 2U)))
|
||||
#define TAG "SubGhzHistory"
|
||||
|
||||
typedef struct {
|
||||
@@ -33,6 +34,7 @@ struct SubGhzHistory {
|
||||
uint32_t code_last_hash_data;
|
||||
FuriString* tmp_string;
|
||||
SubGhzHistoryStruct* history;
|
||||
Rpc* rpc;
|
||||
};
|
||||
|
||||
SubGhzHistory* subghz_history_alloc(void) {
|
||||
@@ -40,6 +42,7 @@ SubGhzHistory* subghz_history_alloc(void) {
|
||||
instance->tmp_string = furi_string_alloc();
|
||||
instance->history = malloc(sizeof(SubGhzHistoryStruct));
|
||||
SubGhzHistoryItemArray_init(instance->history->data);
|
||||
instance->rpc = furi_record_open(RECORD_RPC);
|
||||
return instance;
|
||||
}
|
||||
|
||||
@@ -56,6 +59,7 @@ void subghz_history_free(SubGhzHistory* instance) {
|
||||
}
|
||||
SubGhzHistoryItemArray_clear(instance->history->data);
|
||||
free(instance->history);
|
||||
furi_record_close(RECORD_RPC);
|
||||
free(instance);
|
||||
}
|
||||
|
||||
|
||||
@@ -89,6 +89,7 @@ struct RpcSession {
|
||||
|
||||
struct Rpc {
|
||||
FuriMutex* busy_mutex;
|
||||
size_t sessions_count;
|
||||
};
|
||||
|
||||
RpcOwner rpc_session_get_owner(RpcSession* session) {
|
||||
@@ -412,6 +413,8 @@ RpcSession* rpc_session_open(Rpc* rpc, RpcOwner owner) {
|
||||
|
||||
furi_thread_start(session->thread);
|
||||
|
||||
rpc->sessions_count++;
|
||||
|
||||
return session;
|
||||
}
|
||||
|
||||
@@ -419,6 +422,8 @@ void rpc_session_close(RpcSession* session) {
|
||||
furi_assert(session);
|
||||
furi_assert(session->rpc);
|
||||
|
||||
session->rpc->sessions_count--;
|
||||
|
||||
rpc_session_set_send_bytes_callback(session, NULL);
|
||||
rpc_session_set_close_callback(session, NULL);
|
||||
rpc_session_set_buffer_is_empty_callback(session, NULL);
|
||||
@@ -494,3 +499,7 @@ void rpc_send_and_release_empty(RpcSession* session, uint32_t command_id, PB_Com
|
||||
rpc_send_and_release(session, &message);
|
||||
pb_release(&PB_Main_msg, &message);
|
||||
}
|
||||
|
||||
size_t rpc_get_sessions_count(Rpc* rpc) {
|
||||
return rpc->sessions_count;
|
||||
}
|
||||
|
||||
@@ -134,6 +134,13 @@ size_t rpc_session_feed(RpcSession* session, uint8_t* buffer, size_t size, uint3
|
||||
*/
|
||||
size_t rpc_session_get_available_size(RpcSession* session);
|
||||
|
||||
/** Get number of open RPC sessions
|
||||
*
|
||||
* @param rpc instance
|
||||
* @return sessions count
|
||||
*/
|
||||
size_t rpc_get_sessions_count(Rpc* rpc);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
@@ -2772,6 +2772,7 @@ Function,-,rintl,long double,long double
|
||||
Function,-,round,double,double
|
||||
Function,+,roundf,float,float
|
||||
Function,-,roundl,long double,long double
|
||||
Function,+,rpc_get_sessions_count,size_t,Rpc*
|
||||
Function,+,rpc_session_close,void,RpcSession*
|
||||
Function,+,rpc_session_feed,size_t,"RpcSession*, uint8_t*, size_t, uint32_t"
|
||||
Function,+,rpc_session_get_available_size,size_t,RpcSession*
|
||||
|
||||
|
Reference in New Issue
Block a user