I am using Windows 7 as OS on my PC. I am looking to create an application wherein I shall send AT commands to Mobile, programatically.
As of now I am looking towards achieving this with USB data cable connection between PC and Mobile. My initial approach was to use JAVA. Though I soon realized that most API development for communication between JAVA and USB port is dead for windows, and none of these APIs support Windows 7.
Can someone please suggest which language would be best for doing this?
Thanks,
Ishan Aggarwal
For Android to create connection with PC, you need forward the same port by using adb command (Android SDK), like:
adb forward tcp:7612 tcp:7612
In Java it seems like:
private int port = 7612;
....
/**
* Runs the android debug bridge command of forwarding the ports
*
*/
private void execAdb() {
// run the adb bridge
try {
String runP = "adb forward tcp:" + port + " tcp:" + port + "";
System.out.println("Run command through cmd: " + runP);
Process p=Runtime.getRuntime().exec(runP);
Scanner sc = new Scanner(p.getErrorStream());
if (sc.hasNext()) {
while (sc.hasNext()) System.out.println(sc.next());
System.out.println("Cannot start the Android debug bridge");
}
} catch (Exception e) {
e.printStackTrace();
}
}
After that you can implement any TCP client/server code since the port is defined and you can use default IP like: 127.0.0.1
For iOS use Objective C lang.
Related
I'm trying to setup my environment to develop with react-native and react-devtools.
Per default the react-devtool uses port 8097 to connect with the app on the emulator.
Unfortunatley, this port is blocked at my workplace. Where/How can i change this port?
I found out that there's an option to configure the devtools with:
const { connectToDevTools } = require("react-devtools-core");
connectToDevTools( { port: "customport" } );
I just don't know where to place this config.
I managed to change the app so that it tries to connect to a different port, but i can't seem to change wart port the devtool client (?) uses (see image)
Any help is appreciated
I am developing a backend with some routes that I want to use in an iOS App (developing the app with Expo and react-native).
So during the development mode (both for the backend and for the app), the backend is served on http://127.0.0.1:80/, and it is working perfectly when the app is on the iOS Emulator, but when I start the app on a real device, then I can't connect to the backend using the same url.
What url should I use ? Or which setting do I miss ?
Here is the code I have for starting the server...
const app = require('./app');
app.set('port', process.env.PORT || 80);
const server = app.listen(app.get('port'), () => {
console.log(`Express running → PORT ${server.address().port}`);
});
Localhost won't work if you have two different devices. Instead try to connect both to the same wifi network and use the ipv4 adress of you pc (find with ipconfig in cmd) instead of '127.0.0.1'. Provided that your firewall doesn't block the connection.
So thanks to #Mukeyii I found the answer (for a Mac and an iPhone at least) on this page
Here are the steps :
On your Node app, you need to give the port and the ip you'll be listening the app, for example :
const app = require('./app'); // app is made with express.js
app.set('port', 80);
const server = app.listen(app.get('port'), '0.0.0.0', () => {
console.log(`Express running → PORT ${server.address().port}`);
});
Strangely, I wanted to put the 127.0.0.1 ip but it didn't work. 0.0.0.0 worked for me so I put that one.
On the /private/etc/hosts file, add the line 0.0.0.0 any.url.you.wish, save and test on a browser on your computer that when you start your app (dev mode) and you type the url any.url.you.wish, you go on your app.
Download SquidMan and open it, let it install what it wants to install.
In SquidMan > Preferences, set the port in the General tab (for me: 80)
On the Client tab, set a new ip: the ip address of the iOS mobile device. To get it, you need to click on the i in front of your WiFi connected network.
On the Template tab, add a comment on the line http_access deny to_localhost and add these two lines :
# hosts file
hosts_file /private/etc/hosts
Save the Preferences and Start Squid
Get the IP Address of the Mac in System Preferences > Network
Configure the Proxy on the iPhone (port + ip) at the bottom of the same view described in 5.
That's it ! Read more infos in this url: http://egalo.com/2012/05/29/testing-mac-web-site-using-local-hostname-on-mobile-device/
I'm trying to build a very simple chat application with wxWidgets. At the moment, I can open the software on my local machine and on a virtual machine with it's own LAN IP Address. I'm able to retrieve each machines local IP Address via wxGetFullHostName() function; which I then manually enter this value into the other instance so that they connect. Everything works well at this stage.
However, now I'd like to send the .exe to a friend somewhere else. How can I get the application to expose the machines public IP address so that I can provide it to my friend to connect to my instance? Are their any other requirements to have the two instances connect to each other?
I'm using C++, but I don't think it matters much to this question.
For a platform independent method that works behind NAT, I would suggest to use ipify (https://www.ipify.org/).
There are many ways of achieving this in C++ and wxWidgets. Possibly one of the best is to use curl (https://curl.haxx.se/libcurl/).
However, for a 'pure' wxWidgets implementation you can try the following modification to the minimal.cpp sample:
#include <wx/sstream.h>
#include <wx/protocol/http.h>
#include <wx/msgdlg.h>
MyFrame::MyFrame(const wxString& title)
: wxFrame(NULL, wxID_ANY, title)
{
wxHTTP http;
http.SetHeader("Content-type", "text/html; charset=utf-8");
http.SetTimeout(10);
http.Connect("api.ipify.org");
wxInputStream* httpStream = http.GetInputStream("/");
if (http.GetError() == wxPROTO_NOERR)
{
wxString result;
wxStringOutputStream out_stream(&result);
httpStream->Read(out_stream);
wxMessageBox(result);
}
else
{
wxMessageBox("Unable to connect!");
}
wxDELETE(httpStream);
}
I have been currently working with OpenGTS platform, I would like to help me with something.
I want to connect a GPS to the platform is the "GPS TRACKER 103ab" this GPS works under the protocol "TK-103". To see if they could help me connect this device to the platform. I followed the documentation to activate the devicenter code heree through SMS to my cell with commands like:
Begin123456 = to start the device.
IMEI123456 = so that the device will return the 15 digits.
adminip123456 109.0.0.9 = 8080 to set the ip + port that I am using.
The problem is that still can not get connect with the platform, help me.
Facts:
Opengts
GPS TRACKER 103ab
Protocol "TK-103"
You can use Traccar GPS server to receive data from your device and integrate it with OpenGTS if you want to access the data from OpenGTS web interface. Traccar supports more communication protocols than OpenGTS.
The correct command to set ADMINIP is :
adminip123456 [xxx.xxx.xxx.xxx] [xxxx]
where the first field is the IP address of your server, must be an address public and accessible from the outside.
and the second field (note that they are only separated by a space) is the port where the server expects the connection , the default is 31272 for tk10x protocol. NEVER 8080 , this is the port where Tomcat listens.
After setting the ' adminp ' , use the command:
fix001m***123456
to start position reports every minute.
it is also necessary to set the APN,APNuser,APNpassword from the mobile service provider's of the device.
use the commands:
apn123456 datos.personal.com
apnuser123456 gprs
apnpasswd123456 gprs
(This is an example using the appropriate data to the service provider's Personal.ar)
I am trying to setup a peer to peer connection for WebRTC application. I have read the forums and discussion groups which lead me to the point that STUN/TURN servers are required for the same. Here are the details:
I downloaded the open source implementation of the STUN/TURN server from https://code.google.com/p/rfc5766-turn-server/
Installed the server on my local Mac OS X machine and turned on the server on localhost:3478
When I tested the server using the client scripts, I was able to get back the remote address from the server.
However, when I try to hit the server from my JavaScript code while creating a peer to peer connection, it is not hitting the server itself.
Below is the code which I am using :
function createPeerConnection() {
var pc_config = {'iceServers': [{'url':'turn:127.0.0.1:3478', 'credential':'Apple123'}]};
try {
// Create an RTCPeerConnection via the polyfill (adapter.js).
pc = new webkitRTCPeerConnection(pc_config);
pc.onicecandidate = gotLocalCandidate;
trace("Created RTCPeerConnnection with config:\n" + " \"" +JSON.stringify(pc_config) + "\".");
} catch (e) {
trace("Failed to create PeerConnection, exception: " + e.message);
alert("Cannot create RTCPeerConnection object; WebRTC is not supported by this browser.");
return;
}
pc.onconnecting = onSessionConnecting;
pc.onopen = onSessionOpened;
pc.onaddstream = onRemoteStreamAdded;
pc.onremovestream = onRemoteStreamRemoved;
}
Appreciate any guidance in this matter as I am completely stuck at this point.
One more question: How to setup a peer to peer connection for WebRTC application where both peer A and B are present on an internal network? Is STUN/TURN servers required then?
First, TURN servers are something that are used only if failing to setup an p2p connection directly. About 86% of all calls can be made without relaying via a TURN server (according to this slide, which I by the way recomend to get a better understanding of TURN (from slide 44)).
TURN server should be outside your network since the purpose of it is to relay the stream when not possible to do so in other way.
I would recomend you to start with the case where both A and B are on the same network. Then you do not need to worry about using STUN/TURN. It's enough complicated as it is.