Commit e23f8bf0 by kollo

implemented bluetooth support

added check for bloetooth library
added skeleton for bluetooth functions
implemented FSFIRST/FSNEXT for bluetooth
implemented bluetooth OPEN/CLOSE/SEND/RECEIVE/ACCEPT
improved documentation of new features
parent 66f35740
......@@ -493,19 +493,25 @@ DESCRIPTION:
Initiate a connection on a socket.
The file number #n must refer to a socket. If the socket is of type "U"
The file number #n must refer to a socket, which must have been created by
OPEN. If the socket is of type "U" or "V"
then the server$ address is the address to which packets are sent by
default, and the only address from which packets are received. If the
socket is of type "S","A","C", this call attempts to make a connection
to another socket. The other socket is specified by server$, which is
an address in the communications space of the socket.
socket is of type "S","A","C","B" or "Z", this call attempts to make a
connection to another socket. The other socket is specified by server$,
which is an address in the communications space of the socket
(usually an IP address or a Bluetooth device address).
Generally, connection-based protocol sockets may successfully connect
only once; connectionless protocol sockets may use connect multiple
times to change their association.
SEE ALSO: OPEN, CLOSE, SEND, RECEIVE
COMMENT:
This function does work with internet connections, however it is not fully
documented and the implementation for Bluetooth and USB devices is not
yet finished. Please refer to the example programs.
SEE ALSO: OPEN, CLOSE, SEND, RECEIVE
#############################################################################
Command: CONTINUE
......
......@@ -345,6 +345,7 @@ EXAMPLE:
ELSE
PRINT "I am parent. My child is PID=";a
ENDIF
SEE ALSO: SPAWN
##############################################################################
......@@ -510,15 +511,24 @@ DESCRIPTION:
pattern$ can be a file name mask; default is "*".
attr$ can be "d" for only list directories,
"a" also list hidden files,
"f" list regular files.
The attributes can be combined. default is "df". If found, the
filename and attributes are returned in a$. When path$ is empty, an
empty string is returned. Otherwise the returned string consists of
two words. E.g. "- filename.dat". The first word lists the
"f" list regular files,
"u" list usb devices,
"b" list visible bluetooth devices nearby.
The attributes "d" and "f" can be combined ("df") so directories
as well as normal files are listed. If no attributes are give,
the default is "df".
If found, the filename and attributes are returned in a$.
If no file can be found, an empty string is returned.
When path$ is empty, an empty string is returned.
Otherwise the returned string consists of two words.
E.g. "- filename.dat". The first word lists the
attributes, the second word is the filename. Attributes can be "d" is
a directory, "s" symbolic link, "-" a regular file.
EXAMPLE:
' list files and directories in /tmp/
a$=FSFIRST$("/tmp","*.dat")
WHILE LEN(a$)
PRINT WORD$(a$,2)
......@@ -528,6 +538,40 @@ EXAMPLE:
a$=FSNEXT$()
WEND
COMMENT:
FSFIRST$() can also be used to scan for BLUETOOTH or USB devices.
When scanning USB or Bluetooth devices additional information is returned.
The attributes "u" and "b" cannot be combined with other attributes.
EXAMPLE:
' Scan for USB devies around:
a$=FSFIRST$("","*","u")
WHILE LEN(a$)
PRINT a$
@decode(a$)
a$=FSNEXT$()
WEND
QUIT
PROCEDURE decode(a$)
PRINT " USB bus/device: ";WORD$(a$,1)
PRINT " USB vendor-ID/product-ID: ";WORD$(a$,2)
PRINT " Manufacturer: ";WORD$(a$,3)
PRINT " Product: ";WORD$(a$,4)
PRINT " Serial-Nr: ";WORD$(a$,5)
PRINT " Number of configurations: ";WORD$(a$,6)
RETURN
EXAMPLE:
' Scan for bluetooth devies around:
a$=FSFIRST$("","*","b")
WHILE LEN(a$)
PRINT a$
PRINT "Adress: ";WORD$(a$,1)
PRINT "Name: ";WORD$(a$,1)
a$=FSNEXT$()
WEND
SEE ALSO: FSNEXT$()
##############################################################################
......
......@@ -310,6 +310,8 @@ COMMENTS:
l%=IOCTL(#1,16,VARPTR(t$))
error$=LEFT$(t$,l%)
COMMENT:
The interface to Bluetooth devices is not yet defined.
SEE ALSO: OPEN, CLOSE
EXAMPLE:
......@@ -317,7 +319,7 @@ EXAMPLE:
frequency=300
tone=1190000/frequency
KIOCSOUND=19247
PRINT ioctl(#1,KIOCSOUND,tone) ! Sounds the speaker
PRINT IOCTL(#1,KIOCSOUND,tone) ! Sounds the speaker
CLOSE #1
Result: 0
......
......@@ -194,8 +194,8 @@ mode$ is a character string which indicates the way the file should be
The second character specifies the type of file which should be opened
or created:
"" default opens regular file
"U" opens a datagram socket connection
"C" opens a stream socket as client with connection
"U" opens a datagram socket connection (UDP)
"C" opens a stream socket as client with connection (TCP)
"S" opens a stream socket as server
"A" Socket accept connection
"X" extra settings for a special device following:
......@@ -203,9 +203,19 @@ mode$ is a character string which indicates the way the file should be
"UX:baud,parity,bits,stopbits,flow"
"Y" opens an USB connection. The filename specifies the vendor-ID and
product-ID of the device to be opened.
"B" opens a BLUETOOTH stream socket as client with connection (RFCOMM)
"L" opens a BLUETOOTH datagram socket as client with connection (L2CAP)
"V" opens a BLUETOOTH datagram socket as server (L2CAP)
"Z" opens a BLUETOOTH a stream socket as server (RFCOMM)
<port-nr> The portnr is used only by the OPEN "UC" and OPEN "UU" statement.
It specifies the TCP/IP Port of connection (FTP, WWW, TELNET, MAIL etc.).
<port-nr> The portnr is used by the OPEN "UC" and OPEN "UU" statement to
specify the TCP/IP Port of connection (FTP, WWW, TELNET, MAIL etc.) and also
by the "UB","UL","UV" and "UZ" connection types.
COMMENTS:
Special settings of USB and BLUETOOTH devices can be acces by IOCTL().
They are not fully documented by now, and also the implementation is not
yet fixed. Please refer to the example programs.
EXAMPLES:
......@@ -220,7 +230,7 @@ EXAMPLES:
for read and write.
SEE ALSO: CLOSE, EXIST(), INPUT, LINEINPUT, PRINT, SEEK, LOF(), EOF(),
LOC(), BLOAD, LINK, FREEFILE(), CONNECT, IOCTL()
LOC(), BLOAD, LINK, FREEFILE(), CONNECT, IOCTL(), SEND, RECEIVE
##############################################################################
Command: OPENW
......
......@@ -159,7 +159,7 @@ DESCRIPTION:
RECEIVE is used to receive messages t$ from a socket or USB-device
#n, which has been opened with OPEN before. If a is given, this
variable will take the host address of the sender (IPv4 32 bit
format).
format) or the bluetooth device ID.
SEE ALSO: OPEN, SEND
......
......@@ -223,18 +223,20 @@ Syntax: SEND #n,msg$[,adr%,port%]
DESCRIPTION:
SEND is used to transmit a message via fast UDP datagrams to another
SEND is used to transmit a message via fast UDP datagrams to another
socket which may be on another host. Or, send is used to send a data
packet to a previously opened USB device. Send with only two
parameters may be used only when the socket is in a connected state
(see CONNECT), otherwise the destination address and the port has to
be specified.
packet to a previously opened USB device. Or, send is used to transmit
a data packet to to a previously opened BLUETOOTH L2CAP connection.
Send with only two parameters may be used only when the socket is in a
connected state (see CONNECT), otherwise the destination address and the
port has to be specified.
The address of the target is given by adr%, which usually contains a
IP4 address (e.g. cvl(chr$(127)+chr$(0)+chr$(0)+chr$(1)) which
corresponds to 127.0.0.1). msg$ can be an arbitrary message with any
data in it. The length of the message must not exceed 1500 Bytes. If
the message is too long to pass atomically through the underlying
data in it. The length of the message must not exceed 1500 Bytes. If
the message is too long to pass automically through the underlying
protocol, an error occurs, and the message is not transmitted.
No indication of failure to deliver is implicit in a send.
......@@ -243,6 +245,10 @@ DESCRIPTION:
blocks. The OUT?() function may be used to determine when it is
possible to send more data.
COMMENT:
SEND is currently working for USB and Bluetooth devices only in
connected state.
EXAMPLE:
port=5555
......@@ -356,17 +362,30 @@ DESCRIPTION:
Loads and sets a font for graphical text commands.
t$ may be
"SMALL" or "5x7" for a small font
"MEDIUM or "8x8 for a medium sized font
"BIG" or "8x16" for a big font.
"LARGE" or "16x32" for an even bigger font.
"HUGE" or "24x48" for an even bigger font.
"SMALL" or "5x7" for a small font,
"MEDIUM or "8x8 for a medium sized font,
"BIG" or "8x16" for a big font,
"LARGE" or "16x32" for an even bigger font,
"HUGE" or "24x48" for an even bigger font,
"GIANT" or "32x64" for a gigantic font size.
This setting affects the text style and size of the commands TEXT
and GPRINT.
With UNIX and the X-WINDOW system, the font name may be any valid
With UNIX and the X-WINDOW system, the font name t$ may be any valid
font name or pattern. On other platforms true-type font filenames can
be used. This way, also proportional fonts can be used.
COMMENT:
The support for true-type .TTF fonts is not usable at the moment. You
should prefer the standard names given obove instead of platform dependant
names to stay platform independant.
Currently the font setting is overwritten by ALERT, FILESELCT and others
every time they are used. It is planned to have this independant and also
have a way to independantly change the font sizes and style of the GUI
functions, but this is work in progress.
EXAMPLE:
SETFONT "BIG"
TEXT 100,100,"Hi, this is a big font"
......
......@@ -28,6 +28,25 @@ ISDIR(d$) --> STAT ? --> geht mit user-funktion...
* Event, wenn sound zuende (oder testfunktionen)
* Einzelne Toene auf Kanal spielen (ok)
---- bluetooth ----
FSFIRST$() and FSNEXT$() can be used to scan for bluetooth devices.
with OPEN "UB" you can open a RFCOMM connection
with OPEN "UP" cou can open a L2CAP connection.
you can use SEND/RECEIVE/CLOSE on L2CAP connections.
you can use PRINT/INPUT/OUT/INP()/CLOSE on RFCOMM connections.
you can as well setup a server and open a listening socket with OPEN,
much the same as you would do it with normal internet connections.
---- USB support ----
FSFIRST$() and FSNEXT$() can be used to scan for USB devices.
-------encryption---------------
......
' Test of the bluetooth functions of X11-Basic Version >= 1.25
'
'
' Scan for bluetooth devies around:
'
'
PRINT "Following devices could be found nearby:"
a$=FSFIRST$("","*","b")
while len(a$)
print a$
PRINT "Adress: ";WORD$(a$,1)
PRINT "Name: ";WORD$(a$,2)
adr$=word$(a$,1)
a$=FSNEXT$()
wend
PRINT "Now try to connect to ";adr$
OPEN "UL",#1,adr$,1
print #1,"Test"
CLOSE
quit
......@@ -260,6 +260,10 @@
/* Define to 1 if you have the <usb.h> header file. */
#undef HAVE_USB
/* Define to 1 if you have the <usb.h> header file. */
#undef HAVE_BLUETOOTH
/* Define to 1 if you have the <gcrypt.h> header file. */
#undef HAVE_GCRYPT
......
......@@ -5525,6 +5525,53 @@ fi
#AC_DEFINE(HAVE_LIBUSB,1,[libusb_control_transfer in lusb-1.0])
#],,[$libs])
# `-lbluetooth':
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for hci_get_route in -lbluetooth" >&5
$as_echo_n "checking for hci_get_route in -lbluetooth... " >&6; }
if ${ac_cv_lib_bluetooth_hci_get_route+:} false; then :
$as_echo_n "(cached) " >&6
else
ac_check_lib_save_LIBS=$LIBS
LIBS="-lbluetooth $libs $LIBS"
cat confdefs.h - <<_ACEOF >conftest.$ac_ext
/* end confdefs.h. */
/* Override any GCC internal prototype to avoid an error.
Use char because int might match the return type of a GCC
builtin and then its argument prototype would still apply. */
#ifdef __cplusplus
extern "C"
#endif
char hci_get_route ();
int
main ()
{
return hci_get_route ();
;
return 0;
}
_ACEOF
if ac_fn_c_try_link "$LINENO"; then :
ac_cv_lib_bluetooth_hci_get_route=yes
else
ac_cv_lib_bluetooth_hci_get_route=no
fi
rm -f core conftest.err conftest.$ac_objext \
conftest$ac_exeext conftest.$ac_ext
LIBS=$ac_check_lib_save_LIBS
fi
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_bluetooth_hci_get_route" >&5
$as_echo "$ac_cv_lib_bluetooth_hci_get_route" >&6; }
if test "x$ac_cv_lib_bluetooth_hci_get_route" = xyes; then :
libs="$libs -lbluetooth"
$as_echo "#define HAVE_BLUETOOTH 1" >>confdefs.h
fi
# `-lgcrypt':
#AC_CHECK_LIB([gcrypt], [gcry_check_version], [
#libs="$libs -lgcrypt"
......
......@@ -189,6 +189,12 @@ AC_DEFINE(HAVE_USB,1,[usb_open in lusb])
#AC_DEFINE(HAVE_LIBUSB,1,[libusb_control_transfer in lusb-1.0])
#],,[$libs])
# `-lbluetooth':
AC_CHECK_LIB([bluetooth], [hci_get_route], [
libs="$libs -lbluetooth"
AC_DEFINE(HAVE_BLUETOOTH,1,[hci_get_route in lbluetooth])
],,[$libs])
# `-lgcrypt':
#AC_CHECK_LIB([gcrypt], [gcry_check_version], [
#libs="$libs -lgcrypt"
......
......@@ -31,6 +31,8 @@
#define FT_SOCKET 4
#define FT_USB 5
#define FT_PIPE 6
#define FT_BTRC 7
#define FT_BTL2 8
typedef struct {
int typ;
......
......@@ -1522,6 +1522,8 @@ void c_dump(PARAMETER *plist,int e) {
else if(filenr[i].typ==FT_USB) fprintf(fff.dptr,"#%d: %s [%s]\n",i,"","USB CONNECTION");
else if(filenr[i].typ==FT_SOCKET) fprintf(fff.dptr,"#%d: %s [%s]\n",i,"","SOCKET");
else if(filenr[i].typ==FT_PIPE) fprintf(fff.dptr,"#%d: %s [%s]\n",i,"","PIPE");
else if(filenr[i].typ==FT_BTRC) fprintf(fff.dptr,"#%d: %s [%s]\n",i,"","BLUETOOTH RFCOMM");
else if(filenr[i].typ==FT_BTL2) fprintf(fff.dptr,"#%d: %s [%s]\n",i,"","BLUETOOTH L2CAP");
else if(filenr[i].typ) fprintf(fff.dptr,"#%d: %s [%s]\n",i,"","other");
}
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment