howardhb wrote:What WiFi hardware do you use on the copter?
Howard, I believe any Wifi to Serial device will work such as this one.
http://www.ebay.com/itm/281205805036?ss ... 1423.l2649
howardhb wrote:What WiFi hardware do you use on the copter?
Howard, I believe any Wifi to Serial device will work such as this one.
http://www.ebay.com/itm/281205805036?ss ... 1423.l2649
howardhb wrote:What WiFi hardware do you use on the copter?
howardhb wrote:Howard, I believe any Wifi to Serial device will work such as this one.
copterrichie wrote:Ok, I installed the updated version and was able to access the menu and sub-menus. I set the IP Address and port for my copters and upon pressing the connect, I received: "Unfortunately, Multiwii Remote has Stopped". I have a newer Tablet, going to test it there and see if I receive the same response.
Thank you and I am LOVING This.
Richard
copterrichie wrote:On the second tablet, I received the following: "failed to connect to /192.168.1.20 (port 8899) after 90000ms: isConnected failed: ECONNREFUSED (Connection refused)
Theelectronicguy wrote:
What android version are you running and what tablet?
Hmm, that means there is a problem with the wifi link, nothing I can do from this end. Did you connect to your copter wifi network before connecting with the app? If you are using an openwrt router, I had the same issue and reset it with the command "fastboot", installed ser2net and disabled the console.
I have to go now, I'll be back in about an hour.
Code: Select all
public class Wifi extends Communication {
private Activity myActivity;
private CommunicationInterface wifiInterface;
private Socket mySocket;
private BufferedInputStream input;
private OutputStream out;
private WifiManager wifiManager;
public Wifi(Activity myActivity) {
super(myActivity.getApplicationContext());
this.myActivity = myActivity;
wifiInterface = (CommunicationInterface) this.myActivity;
}
public boolean Write(byte[] data) {
super.Write(data);
try {
out.write(data);
} catch (IOException e) {
e.printStackTrace();
Connected = false;
}
return Connected;
}
Handler handler = new Handler();
Runnable inputRunnable = new Runnable() {
@Override
public void run() {
if(input != null)
try {
while(input.available() > 0)
wifiInterface.onReceive((byte) (input.read() & 0xFF));
}
catch(IOException e) {
e.printStackTrace();
}
if(Connected)
handler.postDelayed(this, 10);
}
};
public boolean flush() {
try {
out.flush();
return true;
} catch (IOException e) {
e.printStackTrace();
return false;
}
}
@Override
public boolean Connect(String ip, int port) {
address = ip + ":" + port;
setState(STATE_CONNECTING);
try {
mySocket = new Socket(ip, port);
input = new BufferedInputStream(mySocket.getInputStream());
out = mySocket.getOutputStream();
handler.post(inputRunnable);
setState(STATE_CONNECTED);
Connected = true;
}
catch(Exception e) {
e.printStackTrace();
setState(STATE_NONE);
setState(e.getMessage());
Connected = false;
}
return Connected;
}
@Override
public boolean dataAvailable() {
try {
if(input == null)
return false;
return input.available() != 0;
} catch (IOException e) {
e.printStackTrace();
return false;
}
}
@Override
public void Close() {
Connected = false;
if(mySocket != null && mySocket.isConnected())
try {
mySocket.close();
} catch (IOException e) {
e.printStackTrace();
}
}
@Override
public int getStrength() {
return 100 + wifiManager.getConnectionInfo().getRssi();
}
}
Code: Select all
<uses-permission android:name="android.permission.CHANGE_WIFI_STATE"/>
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/>
<uses-permission android:name="android.permission.ACCESS_WIFI_STATE"/>
<uses-permission android:name="android.permission.INTERNET"/>
Code: Select all
import android.net.wifi.WifiManager;
import android.net.wifi.WifiInfo;
private WifiManager wifiManager; // instance of the WifiManager for getting network details
private String wifiState; // state of the wifi connection
private String IpAddress;
//private String Network;
Socket socket;
ObjectOutputStream out;
DataInputStream in;
private String HostAddress = "192.168.1.77";
private int port = 8899;
private boolean NetworkFlag = false;
Code: Select all
wifiManager = (WifiManager) getSystemService(Context.WIFI_SERVICE);
int wifiStateCode = wifiManager.getWifiState();
switch (wifiStateCode) {
case 1:
wifiState = "Wifi disabled";
break;
case 3:
wifiState = "Wifi enabled";
WifiInfo wifiInfo = wifiManager.getConnectionInfo();
IpAddress = ReadIpAddress(wifiInfo.getIpAddress());
controlP5.addTextlabel("IpAddress",IpAddress,1,90).setFont(font15);
//init_com=true;
//graph_on=true;
try {
Socket socket=new Socket(HostAddress,port);
socket.setKeepAlive(true);
NetworkFlag = socket.isConnected();
out=new ObjectOutputStream(socket.getOutputStream());
in=new DataInputStream(socket.getInputStream());
controlP5.addTextlabel("HostIP",HostAddress,1,120).setFont(font15);
} catch (IOException e) {}
break;
case 4:
wifiState = "Wifi state unknown";
break;
default:
wifiState = "Other wifi state detected: " + wifiState;
}
controlP5.addTextlabel("WiFiStatus",wifiState,1,75).setFont(font15);
if(NetworkFlag==true){
buttonSTART.setColorBackground(green_);buttonSTOP.setColorBackground(green_);buttonREAD.setColorBackground(green_);
buttonRESET.setColorBackground(green_);
buttonCALIBRATE_ACC.setColorBackground(green_); buttonCALIBRATE_MAG.setColorBackground(green_);
}
WifiInfo wifiInfo = wifiManager.getConnectionInfo();
Code: Select all
[/code<?xml version="1.0" encoding="UTF-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android" android:versionCode="1" android:versionName="1.0" package="processing.test.multiwiiconfusb">
<uses-sdk android:minSdkVersion="14"/>
<application android:debuggable="true" android:icon="@drawable/icon" android:label="MultiWiiConfUSB">
<activity android:name=".MultiWiiConfWifi">
<intent-filter >
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/>
<uses-permission android:name="android.permission.ACCESS_WIFI_STATE"/>
<uses-permission android:name="android.permission.CHANGE_NETWORK_STATE"/>
<uses-permission android:name="android.permission.CHANGE_WIFI_STATE"/>
</manifest>
copterrichie wrote:Thank you for the INSPIRATION, will keep you posted on the testing.
Harnas wrote:I developed similar app for Windows Phone. Now works on my Nokia Lumia 820, and connected with multiwii board via bluetooth. I think in next 2-3 weeks app will be published on windows phone store, and source code will be published.
Theelectronicguy wrote:Looks good. How does it fly?
Nice. I think it would look better if you remove aux1 = 1000 and "illuminate" the 1000/1500/2000 values when they are selected. I never programed for the windows phone. How hard is it and what do you use?
copterrichie wrote:Just discovered there is an inherited problem with the touch screens on Tablets and maybe cell phones as well. The touch screen is unable to receive two simultaneous inputs. So, the built in Accelerometer may have to be used in place of one of the sticks.
ezio wrote:Well I think it is the problem of the implementation. Each android device should support multi touch. With new devices it is up to 10 fingers.
http://developer.android.com/training/g ... multi.html
ezio wrote:copterrichie wrote:Just discovered there is an inherited problem with the touch screens on Tablets and maybe cell phones as well. The touch screen is unable to receive two simultaneous inputs. So, the built in Accelerometer may have to be used in place of one of the sticks.
Well I think it is the problem of the implementation. Each android device should support multi touch. With new devices it is up to 10 fingers.
http://developer.android.com/training/g ... multi.html
Theelectronicguy wrote:ezio wrote:copterrichie wrote:Just discovered there is an inherited problem with the touch screens on Tablets and maybe cell phones as well. The touch screen is unable to receive two simultaneous inputs. So, the built in Accelerometer may have to be used in place of one of the sticks.
Well I think it is the problem of the implementation. Each android device should support multi touch. With new devices it is up to 10 fingers.
http://developer.android.com/training/g ... multi.html
Hey ezio,
Do you think you could add support for wifi in the next version of your app? I would love to use it, but as mentioned, I don't have bluetooth.
Code: Select all
import java.io.BufferedInputStream;
import java.io.IOException;
import java.io.OutputStream;
import java.net.Socket;
import java.util.List;
import android.app.Activity;
import android.content.Context;
import android.net.wifi.WifiConfiguration;
import android.net.wifi.WifiManager;
import android.os.Handler;
public class Wifi extends Communication {
private Activity myActivity;
private CommunicationInterface wifiInterface;
private Socket mySocket;
private BufferedInputStream input;
private OutputStream out;
private WifiManager wifiManager;
public Wifi(Activity myActivity) {
super(myActivity.getApplicationContext());
this.myActivity = myActivity;
wifiInterface = (CommunicationInterface) this.myActivity;
wifiManager = (WifiManager) myActivity.getSystemService(Context.WIFI_SERVICE);
Enable();
}
//TODO connectToNetwork not working
public boolean connectToNetwork(String ssid, String key) {
WifiConfiguration wifiConfig = new WifiConfiguration();
wifiConfig.SSID = String.format("\"%s\"", ssid);
wifiConfig.preSharedKey = String.format("\"%s\"", key);
wifiConfig.allowedProtocols.set(WifiConfiguration.Protocol.WPA);
int netId;
WifiConfiguration currentConf = getConfiguredNetwork(wifiManager, ssid);
if(currentConf == null)
netId = wifiManager.addNetwork(wifiConfig);
else
netId = currentConf.networkId;
if(wifiManager.getConnectionInfo().getSSID().equalsIgnoreCase(ssid))
return true;
wifiManager.disconnect();
wifiManager.enableNetwork(netId, true);
return wifiManager.reconnect();
}
private WifiConfiguration getConfiguredNetwork(WifiManager wifiManager, String ssid) {
List<WifiConfiguration> myList = wifiManager.getConfiguredNetworks();
for(WifiConfiguration current: myList) {
if(current.SSID.equalsIgnoreCase(ssid))
return current;
}
return null;
}
public void setState(String state) {
this.state = state;
}
public String getConnectionState() {
return state;
}
public boolean Write(byte[] data) {
super.Write(data);
try {
out.write(data);
Connected = true;
} catch (IOException e) {
e.printStackTrace();
Connected = false;
}
return Connected;
}
Handler handler = new Handler();
Runnable inputRunnable = new Runnable() {
@Override
public void run() {
if(input != null)
try {
while(input.available() > 0)
wifiInterface.onReceive((byte) (input.read() & 0xFF));
}
catch(IOException e) {
e.printStackTrace();
}
if(Connected)
handler.postDelayed(this, 10);
}
};
public boolean flush() {
try {
out.flush();
return true;
} catch (IOException e) {
e.printStackTrace();
return false;
}
}
@Override
public void Enable() {
if(!wifiManager.isWifiEnabled())
wifiManager.setWifiEnabled(true);
}
@Override
public boolean Connect(String ip, int port) {
address = ip + ":" + port;
setState(STATE_CONNECTING);
try {
mySocket = new Socket(ip, port);
mySocket.setKeepAlive(true);
input = new BufferedInputStream(mySocket.getInputStream());
out = mySocket.getOutputStream();
handler.post(inputRunnable);
setState(STATE_CONNECTED);
Connected = true;
}
catch(Exception e) {
e.printStackTrace();
setState(STATE_NONE);
setState(e.getMessage());
Connected = false;
}
return Connected;
}
@Override
public boolean dataAvailable() {
try {
if(input == null)
return false;
return input.available() != 0;
} catch (IOException e) {
e.printStackTrace();
return false;
}
}
@Override
public byte Read() {
return 0;
}
@Override
public void Close() {
Connected = false;
if(mySocket != null && mySocket.isConnected())
try {
mySocket.close();
} catch (IOException e) {
e.printStackTrace();
}
}
@Override
public void Disable() {
if(wifiManager.isWifiEnabled())
wifiManager.setWifiEnabled(false);
}
@Override
public int getStrength() {
return 100 + wifiManager.getConnectionInfo().getRssi();
}
}
Theelectronicguy wrote:I actually tried to add it on the source you published on github, but couldn't get it to run >.<. Thanks for adding it
copterrichie wrote:Here is a much better version for $49 bucks:
HyperTAB 7" Google Android 4.2 Tablet 4GB Dual Core A23 Jelly Bean PC
http://www.ebay.com/itm/HyperTAB-7-Goog ... 1088431544
Theelectronicguy wrote:Gladly:Code: Select all
import java.io.BufferedInputStream;
import java.io.IOException;
import java.io.OutputStream;
import java.net.Socket;
import java.util.List;
import android.app.Activity;
import android.content.Context;
import android.net.wifi.WifiConfiguration;
import android.net.wifi.WifiManager;
import android.os.Handler;
public class Wifi extends Communication {
private Activity myActivity;
private CommunicationInterface wifiInterface;
private Socket mySocket;
private BufferedInputStream input;
private OutputStream out;
private WifiManager wifiManager;
public Wifi(Activity myActivity) {
super(myActivity.getApplicationContext());
this.myActivity = myActivity;
wifiInterface = (CommunicationInterface) this.myActivity;
wifiManager = (WifiManager) myActivity.getSystemService(Context.WIFI_SERVICE);
Enable();
}
//TODO connectToNetwork not working
public boolean connectToNetwork(String ssid, String key) {
WifiConfiguration wifiConfig = new WifiConfiguration();
wifiConfig.SSID = String.format("\"%s\"", ssid);
wifiConfig.preSharedKey = String.format("\"%s\"", key);
wifiConfig.allowedProtocols.set(WifiConfiguration.Protocol.WPA);
int netId;
WifiConfiguration currentConf = getConfiguredNetwork(wifiManager, ssid);
if(currentConf == null)
netId = wifiManager.addNetwork(wifiConfig);
else
netId = currentConf.networkId;
if(wifiManager.getConnectionInfo().getSSID().equalsIgnoreCase(ssid))
return true;
wifiManager.disconnect();
wifiManager.enableNetwork(netId, true);
return wifiManager.reconnect();
}
private WifiConfiguration getConfiguredNetwork(WifiManager wifiManager, String ssid) {
List<WifiConfiguration> myList = wifiManager.getConfiguredNetworks();
for(WifiConfiguration current: myList) {
if(current.SSID.equalsIgnoreCase(ssid))
return current;
}
return null;
}
public void setState(String state) {
this.state = state;
}
public String getConnectionState() {
return state;
}
public boolean Write(byte[] data) {
super.Write(data);
try {
out.write(data);
Connected = true;
} catch (IOException e) {
e.printStackTrace();
Connected = false;
}
return Connected;
}
Handler handler = new Handler();
Runnable inputRunnable = new Runnable() {
@Override
public void run() {
if(input != null)
try {
while(input.available() > 0)
wifiInterface.onReceive((byte) (input.read() & 0xFF));
}
catch(IOException e) {
e.printStackTrace();
}
if(Connected)
handler.postDelayed(this, 10);
}
};
public boolean flush() {
try {
out.flush();
return true;
} catch (IOException e) {
e.printStackTrace();
return false;
}
}
@Override
public void Enable() {
if(!wifiManager.isWifiEnabled())
wifiManager.setWifiEnabled(true);
}
@Override
public boolean Connect(String ip, int port) {
address = ip + ":" + port;
setState(STATE_CONNECTING);
try {
mySocket = new Socket(ip, port);
mySocket.setKeepAlive(true);
input = new BufferedInputStream(mySocket.getInputStream());
out = mySocket.getOutputStream();
handler.post(inputRunnable);
setState(STATE_CONNECTED);
Connected = true;
}
catch(Exception e) {
e.printStackTrace();
setState(STATE_NONE);
setState(e.getMessage());
Connected = false;
}
return Connected;
}
@Override
public boolean dataAvailable() {
try {
if(input == null)
return false;
return input.available() != 0;
} catch (IOException e) {
e.printStackTrace();
return false;
}
}
@Override
public byte Read() {
return 0;
}
@Override
public void Close() {
Connected = false;
if(mySocket != null && mySocket.isConnected())
try {
mySocket.close();
} catch (IOException e) {
e.printStackTrace();
}
}
@Override
public void Disable() {
if(wifiManager.isWifiEnabled())
wifiManager.setWifiEnabled(false);
}
@Override
public int getStrength() {
return 100 + wifiManager.getConnectionInfo().getRssi();
}
}
I actually tried to add it on the source you published on github, but couldn't get it to run >.<. Thanks for adding it
Code: Select all
public int getRSSI() {
try {
int rssi = wifi.getConnectionInfo().getRssi();
int level = WifiManager.calculateSignalLevel(rssi, 10);
int percentage = (int) ((level / 10.0) * 100);
Log.d("aaa", "WiFI RSSI=" + String.valueOf(percentage));
return percentage;
} catch (Exception e) {
return 0;
}
}