To keep things simple and easy I have used RFO-BASIC and BASIC! compiler to create the APK (If your using Android 10 and want to create an APK then use the HBASIC fork of RFO-BASIC to overcome the android file access permission changes.
Tools for BASIC! - rfobasic (tapatalk.com)
the source for BTClipSync.bas is below
BT.OPEN
ARRAY.LOAD type$[], "Send Sync data", "Receive Sync data", "Quit"
title$ = "Bluetooth ClipSync v0.1"
new_connection:
xdomenu =0
SELECT type, type$[], title$
! If the user pressed the back
! key or selected quit then quit
! otherwise try to connect to
! a listener
PRINT "-----------------------------"
PRINT "Bluetooth Clipboard Sync"
PRINT "V0.1 Paul Bowers Nov 2023"
PRINT "-----------------------------"
IF (type = 0) | (type =3)
PRINT "Session Closed"
BT.CLOSE
PAUSE 5000
EXIT
ELSEIF type = 1
BT.CONNECT
PAUSE 1000
ENDIF
! Read status until
! a connection is made
DO
BT.STATUS s
IF s = 1
PRINT "Waiting for connection, Press back to cancel"
ELSEIF s =2
PRINT "Destination acknowledged, Connecting"
ELSEIF s = 3
PRINT "Connected"
BT.DEVICE.NAME device$
IF type =1
CLIPBOARD.GET wmsg$
PRINT "Sending ";LEN(wmsg$) ;" bytes"
BT.WRITE wmsg$
PRINT "sent data to "; device$
DO
! wait until receiver had completed unbuffering.
BT.STATUS d
PAUSE 1000
UNTIL d<>3
BT.CLOSE
EXIT
ENDIF
ENDIF
PAUSE 1000
UNTIL s = 3
DO
BT.STATUS s
IF s<> 3
PRINT "Connection lost"
GOTO new_connection
ENDIF
! Read messages until
! the message queue is
! empty
buffer$=""
CLS
DO
BT.READ.READY rr
IF rr
BT.READ.BYTES rmsg$
IF rmsg$<>""
buffer$=buffer$+rmsg$
ENDIF
ENDIF
UNTIL rr = 0
CLIPBOARD.PUT buffer$
NOTIFY "BT ClipSync Receive","Data received","and is ready for processing",0
UNTIL rr=0
BT.CLOSE
EXIT
ONERROR:
err$=GETERROR$()
DIALOG.MESSAGE err$,"",a,"Continue"
IF a=1
GOTO new_connection
ENDIF
EXIT
====================================================================
The source for IP ClipSync Receive
====================================================================
PRINT "Sailforms Point to Point Sync Server"
PRINT "Paul Bowers v0.3 November 2023"
PRINT "---------------------------------------"
PRINT
PRINT "connection will auto end on receipt of data"
PRINT "This app can run in the background and"
PRINT "issue a notification on receipt of data"
PRINT
port=1080
SOCKET.MYIP ip$
PRINT "LAN IP: " + ip$
GRABURL ip$, "
http://icanhazip.com"
PRINT "WAN IP: " + ip$
line$=""
line2$=""
SOCKET.SERVER.CREATE port
newConnection:
PRINT "Waiting for client connect"
SOCKET.SERVER.CONNECT 0
DO
SOCKET.SERVER.STATUS st
UNTIL st = 3
SOCKET.SERVER.CLIENT.IP ip$
PRINT "Connected to ";ip$
maxclock = CLOCK() + 90000
line$ = "Wait"
HOME
DO
SOCKET.SERVER.READ.READY flag
IF CLOCK() > maxclock
PRINT "Read time out"
END
ENDIF
UNTIL flag
SOCKET.SERVER.READ.LINE line$
CLIPBOARD.PUT line$
NOTIFY "ClipSync Receive","Data received","",0
SOCKET.SERVER.WRITE.LINE "ACK"
SOCKET.SERVER.DISCONNECT
PRINT "Disconnected from client"
EXIT
ONBACKGROUND:
IF BACKGROUND()=1
maxclock = CLOCK() + 90000
line$ = "Wait"
DO
SOCKET.SERVER.READ.READY flag
IF CLOCK() > maxclock
! PRINT "Read time out"
END
ENDIF
UNTIL flag
SOCKET.SERVER.READ.LINE line$
NOTIFY "ClipSync Receive","Data received","",0
CLIPBOARD.PUT line$
SOCKET.SERVER.WRITE.LINE "ACK"
ENDIF
EXIT
BACKGROUND.RESUME
ONERROR:
err$=GETERROR$()
DIALOG.MESSAGE err$,"",a,"Continue"
EXIT
========================================================
and source for IP ClipSync Send
========================================================
PRINT "--------------------------------------"
PRINT "Sailforms point to point Sync client"
PRINT "Paul Bowers v0.3 November 2023"
PRINT "--------------------------------------"
CONSOLE.TITLE "ClipSync Send"
PRINT "ClipSyncSend.txt contains config"
line$=""
main:
DO
FILE.EXISTS fn, "clipsyncsend.txt"
IF fn <>0
TEXT.OPEN R, FN2, "clipsyncsend.txt"
TEXT.READLN FN2, ip$
PRINT "connecting to ";ip$
TEXT.CLOSE FN2
ELSE
INPUT "Enter the target device IP", ip$, "192.168.0.122"
HOME
ENDIF
port=1080
print "Connecting..."
SOCKET.CLIENT.CONNECT ip$, port
DO
CLIPBOARD.GET cg$
IF cg$<> ""
SOCKET.CLIENT.WRITE.LINE cg$
CLIPBOARD.PUT ""
DO
SOCKET.CLIENT.READ.READY flag
maxclock = CLOCK() + 20000
IF CLOCK() > maxclock
NOTIFY "ClipSync send","session timeout","",0
END
ENDIF
UNTIL flag
SOCKET.CLIENT.READ.LINE line$
IF line$="ACK"
NOTIFY "ClipSync send","Data sent & acknowledged","",0
SOCKET.SERVER.DISCONNECT
EXIT
ENDIF
ENDIF
line$="OFF"
UNTIL line$="OFF"
SOCKET.SERVER.DISCONNECT
ENDIF
UNTIL line$="OFF"
EXIT
ONBACKGROUND:
IF BACKGROUND()=1
FILE.EXISTS fn, "clipsyncsend.txt"
IF fn <>0
TEXT.OPEN R, FN2, "clipsyncsend.txt"
TEXT.READLN FN2, ip$
PRINT "connecting to ";ip$
TEXT.CLOSE FN2
ELSE
INPUT "Enter the target device IP", ip$, "192.168.0.122"
HOME
ENDIF
port=1080
print "Connecting..."
SOCKET.CLIENT.CONNECT ip$, port
DO
CLIPBOARD.GET cg$
IF cg$<> ""
SOCKET.CLIENT.WRITE.LINE cg$
CLIPBOARD.PUT ""
DO
SOCKET.CLIENT.READ.READY flag
maxclock = CLOCK() + 20000
IF CLOCK() > maxclock
NOTIFY "ClipSync send","session timeout","",0
END
ENDIF
UNTIL flag
SOCKET.CLIENT.READ.LINE line$
IF line$="ACK"
NOTIFY "ClipSync send","Data sent & acknowledged","",0
SOCKET.SERVER.DISCONNECT
EXIT
ENDIF
ENDIF
line$="OFF"
UNTIL line$="OFF"
SOCKET.SERVER.DISCONNECT
ENDIF
BACKGROUND.RESUME
ONERROR:
PRINT "Waiting...."
PAUSE 3000
GOTO main
EXIT
onbackkey:
INPUT "Enter the target device IP", ip$, "192.168.0.122"
backkey.resume