Sending an MMS programatically to Metro PCS MMSC (via Nokia Implementation) - android

This is my first post so my apologies in advance if this is the wrong site to post this particular question to.
Question
I have integrated Nokia's MMS implementation for android (http://androidbridge.blogspot.com/2011/03/how-to-send-mms-programmatically-in.html) into an android application I am writing and I am able to send MMS's from my personal Metro PCS device to Metro PCS's MMSC and messages are delivered to any recipient without issue.
This is how I am sending the MMS:
public Boolean sendMMSMessage(final String senderNumber, final String smsText, final File imageFile, final Integer requestId){
byte[] out;
Enumeration keys;
//set image File
setImageFile(imageFile);
//create MMMessage
setMMMessage(new MMMessage());
//add text
addText(getMMMessage(),smsText,"<0>",IMMConstants.CT_TEXT_PLAIN);
//add image file
addFromFile(getMMMessage(),getImageFile(),"<1>",IMMConstants.CT_IMAGE_JPEG);
//set MMEncoder
setMMEncoder(new MMEncoder());
getMMEncoder().setMessage(getMMMessage());
//transaction ID (second parameter) is arbitrary
setMessage(getMMMessage(),"T135d743a6b7",senderNumber);
try {
getMMEncoder().encodeMessage();
out = getMMEncoder().getMessage();
setMMSender(new MMSender());
getMMSender().setMMSCURL("http://mms.metropcs.net:3128/mmsc");
//'min' of sending device. Required by Metro PCS MMSC.
getMMSender().addHeader("X-DEVICE-MIN", min);
setMMResponse(getMMSender().send(out));
} catch (Exception e) {
System.out.println(e.getMessage());
return false;
}
return (getMMResponse().getResponseCode()==IMMConstants.HTTP_RESPONSE_OK);
}
I am wondering if it is possible to 'tweak' Nokia's code (if this is necessary) such that any device can send a properly constructed MMS request to Metro PCS's MMSC using my 'min' credentials. I have studied the packet flow (via 'WireShark') of what occurs when an MMS is successfully sent from my particular device to other recipients however when I run this same android app. on another device (a non-Metro PCS device), MMS messages fail to send and 'WireShark' is not helpful in explaining why. Can anyone help lead me in the direction of how I might make this work?
Update: It may help to add that logcat reports:
java.net.SocketTimeoutException: Connection timed out
Second Update: I took a look at another post regarding this issue. It is titled "Android sending image via MMS programatically(Operation timed out)" but unfortunately there currently is not a definite answer and this question has been live for two months. I will try increasing the read 'timeout' as someone suggested (I doubt this is the cause) but if anyone DOES know what the problem might be but simply wishes not to provide a direct answer this is fine. I just need a hint of where to look.
Third Update: Now that I think about it, I wonder if the senders IP address (the actual IP address used by the device) constitutes a factor here. Can anyone confirm?
Fourth Update: I just took a closer look at the code for 'MMSender.java' (specifically at whats going on with the 'HttpURLConnection' object) and according to its setReadTimeout(ms) method, the default value ('0') establishes an infinite wait time anyways and this method is not called anywhere in the code. Just for kicks, however, I manually set this value to 1 minute for both setConnectionTimeout(ms) and setReadTimeout(ms) and as I suspected, no dice. Same connect timeout issue.
Final Update: Sorry. I just realized that I copied this line of code from another posting some time ago:
((ConnectivityManager)getSystemService(Context.CONNECTIVITY_SERVICE)).startUsingNetworkFeature(ConnectivityManager.TYPE_MOBILE,"enableSUPL");
and now after looking at this call more closely, I wonder if it is possible that I am supplying incorrect parameter values to startUsingNetworkFeature() (at least for the non-Metro PCS device I am trying the application on). I don't want to overkill my 'updates' here for this question but I want you guys (or gals) to be well informed so...; if these parameter values do turn out to be the problem, I will definitely post that fact but this will be my final update. In the mean time, any advice is greatly appreciated.

Related

NoRouteToHostException "Address not available"

