REM Test Message sending to Activity Bot Ver 1 DIM Message~(16) xcenter = Graphics.Width/2 DIM quit AS Button quit = Graphics.newButton(xcenter,250) quit.setTitle("Quit") DIM send6 AS Button send6 = Graphics.newButton(xcenter,200,100) send6.setTitle("Send 6 bytes") REM Direct connection ip address Comm.openTCPIP(1, "192.168.1.3", $2616) DIM swP26 as Switch DIM swP27 as Switch DIM lblP26 as Label DIM lblP27 as Label swP26 = Graphics.newSwitch(xcenter,25) !Default to off swP26.setOn(0) swP27 = Graphics.newSwitch(xcenter,65) !Default to off swP27.setOn(0) lblP26 = Graphics.newLabel(xcenter+85,25,100) lblP27 = Graphics.newLabel(xcenter+85,65,100) lblP26.setText("P26LED") lblP27.setText("P27LED") System.showGraphics SUB TxMessage(numbytes AS BYTE) FOR i% = 1 TO numbytes PUT #1,, Message~(i%) NEXT END SUB SUB SendMsgA1(db AS Byte) Message~(1) = $A1 Message~(2) = 2 Message~(3) = db ! Compute the checksum checksum~ = BITNOT(2 + db) + 1 Message~(4) = checksum~ TxMessage(4) END SUB SUB SendMsgA6 !Send known bytes Message~(1) = $A6 Message~(2) = 7 Message~(3) = $01 Message~(4) = $02 Message~(5) = $04 Message~(6) = $08 Message~(7) = $10 Message~(8) = $20 FOR idx = 2 To 8 checksum~ = checksum~ + Message~(idx) NEXT checksum~ = BITNOT(checksum~) +1 Message~(9) = checksum~ TxMessage(9) END SUB SUB valueChanged(ctrl AS Control, time AS DOUBLE) IF ctrl = swP26 THEN IF swP26.isON THEN SendMsgA1(1) ELSE SendMsgA1(2) END IF END IF IF ctrl = swP27 THEN IF swP27.isON THEN SendMsgA1(4) ELSE SendMsgA1(8) END IF END IF END SUB SUB touchUpInside(ctrl AS Button, when AS Double) if ctrl = quit then STOP ELSE IF ctrl = send6 THEN SendMsgA6 end if end sub