summaryrefslogtreecommitdiffstats
path: root/src/host/layer23/include/osmocom/bb
diff options
context:
space:
mode:
authorAndreas Eversberg <jolly@eversberg.eu>2011-12-01 12:06:51 +0100
committerAndreas Eversberg <jolly@eversberg.eu>2016-09-25 08:11:47 +0200
commit958292f3a4024c54115035cb3379e301168fbfde (patch)
tree7f8225d258ae7ec27d145ec05a8a6e01c51a19d6 /src/host/layer23/include/osmocom/bb
parenta5a5cd1eff13e8079c6f0058d5e5d94e8dd99ba5 (diff)
layer23/mobile: Added generic user interface
The user interface instance is currently accessed via telnet. It supports different views to display or enter something. It is still not complete.
Diffstat (limited to 'src/host/layer23/include/osmocom/bb')
-rw-r--r--src/host/layer23/include/osmocom/bb/Makefile.am2
-rw-r--r--src/host/layer23/include/osmocom/bb/ui/Makefile.am2
-rw-r--r--src/host/layer23/include/osmocom/bb/ui/telnet_interface.h17
-rw-r--r--src/host/layer23/include/osmocom/bb/ui/ui.h96
4 files changed, 116 insertions, 1 deletions
diff --git a/src/host/layer23/include/osmocom/bb/Makefile.am b/src/host/layer23/include/osmocom/bb/Makefile.am
index 58a5f7fb..a8791fe4 100644
--- a/src/host/layer23/include/osmocom/bb/Makefile.am
+++ b/src/host/layer23/include/osmocom/bb/Makefile.am
@@ -1 +1 @@
-SUBDIRS = common misc mobile
+SUBDIRS = common misc ui mobile
diff --git a/src/host/layer23/include/osmocom/bb/ui/Makefile.am b/src/host/layer23/include/osmocom/bb/ui/Makefile.am
new file mode 100644
index 00000000..b010e53c
--- /dev/null
+++ b/src/host/layer23/include/osmocom/bb/ui/Makefile.am
@@ -0,0 +1,2 @@
+noinst_HEADERS = ui.h telnet_interface.h
+
diff --git a/src/host/layer23/include/osmocom/bb/ui/telnet_interface.h b/src/host/layer23/include/osmocom/bb/ui/telnet_interface.h
new file mode 100644
index 00000000..b35b47f9
--- /dev/null
+++ b/src/host/layer23/include/osmocom/bb/ui/telnet_interface.h
@@ -0,0 +1,17 @@
+#ifndef _LIBUI_TELNET_IF_H
+#define _LIBUI_TELNET_IF_H
+
+struct ui_telnet_connection {
+ struct llist_head entry;
+ void *priv;
+ struct osmo_fd fd;
+ struct ui_inst *ui;
+ struct buffer *obuf;
+ int iac, sb, esc;
+};
+
+int ui_telnet_init(struct ui_inst *ui, void *tall_ctx, int port);
+int ui_telnet_puts(struct ui_inst *ui, const char *text);
+void ui_telnet_exit(struct ui_inst *ui);
+
+#endif /* _LIBUI_TELNET_IF_H */
diff --git a/src/host/layer23/include/osmocom/bb/ui/ui.h b/src/host/layer23/include/osmocom/bb/ui/ui.h
new file mode 100644
index 00000000..75e2fad7
--- /dev/null
+++ b/src/host/layer23/include/osmocom/bb/ui/ui.h
@@ -0,0 +1,96 @@
+#ifndef _libui_h
+#define _libui_h
+
+#define UI_ROWS 8
+#define UI_COLS 12
+#define UI_TARGET 0
+
+enum ui_key {
+ UI_KEY_0 = '0',
+ UI_KEY_1 = '1',
+ UI_KEY_2 = '2',
+ UI_KEY_3 = '3',
+ UI_KEY_4 = '4',
+ UI_KEY_5 = '5',
+ UI_KEY_6 = '6',
+ UI_KEY_7 = '7',
+ UI_KEY_8 = '8',
+ UI_KEY_9 = '9',
+ UI_KEY_STAR = '*',
+ UI_KEY_HASH = '#',
+ UI_KEY_F1 = 1,
+ UI_KEY_F2 = 2,
+ UI_KEY_PICKUP = 26,
+ UI_KEY_HANGUP = 27,
+ UI_KEY_UP = 28,
+ UI_KEY_DOWN = 29,
+ UI_KEY_LEFT = 30,
+ UI_KEY_RIGHT = 31,
+};
+
+union ui_view_data {
+ struct {
+ int lines;
+ const char **text;
+ int vpos;
+ } listview;
+ struct {
+ int lines;
+ const char **text;
+ int vpos;
+ int cursor;
+ } selectview;
+ struct {
+ char *number;
+ int num_len;
+ int pos;
+ int options;
+ int options_pos;
+ } stringview;
+ struct {
+ unsigned int value;
+ int sign;
+ int min, max;
+ } intview;
+};
+
+struct ui_inst;
+
+struct ui_view {
+ const char *name;
+ int (*init)(struct ui_view *uv, union ui_view_data *ud);
+ int (*keypad)(struct ui_inst *ui, struct ui_view *uv,
+ union ui_view_data *ud, enum ui_key kp);
+ int (*display)(struct ui_inst *ui, union ui_view_data *ud);
+};
+
+struct ui_inst {
+ struct ui_view *uv;
+ const char *title;
+ const char *bottom_line;
+ union ui_view_data ud;
+ int (*key_cb)(struct ui_inst *ui, enum ui_key kp);
+ int (*beep_cb)(struct ui_inst *ui);
+ /* display */
+ char buffer[(UI_COLS + 1) * UI_ROWS];
+ int cursor_on, cursor_x, cursor_y;
+ /* telnet */
+ void *tall_telnet_ctx;
+ struct osmo_fd server_socket;
+ struct llist_head active_connections;
+ int (*telnet_cb)(struct ui_inst *ui);
+};
+
+extern struct ui_view ui_listview;
+extern struct ui_view ui_selectview;
+extern struct ui_view ui_stringview;
+extern struct ui_view ui_intview;
+
+int ui_inst_init(struct ui_inst *ui, struct ui_view *uv,
+ int (*key_cb)(struct ui_inst *ui, enum ui_key kp),
+ int (*beep_cb)(struct ui_inst *ui),
+ int (*telnet_cb)(struct ui_inst *ui));
+int ui_inst_keypad(struct ui_inst *ui, enum ui_key kp);
+int ui_inst_refresh(struct ui_inst *ui);
+
+#endif /* _libui_h */