In my Android app, I do poll a device (Wallbox) every 5 seconds using the Volley library. For one customer, I get
java.net.NoRouteToHostException: Address not available
after several hours. Usually, using the exactly same type of device and at my place, this polling works for days, but not at (at least) this customer.
The device address is on the local LAN.
I have not found any description about "address not available" that might apply to my case, or at least I did not see the point.
The call is always the same:
http://192.168.160.152/api/status
As this is live data, I set ".setShouldCache(false)" for the request.
Meanwhile, other HTTP requests (in this case, a query to a WWW address, also polled continuously), even using Volley, continue to work:
https://backend.powerfox.energy/api/2.0/my/***********/current
The connection works again after rebooting the device (and at the same original IP address), so I guess it has nothing to do with the wallbox or the router.
And if the wallbox would be not available, I assue I would get "unreachable" error or such.
Is there someone who can help me, what could cause that exception ("address not available"), and what can I do about it?

WebRTC Android, can't get what I should do?

I am working with WebRTC to make a basic video call application that works between two Android phones, I have been searching for about more than 10 days, I have understood everything regarding the Android side, but I really can't get it in the web side, signalling, TURN and STUN. Unfortunately I am not a web guy (at least not now) and I am very very confused about what to do about the servers setup. I don't even understand exactly when to use what and why. to make the story shorter what I need is:
I need a roadmap to continue in the servers setup.
thank you in advance.
UPDATE:
The backend has been implemented and it seems to be working cuz I receive voice without any problem, I also receive the MediaStream which contains both the video and the audio, but no video is being displayed.
private void gotRemoteStream(MediaStream stream) {
//we have remote video stream. add to the renderer.
Log.d("KingArmstring", "gotRemoteStream: 1 stream == null" + String.valueOf(stream == null));
Log.d("KingArmstring", "the value of the received stream: " + String.valueOf(stream));
final VideoTrack videoTrack = stream.videoTracks.get(0);
Log.d("TAG", "gotRemoteStream: we get here");
runOnUiThread(() -> {
try {
Log.d("TAG", "we get here");
remoteRenderer = new VideoRenderer(new VideoRenderer.Callbacks() {
#Override
public void renderFrame(VideoRenderer.I420Frame i420Frame) {
Log.d("TAG", "renderFrame: we get here");
}
});
remoteVideoView.setVisibility(View.VISIBLE);
videoTrack.addRenderer(remoteRenderer);
} catch (Exception e) {
e.printStackTrace();
}
});
}
I played around with webRTC on Android and web. I was able to make my own project with the help of these projects:
https://github.com/pchab/ProjectRTC
https://github.com/pchab/AndroidRTC
What I suggest is to run these projects. After you success doing it, you can try to change the code to meet with your needs. Now I will explain some details about TURN and STUN.
STUN - this is a way to know what is you real ip. If you use your phone with wifi, what will happen is that you will have ip like: 192.168.1.14. This is internal ip. Your real ip is something else. You need some server like google to tell you what is your real ip. Try typing on google search what is my ip and you will see it is different than what you see in the ifconfig.
TURN - This is a relay of the stream of voice/video data. What happen is some cellular carrier cut of the voice/video data for some reason, what you can do to overcome this is use TURN, you send the data to the TURN and it transfer this to the other side.
Signaling - this is a way 1 side calls the other side. lets say you have 2 guys that want to communicate, they need a way to send the communication data before the call starts. webRTC doesn't give you a mechanism. It gives you a json that you need 1 guy to send it to the second guy. The links I provided uses socket.io but there are other implementation like FCM. The data that travels is the first guy ip, the codacs that he wants to use, and things like that. The second guy needs to send the accept response and the voice call begins.
I have figured finally the problem, thanks to Uriel cuz his answer helped me a lot my answer can't stand alone, it can only be added to his answer. You can see that the remoteRenderer has been initialized this way:
remoteRenderer = new VideoRenderer(new VideoRenderer.Callbacks() {
#Override
public void renderFrame(VideoRenderer.I420Frame i420Frame) {
Log.d("TAG", "renderFrame: we get here");
}
});
(I have add that in the UPDATE in my qustion)
instead of that we should initialize it this way:
remoteRenderer = new VideoRenderer(remoteVideoView);
when I finish this part of the app, I will try to add a git repo for this webRTC part so that anyone can take advantage of using any part of it.

Android communicating to HFP device via AT commands

