Mintoris Forum

Author Topic: Hobbyking WiFi Receiver Control Demo  (Read 3726 times)

Chuck

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 1899
Hobbyking WiFi Receiver Control Demo
« on: Mar 13, 2013, 03:25 AM »
Hobbyking makes a really cool little device that lets you control your R/C model from your Android device. The device acts as a WiFi hotspot. You connect to the hotspot and use the Basic program below to control your R/C model (cars, planes, boats, robots, etc).

Hobbyking 4CH WiFi Receiver



Code: [Select]
Global null$, header$
null$ = chr$(0)
header$ = chr$(85) + chr$(0) + chr$(11) + chr$(0)

do

  Print "Attempting to connect…"
  wait 1

  TcpOpen 1, "10.10.100.254", 8899, "c", 12000, 1000

  if TcpGetState(1) = 1 then

    Print "Connected"
    wait 1

    do while TcpGetState(1) = 1

      ' set your channel values here.
      sendRawChannels(0, 25, 50, 100)
      wait 50

    loop

  endif

  Print "Not Connected"
  Print TcpGetError$(1)
  TcpClose 1

loop

end


Sub sendRawChannels(ch1, ch2, ch3, ch4)

  ' Add header
  packet$ = header$

  ' Add channel values
  packet$ = packet$ + chr$(ch1 & 255)  
  packet$ = packet$ + chr$(ch2 & 255)  
  packet$ = packet$ + chr$(ch3 & 255)  
  packet$ = packet$ + chr$(ch4 & 255)  

  ' Two bytes not used
  packet$ = packet$ + null$  
  packet$ = packet$ + null$  

  sum = 0
  for i = 1 to 10
    sum = sum + ascii(mid$(packet$, i, 1))
  next

  ' Add checksum byte
  packet$ = packet$ + chr$(sum % 256)

  TcpWrite 1, packet$

End Sub
« Last Edit: Sep 21, 2014, 08:03 AM by Chuck »

Chuck

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 1899
Re: Hobbyking WiFi Receiver Control Demo
« Reply #1 on: Mar 07, 2014, 06:16 PM »
The following is a link to a full app using the Hobbyking WiFi Receiver.

Remote Camera Control App