From 21d277edf33df5f9546eb3137161e3f04583d126 Mon Sep 17 00:00:00 2001 From: Christophe Troestler Date: Sat, 11 Jul 2015 16:05:05 +0200 Subject: [PATCH] Add EV3.connect_bluetooth for all platforms --- src/mindstorm_EV3.ml | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/src/mindstorm_EV3.ml b/src/mindstorm_EV3.ml index b2b23ce..a335cdf 100644 --- a/src/mindstorm_EV3.ml +++ b/src/mindstorm_EV3.ml @@ -103,9 +103,26 @@ let bt_recv fd = #ifdef MACOSX (* Mac OS X *) +let connect_bluetooth tty = + let fd = Unix.openfile tty [Unix.O_RDWR] 0o660 in + { fd = fd; + send = bt_send; + recv = bt_recv; + close = Unix.close; + msg_counter = 0 } #elif defined WIN32 (* Windows *) +external socket_bluetooth : string -> Unix.file_descr + = "ocaml_mindstorm_connect" + +let connect_bluetooth addr = + let fd = socket_bluetooth ("\\\\.\\" ^ addr) in + { fd = fd; + send = bt_send; + recv = bt_recv; + close = Unix.close; + msg_counter = 0 } #else (* Unix *)