How to keep Android HotSpot wifi alive

LiveCode is the premier environment for creating multi-platform solutions for all major operating systems - Windows, Mac OS X, Linux, the Web, Server environments and Mobile platforms. Brand new to LiveCode? Welcome!

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller

Post Reply
trevix
Posts: 958
Joined: Sat Feb 24, 2007 11:25 pm
Location: Italy
Contact:

How to keep Android HotSpot wifi alive

Post by trevix » Wed Apr 06, 2022 3:09 pm

Hello.
I am running a socket server on a Android 10 TvBox, that has the hotspot mode enabled.
I have noticed that the hotspost mode goes off after around 10 minutes, UNLESS somebody is connected to the server socket.

Unfortunatly the TvBox settings don't have any mean to keep the hotspot alive, like you can do on most phones.

So, the question is how to fake a socket connection to itself and see if this is enough to let the TvBox in hotspot mode.

I did this but it seems not to be enough or something is wrong:

Code: Select all

command chatServerStart
     accept connections on port kPort with message "chatServerClientConnected"
     send "ServerTimer" to me in 240 seconds --keep hotspot alive
     put true into sRunning
end chatServerStart

--keep the hotspot alive -test
Command ServerTimer
     put the networkInterfaces into tInterfacesList
     set the itemdelimiter to "."
     repeat for each line tMyIP in tInterfacesList
          if item 1 of tMyIP <> 127 then 
               exit repeat
          end if
     end repeat
     open datagram socket to tMyIP & ":" & kPort 
     close socket tMyIP & ":" & kPort 
     if sRunning then
          --Refresh hotspot
          send "ServerTimer" to me in 240 seconds
     end if
end ServerTimer
Thanks for any suggestions
Trevix
Trevix
OSX 14.3.1 xCode 15 LC 10 DP7 iOS 15> Android 7>

mrcoollion
Posts: 719
Joined: Thu Sep 11, 2014 1:49 pm
Location: The Netherlands

Re: How to keep Android HotSpot wifi alive

Post by mrcoollion » Thu Apr 07, 2022 1:00 pm

Maybe sending a ping command to a server on the internet or a device?

trevix
Posts: 958
Joined: Sat Feb 24, 2007 11:25 pm
Location: Italy
Contact:

Re: How to keep Android HotSpot wifi alive

Post by trevix » Thu Apr 07, 2022 3:11 pm

If the TvBox is in hotspot mode, it is not connected to internet. Cannot ping.
But, acting as socket server, it does have a socket open.
Why can't it write to its own socket?
Trevix
OSX 14.3.1 xCode 15 LC 10 DP7 iOS 15> Android 7>

mrcoollion
Posts: 719
Joined: Thu Sep 11, 2014 1:49 pm
Location: The Netherlands

Re: How to keep Android HotSpot wifi alive

Post by mrcoollion » Fri Apr 08, 2022 10:42 am

I do not have an answer to you question.
However what happens if you ping it's own IP Adress? Does this keeps the interfaces alive?

Regards,

Paul

trevix
Posts: 958
Joined: Sat Feb 24, 2007 11:25 pm
Location: Italy
Contact:

Re: How to keep Android HotSpot wifi alive

Post by trevix » Fri Apr 08, 2022 2:00 pm

As in the LC script above, I tried to open/close a socket to itself (this is the only "ping" method that I know of) but it does not work.

This is the reason of my post.
Trevix
OSX 14.3.1 xCode 15 LC 10 DP7 iOS 15> Android 7>

Post Reply

Return to “Getting Started with LiveCode - Experienced Developers”