im trying to control a bluetooth bracelet with vibration function via HFP (hands free profile) in Android. I've been able to connect to the bracelet and access the input- and outputstream.
My goal is to simulate an incoming call so that the bluetooth bracelet starts vibrating (which seems to be the only way to do that). To do this, im using AT commands. In the bluetooth specs at https://www.bluetooth.org/docman/handlers/downloaddoc.ashx?doc_id=238193 on page 22 you can see the handshake to establish service level connection.
I need to establish this connection to use the "+CIEV" command (see handshake page 48).
But when my bracelet returns the command "AT+CIND=?" I dont know how to respond. I can't find any hints on how to answer with the "CIND:" command. Also I dont know how to send the acknowledgement (is it just "OK"?).
That might even be the completely wrong way to do this. Every suggestion is appreciated. I only found one post on stackoverflow that helped me in some way, rest of the posts I found were unanswered.
By the way, im using a smartphone with Android 4.1.2. The bracelet supports HFP and HSP. Thanks in advance.
UPDATE 10/29/2014
===== Connection through RFCOMM Socket established at this point =====
// read AT+BRSF=0 from device
byte[] buffer = new byte[200];
mBluetoothSocket.getInputStream().read(buffer);
Log.d(TAG, new String(buffer).trim());
//write answer BRSF: ...
mBluetoothSocket.getOutputStream().write("+BRSF=20\r".getBytes());
mBluetoothSocket.getOutputStream().write("OK\r".getBytes());
// read AT+CIND=? command
buffer = new byte[200];
mBluetoothSocket.getInputStream().read(buffer);
Log.d(TAG, new String(buffer).trim());
//write answer CIND: ...
mBluetoothSocket.getOutputStream().write("+CIND: (\"battchg\",(0-5)),(\"signal\",(0-5)),
(\"service\",(0,1)),(\"call\",(0,1)),(\"callsetup\",(0-3)),
(\"callheld\",(0-2)),(\"roam\",(0,1))".getBytes());
mBluetoothSocket.getOutputStream().write("OK".getBytes());
// read AT+CIND?
buffer = new byte[200];
mBluetoothSocket.getInputStream().read(buffer);
Log.d(TAG, new String(buffer).trim());
Following the procedure of the protocol, I should receive the "AT+CIND?" command and then I could send the command "+CIND: 5,5,1,0,0,0,0", but...I dont receive the "AT+CIND?" command. Actually im not receiving anything. Am I missing something? Sending an "OK" doesnt change anything btw...
I was fiddeling with exaclty the same problem. After days of trial and error, I finally got it to work.
I think it depends on the speed at wich you answer the HF's commands, as well as on the correct line-endings ("COMMAND").
Here is my DroidScript which works. It's not cleaned up, but it works.
https://gist.github.com/t-oster/68a568ac4c4e133f67ac
Also, the one example I found that seemed to almost work, it's expecting the responses to be top and tailed with crlf:
"\r\n+BRSF=20\r\n"
"\r\nOK\r\n"
Still struggling with the rest of it myself.
refer to bluetooth hfp 1.5 spec in which you can understand CIEV response
normally when not in any call setup, response can be +CIND = 1,0,0,0,5,0,5
Note these values are based on the hfp spec, on incoming call return +CIEV: ,
ind- indicator for callsetup and value as 1 and then RING commands to the bracelet

IMEI Number on non-network devices

I'm currently working on an application where the code uses the device IMEI number as a variable to store something in the DB. We need to see what device the reading originated from.
ie:
String IMEI = telephonyManager.getDeviceId();
However, I'm not sure how this will behave on phones without network access, such as a wifi only tablet. Will is return a unique value? Will it return null?
I know there are alternatives to using IMEI, and I don't need any explanation on what alternative values I can use. I only need to know what will happen when I call this on a phone with no network access. Please do not provide suggestions on alternative IDs or anything other than what I have asked. I appreciate you taking the time to read this question.
Thanks,
-Mark
You get null.
Just ran into this on an app I wrote 3 years ago, and only just converted to tablet format. I had forgotten we were using IMEI (against the advice you and I both received ;-) ) and we started sending a whole bunch of null device IDs to the server.
Sadly it took a whole lot of network logs before I tracked it down to that little hack.

Getting Wi-fi network response time on android

I want to get an access point response time.
I notice that last API has a public long timestamp in class ScanResult.
Unfortunately, I want something that can run over 2.3+.
It's possible to get the "Probe Response" packet of an access point? And so getting the complete packet information, like time, etc.?
I've searched over SO and googled a lot, but I've not found a simple way to send a custom packet over network, or how to receive it.
I would appreciate any hints!
Thank you

Categories

Resources