! test avec appli MikroC Mc$="18F2550_Startup_USB_test_BlueTooh_LCD_160117" ! carte StartUsb 18F2550 + LCD 4x20 I2C + HC06 B.T. Prog$="Bluetooth_simplex_141102.bas" print "Application RFO-Basic" rev$=" 18 Janv 2016" print Prog$," rev ";Rev$ print "Version basic : "; Version$() print "Appli.MikroC MCU :" print Mc$ Device DV$ print "Device Info : "; DV$ PRINT "Rev 02 nov 2014" pause 3000 BT.OPEN new_connection: xdomenu =0 BT.CONNECT ! Read status until ! a connection is made ln = 0 DO BT.STATUS s IF s = 1 ln = ln + 1 PRINT "Listening", ln ELSEIF s =2 PRINT "Connecting" ENDIF PAUSE 1000 UNTIL s = 3 ! When a connection is made ! get the name of the connected ! device BT.DEVICE.NAME device$ print "Connected to ";device$;chr$(13) print "Ready to receive command, touch the screen " print chr$(13) ! *** Read/Write Loop **** RW_Loop: DO ! If the screen is touched, the interrupt ! code will change xdoMemu to 1 (true) ! and call xdosend BT.STATUS s IF s<> 3 PRINT "Connection lost" GOTO new_connection ENDIF ! Read messages until ! the message queue is ! empty rmsg$="" a1$="" DO BT.READ.READY rr IF rr dr=1 pause 100 bt.read.bytes A1$ rmsg$=rmsg$+a1$ end if until rr=0 if dr=1 then PRINT left$(device$,4);": ";rmsg$ rmsg$="" a1$="" dr=0 ENDIF UNTIL 0 ! Get and send message ! to the connected device xdoSend: INPUT "Text to send", wmsg$ PRINT "Me: "; wmsg$ BT.WRITE wmsg$;chr$(13); xdomenu=0 RETURN ! When Console is touched ! set xdoMenu to true onConsoleTouch: xdoMenu=1 gosub xdosend ConsoleTouch.Resume onError: BT.CLOSE END