mirror of
https://github.com/trezor/trezor-firmware.git
synced 2024-11-26 17:38:39 +00:00
88 lines
2.5 KiB
C
88 lines
2.5 KiB
C
/*
|
|
* Copyright (c) Pavol Rusnak, SatoshiLabs
|
|
*
|
|
* Licensed under Microsoft Reference Source License (Ms-RSL)
|
|
* see LICENSE.md file for details
|
|
*/
|
|
|
|
#include <stdio.h>
|
|
#include <string.h>
|
|
#include <stdint.h>
|
|
|
|
#include "py/nlr.h"
|
|
#include "py/runtime.h"
|
|
#include "py/binary.h"
|
|
|
|
#if MICROPY_PY_TREZORMSG
|
|
|
|
// io callbacks
|
|
|
|
mp_obj_t msg_receive_callback = mp_const_none;
|
|
|
|
/*
|
|
static void msg_receive(mp_obj_t message) {
|
|
if (touch_start_callback != mp_const_none) {
|
|
mp_call_function_1(msg_receive_callback, message);
|
|
}
|
|
}
|
|
*/
|
|
|
|
// class Msg(object):
|
|
typedef struct _mp_obj_Msg_t {
|
|
mp_obj_base_t base;
|
|
} mp_obj_Msg_t;
|
|
|
|
// def Msg.__init__(self)
|
|
STATIC mp_obj_t mod_TrezorMsg_Msg_make_new(const mp_obj_type_t *type, size_t n_args, size_t n_kw, const mp_obj_t *args) {
|
|
mp_arg_check_num(n_args, n_kw, 0, 0, false);
|
|
mp_obj_Msg_t *o = m_new_obj(mp_obj_Msg_t);
|
|
o->base.type = type;
|
|
return MP_OBJ_FROM_PTR(o);
|
|
}
|
|
|
|
// def Msg.receive(self, callback) -> None
|
|
STATIC mp_obj_t mod_TrezorMsg_Msg_receive(mp_obj_t self, mp_obj_t callback) {
|
|
msg_receive_callback = callback;
|
|
return mp_const_none;
|
|
}
|
|
STATIC MP_DEFINE_CONST_FUN_OBJ_2(mod_TrezorMsg_Msg_receive_obj, mod_TrezorMsg_Msg_receive);
|
|
|
|
// def Msg.send(self, message) -> None
|
|
STATIC mp_obj_t mod_TrezorMsg_Msg_send(mp_obj_t self, mp_obj_t message) {
|
|
// TODO
|
|
return mp_const_none;
|
|
}
|
|
STATIC MP_DEFINE_CONST_FUN_OBJ_2(mod_TrezorMsg_Msg_send_obj, mod_TrezorMsg_Msg_send);
|
|
|
|
// Msg stuff
|
|
|
|
STATIC const mp_rom_map_elem_t mod_TrezorMsg_Msg_locals_dict_table[] = {
|
|
{ MP_ROM_QSTR(MP_QSTR_receive), MP_ROM_PTR(&mod_TrezorMsg_Msg_receive_obj) },
|
|
{ MP_ROM_QSTR(MP_QSTR_send), MP_ROM_PTR(&mod_TrezorMsg_Msg_send_obj) },
|
|
};
|
|
STATIC MP_DEFINE_CONST_DICT(mod_TrezorMsg_Msg_locals_dict, mod_TrezorMsg_Msg_locals_dict_table);
|
|
|
|
STATIC const mp_obj_type_t mod_TrezorMsg_Msg_type = {
|
|
{ &mp_type_type },
|
|
.name = MP_QSTR_Msg,
|
|
.make_new = mod_TrezorMsg_Msg_make_new,
|
|
.locals_dict = (void*)&mod_TrezorMsg_Msg_locals_dict,
|
|
};
|
|
|
|
// module stuff
|
|
|
|
STATIC const mp_rom_map_elem_t mp_module_TrezorMsg_globals_table[] = {
|
|
{ MP_ROM_QSTR(MP_QSTR___name__), MP_ROM_QSTR(MP_QSTR_TrezorMsg) },
|
|
{ MP_ROM_QSTR(MP_QSTR_Msg), MP_ROM_PTR(&mod_TrezorMsg_Msg_type) },
|
|
};
|
|
|
|
STATIC MP_DEFINE_CONST_DICT(mp_module_TrezorMsg_globals, mp_module_TrezorMsg_globals_table);
|
|
|
|
const mp_obj_module_t mp_module_TrezorMsg = {
|
|
.base = { &mp_type_module },
|
|
.name = MP_QSTR_TrezorMsg,
|
|
.globals = (mp_obj_dict_t*)&mp_module_TrezorMsg_globals,
|
|
};
|
|
|
|
#endif // MICROPY_PY_TREZORMSG
|