Home
JAQForum Ver 24.01
Log In or Join  
Active Topics
Local Time 13:41 27 Nov 2024 Privacy Policy
Jump to

Notice. New forum software under development. It's going to miss a few functions and look a bit ugly for a while, but I'm working on it full time now as the old forum was too unstable. Couple days, all good. If you notice any issues, please contact me.

Forum Index : Microcontroller and PC projects : Hopefully something useful

Author Message
Malibu
Senior Member

Joined: 07/07/2018
Location: Australia
Posts: 228
Posted: 05:10am 25 Oct 2023
Copy link to clipboard 
Print this post

As the title says, hopefully this is something that might be useful that others might want to try out...

My idea is using a WebMite running a stand-alone control system, with a local VB6 program running to easily setup complex parameters and transfer the data to the WebMite.

The same setup could be done with a web page on the WM, but for various reasons, I found it easier to do complex math and data inputs on the VB program.
I should also still be able to access 'normal' web pages via a web browser solely for monitoring.

So, what I've come up with is this (and I was surprised at how simple it was to do)
The WebMite code -

 '
 OPTION EXPLICIT
 OPTION DEFAULT NONE
 option autorun on
 option base 1

Dim string Var1, Var2, Var3

Do While MM.Info(IP ADDRESS) = "0.0.0.0"
 If Timer > 5000 Then
   ? "WiFi Timeout - Reboot"
   Pause 500
   CPU RESTART
 end if
 ? "Waiting for WiFi"
 Pause 1000
Loop
? "Connected.  IP address is " + MM.Info$(ip address)

WEB TCP INTERRUPT WebInterrupt

Var1 = "This is variable #1"
Var2 = "Variable number 2"
Var3 = "Another variable (Number #3)"

do
loop

Sub WebInterrupt
 SortData
end sub

Sub SortData
 Local integer a%
 Local Integer b(512)
 for a% = 1 to mm.info(max connections)
   LongString CLEAR b()
   WEB TCP READ a%, b()
   longstring print b()
   if (linstr(b(), "SitRep") > 0) then
     SendSitRep a%
   Else  
   end if
 next a%
end sub

sub SendSitRep a%
 web transmit page a%, "/SitRep.html"
end sub


The VB code (Just use a standard form, add a winsock control, a command button and a text box) -


Option Explicit
Dim SockData As String
Const IpAddress As String = "Insert your IP Address here"
Const Port As Integer = 80

Private Sub cmdSend_Click()
 If Winsock1.State = 7 Then
   Winsock1.SendData "SitRep"
 End If
End Sub

Private Sub Form_Load()
 Winsock1.Connect IpAddress, Port
End Sub

Private Sub Winsock1_Connect()
 DoEvents
End Sub

Private Sub Winsock1_DataArrival(ByVal bytesTotal As Long)
 Winsock1.GetData SockData, 1000
 Text1.Text = SockData
 Winsock1.Close
 Winsock1.Connect IpAddress, Port
End Sub


...and a webpage called 'SitRep.html' to the WM like this...
{Var1}
{Var2}
{Var3}


The returned result is this -
  Quote  HTTP/1.1 200 OK
Server:CPi
Connection:close
Content-type:text/html
Content-Length:68

This is variable #1
Variable number 2
Another variable (Number #3)


Easily sorted by VB6 if needed.

I'm aware that this is probably a completely wrong way to do this, but I found it quick and easy and seems to suit my needs (as a proof of concept, anyway)

Hopefully someone might find the idea worth trying out (Especially those like me that still like and use VB6 [VB.net?... no thanks, it's a nightmare!])

(Forgot to mention, there is absolutely NO error traps or suchlike in any of this code)
Edited 2023-10-25 15:16 by Malibu
John
 
DavidAlanRoss
Newbie

Joined: 18/09/2023
Location: United States
Posts: 14
Posted: 12:48pm 25 Oct 2023
Copy link to clipboard 
Print this post

Clever combo.

Long live VB6!

I had to embrace Xojo myself, being a Mac and all.
 
Print this page


To reply to this topic, you need to log in.

© JAQ Software 2024