Unable to find loaction using Blackberry 8520 4.6.2 version phone - gps

Here is the code i am using to get the location
Criteria criteria = new Criteria();
criteria.setHorizontalAccuracy(Criteria.NO_REQUIREMENT);
criteria.setVerticalAccuracy(Criteria.NO_REQUIREMENT);
criteria.setCostAllowed(true);
criteria.setPreferredPowerConsumption(Criteria.POWER_USAGE_LOW);
try {
LocationProvider lp=LocationProvider.getInstance(criteria);
if(lp !=null)
{
Location loc=null;
loc=lp.getLocation(-1);
if(loc!=null)
add(new EditField(loc.getQualifiedCoordinates().getLatitude()+"\n"+loc.getQualifiedCoordinates().getLongitude(),""));
else
add(new EditField("no location found",""));
}
else
{
add(new EditField("unable to find the location provider", ""));
}
} catch (LocationException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (Exception e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
This code was working well when used in a Blackberry Curve 8520 5.0 version, but when I installed this code on a Blackberry Curve 8520, it is showing a blank screen.
I also tried to debug it through USB debugging. This is the result:
[0.0] Starting version4_0
[0.0] Started version4_0(216)
[0.0] Foreground version4_0(216)
[0.0] VM:+GC(f)w=11
[0.0] VM:-GCt=63,b=1,r=0,g=f,w=11
[0.0] VM:+CR
[0.0] VM:-CR=39
[0.0] VM:+GC(f)w=30
[0.0] VM:-GCt=40,b=0,r=0,g=f,w=30
[0.0] VM:+CR
[0.0] VM:-CR=0
[0.0] VM:+GC(f)w=30
[0.0] VM:-GCt=36,b=0,r=0,g=f,w=30
[0.0] VM:+CR
[0.0] VM:-CR=0
[0.0] VM:+GC(f)w=30
[0.0] VM:-GCt=35,b=0,r=0,g=f,w=30
[0.0] VM:+CR
[0.0] VM:-CR=0
Can anyone please tell why my 4.6 version of black berry is not working?

Which carrier? It matters when you try to get Cellsite based location.
Are you getting an exception? Are you getting a location with invalid coordinates? You can put all that information in popups so you can see it on device.

Related

How to avoid timeout (net::ERR_HTTP2_PING_FAILED 8mins) when uploading files with axios post method?

I'm doing some big file (10GB+) uploading so what I did is slicing the file to some 3MB chunks and then upload them. It works fine until I got a really bad network scenario (cannot finished uploading a chunk with 8mins). The browser(chrome) gave me an net::ERR_HTTP2_PING_FAILED error and after checking on the Internet it basically means timeout. I changed timeout setting for this api in Nginx to 99999, it will not give me 504 error (meaning nginx didn't cut the connection because of timeout) but the maximum time for me to upload a slice is 8mins. I think this problem is caused by browser itself so I checked the browser concole. The thing is the network page shows that "uploadSlice " used 8mins to initial connection! But the progress bar still going so I have no idea how to solve this.
Here is that error screenshot:
enter image description here
Here is my code for the upload slice part. (I use axios and a post method to send chunk)
request(formData,cancel) {
let uid = formData.get("uid");
let lastLoad = 0;
//formData contains file's chunk and other info
return this.$http.post("/file/uploadSlice", formData, {
headers: { "Content-Type": "multipart/form-data" },
//this part is using for progress bar calculation
onUploadProgress: (progressEvent) => {
let loadThisTime = progressEvent.loaded - lastLoad;
lastLoad = progressEvent.loaded;
this.$store.dispatch("updateState/addCompleteNessAsync",[uid,loadThisTime]);
},
cancelToken: cancel
});
},
And here is my setting for this api in Nginx:
(in default.conf)
location /api/file/uploadSlice {
proxy_pass http://172.17.0.1:9090/file/uploadSlice/;
proxy_set_header X-Forwarded-Proto $scheme;
proxy_set_header X-Forwarded-Protocol $scheme;
proxy_read_timeout 99999;
proxy_connect_timeout 99999;
proxy_send_timeout 99999;
}
in nginx.conf:
...
http{
...
keepalive_timeout 65;
client_max_body_size 50m;
client_body_buffer_size 5m;
client_header_timeout 120s;
...
include /etc/nginx/conf.d/*.conf;
}

Sending POST Json to API using Arduino Mega and Ethernet shield W5100

Having this as my sketch, the serial monitor saying that the JSON is successfully sent. But it does not reflect to my Cloud DB.
I changed my HTTPS to HTTP but no luck. Where could this go wrong?
My objective is all input in my Arduino will be sent to my server and store to my Cloud DB.
EDIT: After replacing all suggested Edits, I am getting 400 Bad request.
In Postman, the request is working so i know that my request is valid. But I can't make it work in arduino using ethernet shield
void setup() {
Serial.begin(9600);
// initialize the Ethernet shield using DHCP:
if (Ethernet.begin(mac) == 0) {
Serial.println("Failed to obtaining an IP address using DHCP");
while(true);
}
delay(1000);
Serial.println("connecting...");
if (client.connect(HOST_NAME, HTTP_PORT)) {
Serial.println("connected");
} else {
Serial.println("connection failed");
}
//Create JSON doc and write a "name" attribute
const size_t capacity = JSON_OBJECT_SIZE(3);
DynamicJsonDocument doc(capacity);
doc["tank_id"] = "2a";
doc["branch_name"] = "aurora";
doc["water_level"] = "high level";
//POST request
Serial.println("Begin POST Request");
client.println("POST /myURL HTTP/1.1");
Serial.println("POST /myURL HTTP/1.1");
client.println("Host: host.net");
Serial.println("Host: host.net");
client.println("User-Agent: Arduino/1.0");
Serial.println("User-Agent: Arduino/1.0");
client.println("Content-Type: application/json");
Serial.println("Content-Type: application/json");
client.println("Connection: keep-alive");
Serial.println("Connection: keep-alive");
client.print("Content-Length: ");
Serial.print("Content-Length: ");
client.println(measureJson(doc));
Serial.println(measureJson(doc));
client.println();
Serial.print(F("Sending: "));
serializeJson(doc, Serial);
Serial.println();
//This works like client.println, but prints doc to client
serializeJsonPretty(doc, client);
//To let me know that request has been completed
Serial.println("Sent POST Request");
while (client.available()) {
char c = client.read();
Serial.print(c);
}
}
void loop() {
while(client.connected()) {
if(client.available()){
// read an incoming byte from the server and print it to serial monitor:
char c = client.read();
Serial.print(c);
}
}
}
I had exactly the same issue... after hours and hours of trying different codes, I found the problem:
serializeJsonPretty(doc, client);
This code, prints this:
POST /api/ HTTP/1.1
Host: api.xxxxxxx.com
Content-Type: application/json
Connection: close
Content-Length: 63
->
-> {
-> "data": "2a",
-> "branch_name": "aurora",
-> "water_level": "high level"
-> }
But, if you change to serializeJson(doc, client); you'll send an HTTP like this:
POST /api/ HTTP/1.1
Host: api.xxxxxxx.com
Content-Type: application/json
Connection: close
Content-Length: 63
->
-> {"data":"2a","branch_name":"aurora","water_level":"high level"}
I understood that the problem is to send the data in each line.. for me, changing data for only one line, the problem is gone.
I hope to help!

WebRTC to Gstreamer Bridge

I'm trying to stream audio from a browser to a gstreamer pipeline on a server.
I'm currently using Kurento, and modifying the Hello World example to try to connect an RTP Endpoint to the pipeline -- but am having trouble.
I know the media is getting there because when I swap in a Recording Endpoint, I get a valid recording.
The Kurento Node JS is:
pipeline.create("RtpEndpoint", {}, function(error, rtpEndpoint) {
if (error) {
console.log("Recorder problem");
return sendError(res, 500, error);
}
console.log("Creating WebRtcEndpoint");
pipeline.create('WebRtcEndpoint', function(error, webRtcEndpoint) {
if (error) {
return sendError(res, 500, error);
}
console.log("Processing sdpOffer at server and generating sdpAnswer");
webRtcEndpoint.processOffer(sdpOffer, function(error, sdpAnswer) {
if (error) {
webRtcEndpoint.release();
return sendError(res, 500, error);
}
console.log("Connecting loopback");
webRtcEndpoint.connect(webRtcEndpoint, function(error) {
if(error){
webRtcEndpoint.release();
return sendError(res, 500, error);
}
console.log("Sending sdpAnswer to client");
console.log(sdpAnswer);
webRtcEndpoint.connect(rtpEndpoint, function(error) {
if(error) {
webRtcEndpoint.release();
return sendError(res, 500, error);
}
rtpEndpoint.generateOffer(function(error, offer) {
fs.writeFile('/tmp/test.sdp',offer);
console.log("RTP OFFER GENERATED.");
});
});
res.type('application/sdp');
res.send(sdpAnswer);
});
});
});
});
and my GStreamer pipeline is:
gst-launch-1.0 -vvvv filesrc location=/tmp/test.sdp ! sdpdemux ! decodebin ! autovideosink
which returns
Setting pipeline to PAUSED ...
Pipeline is live and does not need PREROLL ...
Got context from element 'autovideosink0-actual-sink-glimage': gst.gl.GLDisplay=context, gst.gl.GLDisplay=(GstGLDisplay)"\(GstGLDisplayX11\)\ gldisplayx11-0";
Setting pipeline to PLAYING ...
New clock: GstSystemClock
/GstPipeline:pipeline0/GstSDPDemux:sdpdemux0/GstUDPSrc:udpsrc0: timeout = 10000000000
/GstPipeline:pipeline0/GstSDPDemux:sdpdemux0/GstUDPSrc:udpsrc2: timeout = 10000000000
/GstPipeline:pipeline0/GstSDPDemux:sdpdemux0/GstRtpBin:rtpbin0/GstRtpSession:rtpsession0.GstPad:send_rtcp_src: caps = application/x-rtcp
/GstPipeline:pipeline0/GstSDPDemux:sdpdemux0/GstRtpBin:rtpbin0.GstGhostPad:send_rtcp_src_0: caps = application/x-rtcp
/GstPipeline:pipeline0/GstSDPDemux:sdpdemux0/GstUDPSink:udpsink0.GstPad:sink: caps = application/x-rtcp
/GstPipeline:pipeline0/GstSDPDemux:sdpdemux0/GstRtpBin:rtpbin0.GstGhostPad:send_rtcp_src_0.GstProxyPad:proxypad4: caps = application/x-rtcp
/GstPipeline:pipeline0/GstSDPDemux:sdpdemux0/GstRtpBin:rtpbin0/GstRtpSession:rtpsession1.GstPad:send_rtcp_src: caps = application/x-rtcp
/GstPipeline:pipeline0/GstSDPDemux:sdpdemux0/GstRtpBin:rtpbin0.GstGhostPad:send_rtcp_src_1: caps = application/x-rtcp
/GstPipeline:pipeline0/GstSDPDemux:sdpdemux0/GstUDPSink:udpsink1.GstPad:sink: caps = application/x-rtcp
/GstPipeline:pipeline0/GstSDPDemux:sdpdemux0/GstRtpBin:rtpbin0.GstGhostPad:send_rtcp_src_1.GstProxyPad:proxypad7: caps = application/x-rtcp
ERROR: from element /GstPipeline:pipeline0/GstSDPDemux:sdpdemux0: Could not read from resource.
Additional debug info:
gstsdpdemux.c(1213): gst_sdp_demux_handle_message (): /GstPipeline:pipeline0/GstSDPDemux:sdpdemux0:
Could not receive any UDP packets for 10.0000 seconds, maybe your firewall is blocking it.
Execution ended after 0:00:10.062018001
Setting pipeline to PAUSED ...
Setting pipeline to READY ...
Setting pipeline to NULL ...
Freeing pipeline ...
It doesnt work on FFPMEG, VLC, etc -- results are similar to "Attempt 5.3" here: https://altanaitelecom.wordpress.com/2015/02/26/continue-streaming-broadcasting-live-video-call-to-non-webrtc-supported-browsers-and-media-players/
I don't think theres a firewall issue as the pipeline and kurento instance are on the same virtual machine (which has no firewall) -- and the recording endpoint works. Is it being linked badly? Is there an easier way?
Using RtpEndpoint is tricky because you need to complete de SDP negotiation. This means that somewhere after the
rtpEndpoint.generateOffer(...
you should be invoking
rtpEndpoint.processAnswer(sdpAnswer, ...)
The tricky part is that you need to obtain the sdpAnswer from your gstreamer pipeline and this is not trivial if you want to it just using gst-launch. Probably your best option is to write a small programm creating the pipeline and generating the sdpAnswer so that you can give it back to the rtpEndpoint through your signaling mechanism.

Intellij doesn't display some of my logs in the debugger

All of my log statements appear in adb logcat, but two of them don't appear in Intellij Logcat. Why?
Log.i(TAG, "in the long click");
CommentViewHolder commentViewHolder = (CommentViewHolder) view.getTag();
Log.i(TAG, "got the comment holder");
addRequest(mAppController.deleteComment(mPostId,
commentViewHolder.comment_id));
Log.i(TAG, "added the request");
return true;
This is the output in the Intellij Logcat using the "All messages" filter:
05-22 20:14:30.723: INFO/rose_tag(24319): in the long click
This is the output using adb logcat:
I/rose_tag(24319): in the long click
I/rose_tag(24319): got the comment holder
I/rose_tag(24319): added the request

didReceiveRemoteNotification not getting invoked

I am creating app in iOS/android. When a remote notification is received in the device, didReceiveRemoteNotification should get called. But it is not happening. My server side code for sending msg through APNS is as under:
$deviceToken = $obj_listener->ref_id;
// Put your private key's passphrase here:
$passphrase = 'blahblah';
$ctx = stream_context_create();
stream_context_set_option($ctx, 'ssl', 'local_cert', '/var/www/mobileapp/TestAppCK.pem');
stream_context_set_option($ctx, 'ssl', 'passphrase', $passphrase);
// Open a connection to the APNS server
$fp = stream_socket_client(
'ssl://gateway.sandbox.push.apple.com:2195', $err,
$errstr, 60, STREAM_CLIENT_CONNECT|STREAM_CLIENT_PERSISTENT, $ctx);
if (!$fp){
$this->log->debug("Failed to connect: $err $errstr" . PHP_EOL);
exit("Failed to connect: $err $errstr" . PHP_EOL);
}
$badge_count = $obj_listener->badge_count + 1;
// Create the payload body
$body['aps'] = array(
//'alert' => 'Message received',
'sound' => 'default',
'badge' => $badge_count,
'msg_id' => $this->msg_id,
//'user_key' => $obj_listener->ref_id,
'email' => $obj_listener->to_email_id
);
// Encode the payload as JSON
$payload = json_encode($body);
// Build the binary notification
$msg = chr(0) . pack('n', 32) . pack('H*', $deviceToken) . pack('n', strlen($payload)) . $payload;
// Send it to the server
$result = fwrite($fp, $msg, strlen($msg));
// Close the connection to the server
fclose($fp);
My objective-c side code is as under:
- (void)application:(UIApplication *)application didReceiveRemoteNotification:(NSDictionary *)userInfo{
//UIWebView *NewWebView = NULL;
NSLog(#"didReceiveRemoteNotification function");
return;
}
I have checked for the device token in the server side code. It is correct for the device.
Why is the above function not getting called. Thanks in advance.
If you don't register for notifications at your app start, they will never be received.
[[UIApplication sharedApplication] registerForRemoteNotificationTypes:(UIRemoteNotificationTypeAlert | UIRemoteNotificationTypeBadge |UIRemoteNotificationTypeSound)];
Now, about your server side, I suggest you run your code in debug mode and see if Apple's gateway is being properly reached through SSL. A simple bad cert or lack of it can take you away days of work. Personal experience.
If Application is not in background you should use following code
//-------------- check notification when app is come to foreground after apllication get terminated ----------------//
UILocalNotification *localNotif =
[launchOptions objectForKey:UIApplicationLaunchOptionsRemoteNotificationKey];
if (localNotif) {
[self handleRemotNotification:[launchOptions valueForKey:#"UIApplicationLaunchOptionsRemoteNotificationKey"]]; // private method
}