Skip to main content

Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Paho » Paho cannt connect to a wireless network
Paho cannt connect to a wireless network [message #1670659] Fri, 13 March 2015 09:32 Go to next message
Amr Mising name is currently offline Amr Mising nameFriend
Messages: 3
Registered: December 2011
Junior Member
I am developing an Android App and using Paho MQTT library. the App is based on the current WiFi state and the currently connected network, so this means that i am using a WiFi receiver to monitor the WiFi states.

The problem is, in my own PC, when I run the App, it detected the network and connects to the it and it works fine. But, when I tried to connect the App to a telemetry Box which is also connected to the network, the App cant neither detect not connect to the network.

Any suggestions why that is happening? please have a lok at the code posted below shw how i connect to network


int wifiExtras = intent.getIntExtra(WifiManager.EXTRA_WIFI_STATE, WifiManager.WIFI_STATE_UNKNOWN);
//WifiManager wifiMgr = (WifiManager) context.getSystemService(WiFi_Service);

switch (wifiExtras) {
MQTTPrimaryReceiverLocked = true;
Log.i(TAG, "@MQTTPrimaryConnectReceiver(): WIFI_STATE_ENABLING");
MQTTPrimaryReceiverT1 = new Timer();
MQTTPrimaryReceiverT1.schedule(new MQTTReceiverLockTimedTask(), RELEASE_MQTT_RECEIVER_LOCK_AFTER);
timer1Scheduled = true;

case WifiManager.WIFI_STATE_ENABLED:
MQTTPrimaryReceiverLocked = true;
Log.i(TAG, "@MQTTPrimaryConnectReceiver(): WIFI_STATE_ENABLED");
MQTTPrimaryReceiverT2 = new Timer();
MQTTPrimaryReceiverT2.schedule(new MQTTReceiverLockTimedTask(), RELEASE_MQTT_RECEIVER_LOCK_AFTER);
timer2Scheduled = true;

MQTTPrimaryReceiverLocked = true;
Log.i(TAG, "@MQTTPrimaryConnectReceiver(): WIFI_STATE_DISABLING");
MQTTPrimaryReceiverT3 = new Timer();
MQTTPrimaryReceiverT3.schedule(new MQTTReceiverLockTimedTask(), RELEASE_MQTT_RECEIVER_LOCK_AFTER);
timer3Scheduled = true;

MQTTPrimaryReceiverLocked = true;
Log.i(TAG, "@MQTTPrimaryConnectReceiver(): WIFI_STATE_DISABLED");
Log.i(TAG, "@MQTTPrimaryConnectReceiver(): No InterNet Connectivity.");
Toast.makeText(getApplicationContext(), "WIFI_STATE_DISABLED.", Toast.LENGTH_SHORT).show();
MQTTPrimaryReceiverT4 = new Timer();
MQTTPrimaryReceiverT4.schedule(new MQTTReceiverLockTimedTask(), RELEASE_MQTT_RECEIVER_LOCK_AFTER);
timer4Scheduled = true;

if ( (MQTTConnModuleWasCalled) && (!reconnectTimerCurrentlyActive) ) {
} else if (!MQTTConnModuleWasCalled) {

case WifiManager.WIFI_STATE_UNKNOWN:
MQTTPrimaryReceiverLocked = true;
Log.i(TAG, "@MQTTPrimaryConnectReceiver(): WIFI_STATE_UNKNOWN");
MQTTPrimaryReceiverT5 = new Timer();
MQTTPrimaryReceiverT5.schedule(new MQTTReceiverLockTimedTask(), RELEASE_MQTT_RECEIVER_LOCK_AFTER);
timer5Scheduled = true;

**Code2 **:

protected void interNetConnectivityModule() {
// TODO Auto-generated method stub
Log.w(TAG, "@interNetConnectivityModule().");

ConnectivityManager mConnMgr = (ConnectivityManager)getSystemService(Network_Service);

if (mConnMgr != null) {
NetworkInfo networkInfo = mConnMgr.getActiveNetworkInfo();

if (networkInfo != null) {

switch(networkInfo.getType()) {
case ConnectivityManager.TYPE_WIFI:
if (networkInfo.isConnected()) {
Log.i(TAG, "@interNetConnectivityModule(): Connected");

Re: Paho cannt connect to a wireless network [message #1692244 is a reply to message #1670659] Tue, 14 April 2015 13:41 Go to previous messageGo to next message
Ian Craggs is currently offline Ian CraggsFriend
Messages: 76
Registered: March 2013
If your subject line is correct "Paho can't connect...", have you tried using the client trace facility to get an idea of what is going on?
Re: Paho cannt connect to a wireless network [message #1693099 is a reply to message #1692244] Tue, 21 April 2015 17:36 Go to previous message
Amr Mising name is currently offline Amr Mising nameFriend
Messages: 3
Registered: December 2011
Junior Member
sorry fo rthe late reply...can you please provide an example of and explanation how to use it
Previous Topic:Paho application with java fx
Next Topic:Paho Javascript client
Goto Forum:

Current Time: Wed Dec 02 10:29:12 GMT 2020

Powered by FUDForum. Page generated in 0.06008 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top