Files
utun2/tools/chatgui-android/libutun_lite/instance_lite.h
T
evgeny 5276c1288c android: real utun instance + SQLite channels + reactive logs + QR join
- instance_lite.h/c: full uTun stack from INI config text
  (keygen, uasync, UTUN_INSTANCE, SQLite, chat_core/sync, BGP, etcp_router)
- jni_bridge: nativeStart/Stop, nativeJoinChannel → chat_sync_connect_from_invite,
  nativeSubscribeLogs, C logs → logcat + Kotlin LogManager
- Kotlin: direct read-only SQLite queries (channels, messages),
  ViewModel with live event callbacks, reactive LogScreen (tail -f),
  CameraX QR scanner with proper lifecycle, JoinChannelDialog
- HeadlessService: generates INI config from Kotlin settings → C instance
2026-07-28 00:01:57 +03:00

43 lines
1.3 KiB
C

/*
* instance_lite.h — lightweight uTun instance lifecycle for Android
*
* Kotlin generates INI config text, passes to instance_lite_start().
* C side parses it, creates uasync+ETCP+bgp+chat stack, runs in a pthread.
* Mirrors UtunNode::runLoop() from tools/chatgui/transport/utun_node.cpp.
*/
#ifndef INSTANCE_LITE_H
#define INSTANCE_LITE_H
#include <stdint.h>
#ifdef __cplusplus
extern "C" {
#endif
struct UASYNC;
/* Start full uTun stack from INI config text.
* Creates a pthread for uasync event loop.
* Returns 0 on success, -1 on error.
* Config format: same as utun INI (see node_config.cpp saveFull). */
int instance_lite_start(const char* config_text);
/* Signal stop and wait for thread to exit.
* Calls chat_sync_destroy, chat_core_destroy, utun_instance_destroy, uasync_destroy. */
void instance_lite_stop(void);
/* Returns non-zero if instance is running. */
int instance_lite_is_running(void);
/* Get current uasync handle (NULL if not running). */
struct UASYNC* instance_lite_get_uasync(void);
/* Set Kotlin callback for chat events (CONNECT_RESULT, MSG_RECEIVED, ...) */
typedef void (*instance_lite_event_fn)(int type, const uint8_t* data, int len);
void instance_lite_set_event_handler(instance_lite_event_fn handler);
#ifdef __cplusplus
}
#endif
#endif /* INSTANCE_LITE_H */