1#include "main-header.h"
6void (*usb_receive_hook)(uint8_t *received,
int size);
7void (*esp32_receive_hook)(uint8_t received);
9 usb_receive_hook = NULL;
10 esp32_receive_hook = NULL;
13int is_hijacked_usb_acm() {
14 return usb_receive_hook != NULL;
17int is_hijacked_esp32() {
18 return esp32_receive_hook != NULL;
20void unhijack_esp32() {
21 if (esp32_receive_hook != NULL) {
22 printf(
"ESP32 Usart control regained userapp\r\n");
24 esp32_receive_hook = NULL;
26void unhijack_usb_acm() {
27 if (usb_receive_hook != NULL) {
28 printf(
"USB ACM control regained from userapp\r\n");
30 usb_receive_hook = NULL;
37int hijack_esp32_usart(
void ( *receive_hook )(uint8_t received)) {
38 if (receive_hook == NULL) {
39 printf(
"ESP32 not hijacked, hook is null\r\n");
42 printf(
"ESP32 control transferred to userapp\r\n");
43 esp32_receive_hook = receive_hook;
47int hijack_usb_acm(
void ( *receive_hook )(uint8_t *received,
int size)) {
48 printf(
"USB ACM control transferred to userapp\r\n");
49 usb_receive_hook = receive_hook;
53int send_via_usb_acm(uint8_t *buf,
int size) {
54 mculib_usb_send(MAIN_MCULIBHANDLE, size, buf);
58int hijack_receive_on_usb_acm(uint8_t *buf,
int size) {
59 void (*h)(uint8_t *received,
int size) = usb_receive_hook;
66int hijack_receive_esp32(uint8_t received) {
67 void (*h)(uint8_t received) = esp32_receive_hook;