Working on USB Modem, Used RAS interface for dial/hangup.
For connection used RASDial() and for disconnection used RASHangUp() API's.
After successful connection waiting for the disconnect event using function RasConnectionNotification(rasHandle, event, RASCN_Disconnection), event notifies successfully when disconnect happens.
I need to find out the reason of disconnection, if it disconnect due to lost network signal then put my application on auto reconnect.
Is there any method or API which provides the reason for disconnection like LINK_FAILED, USER_SWITCH, USER_LOGOFF ... etc.
RasGetConnectStatus API can give you the reason in RASCONNSTATUS.dwError field.
Related
I am using esp32 code where it connects with wifi and sends data over mqtt.But on any MQTT failure,it does not reconnect. We should not need to reboot the device from outside, it should get back online whenever the problem is solved. The machine may restart after a long time when it is needed ,but remember on any failure it should not keep rebooting.
i'm Working on a embedded Linux system. I need to connect to new WiFi when the existing WiFi disconnects. I can use a loop with a fixed sleep time and see if the wifi is connected or not, but it seems inefficient.
Can anyone suggest a way that wpa_cli can be started as a daemon that fires an event when WiFi is disconnected.
Thanks in advance.
Sundeep.
You could use the control socket that wpa_supplicant exposes to allow external applications to control it.docs are here. You try it out on wpa_cli, eg: run following commmand in wpa_cli scan and scan_results. When you connect to the socket you get all the events like connection,disconection etc. These events are described in the docs
I recently switched my Chromecast app to a custom receiver. I'm still using the Cast Companion Library. The custom receiver is basically based on this https://github.com/googlecast/cast-custom-receiver/blob/master/sample_media_receiver.html the only changes are the adding of a logo and loading screen and commenting out this line appConfig.maxInactivity = 6000; although at first I didn't have it commented out and still had the same issue.
Anyways the issue is pretty simple and only happens to a few people. It happens to me with one of my test devices, not all and not always. Basically I start streaming a video and it is all fine, then the device screen goes off, when I turn it off again the app has disconnected from the Chromecast. I do not have wifi set to turn off when sleeping, and all of the users who have complained about this claim their devices also don't have that setting turned on.
It could be a coincidence that this happened when I switched to the custom receiver but I just wanted to make sure there wasn't something I needed to add to my custom receiver to tell the CCL code to stay connected?
Thanks.
I faced similar issue today. Main cause for this behaviour is that as soon as the sender (in your case phone) is locked (sleep mode) then senderDisconnected event is fired on the receiver side. And if you check the event.reason, it will be unknow, so you could probably check for the reason, if it unknown then dont stop the playback on receiver (window.close).
When the sender itself disconnects, event.reason is "disconnected_from_sender".
I hope this helps.
It has nothing to do with maxInactivity.
The policy for disconnecting wifi when your phone goes to sleep does depend on the brand and vendor . Currently, the Cast SDK holds a lock to keep the wifi connected as long as there is a cast connection but even that is not a 100% guarantee to work for all phones/models/vendors/.... This has nothing to do with your receiver. The proper solution is not to try to fight against the wifi disconnect when phone goes to sleep, instead you have to consider adding some logic to recover the cast connectivity when phone wakes up and wifi connectivity is re-established (register a broadcast receiver to listen for wifi connectivity changes).
I am using boost asio for my TCP Server, in this I am using async_read_some for reading .
Application is working fine when network is connected, normal connection closing are handled correctly like (EOF,abrupt closing).
But my problem is I am not getting any error when network cable is unplugged. socket is open , and I get error when I am writing on socket. This is the way socket work.
Question: Can this is handled in Boost asio by any method?
You may want to set "keep alive" on the socket, see Socket closed notification. Try:
socket.set_option(boost::asio::socket_base::keep_alive(true));
I'm working with an embedded system which has a RAS entry already set up, using the API function RasDial from rasapi32.dll.
All works well except if something goes wrong after RasDial and before RasHangUp. In this case any further attempt to dial is met with error 756 "connection is being dialled", whether the dial attempt is done via the API or via the Windows rasdial command line utility.
rasdial connectionname /d doesn't help either.
The com port used for the modem is locked.
The only way to recover is to reboot.
Obviously under normal circumstances the solution is to make sure that RasDial is always followed by RasHangUp. But for cases where this doesn't happen, is there a way of aborting the dial attempt? For example, if the app calls RasDial and then crashes, how do I get out of that other than by rebooting?
Unfortunately, unless your application can properly terminate the connection that's in progress before exiting the RAS state machine becomes corrupted and must reboot to fix the problem. I've noticed that Windows 7 handles these sorts of scenarios better than XP and Vista did, but there are still occasions when I've had to reboot.
I've managed to prevent most of these sorts of problems with the DotRas API as long as they're occuring in the event handlers of the RasDialer, but if the application crashes from another thread and not from the background thread which raises the RasDialer events, there's nothing I can do about that.
For asynchronous dialing using the DotRas 1.2 SDK:
using DotRas;
RasDialer dialer = new RasDialer();
dialer.EntryName = "My Connection";
dialer.Credentials = new NetworkCredential("My", "User");
dialer.DialAsync();
From this point you can call dialer.DialAsyncCancel() if you want to cancel the connection attempt that's in progress.
For synchronous dialing using the DotRas 1.2 SDK is very similar to asynchronous dialing other than replacing the DialAsync call with simply dialer.Dial().
Here's a link to the API I was talking about: http://www.codeplex.com/DotRas
Hope that helps!