Unable to connect to internet in Blackberry device? - java

I am developing an app where i am using browser field to load html files in it. My code is as follows.
Main.java
//pushing screen to browser field page..
public Main()
{
// Push a screen onto the UI stack for rendering.
pushScreen(new WebViewController());
}
WebViewController.java
BrowserFieldConfig bfConfig = new BrowserFieldConfig();
bfConfig.setProperty(BrowserFieldConfig.NAVIGATION_MODE,
BrowserFieldConfig.NAVIGATION_MODE_POINTER);
bfConfig.setProperty(BrowserFieldConfig.JAVASCRIPT_ENABLED,
Boolean.TRUE);
bfConfig.setProperty(BrowserFieldConfig.ALLOW_CS_XHR, Boolean.TRUE);
bfConfig.setProperty(BrowserFieldConfig.INITIAL_SCALE, new Float(0.0));
bwf = new BrowserField(bfConfig);
add(bwf);
UiApplication.getUiApplication().invokeLater(new Runnable() {
public void run() {
// TODO Auto-generated method stub
bwf.requestContent("local:///html/index.html");
}
}, 500, false);
All my server code & UI design is in javascript & html pages respectively which invokes from index.html page...
As per the following code it is working(executing) in simulator & getting data from server during runtime. But when i am running in BlackBerry device only UI design is loading from index.html page but not getting the data from server. I am not getting any idea whats the error is.
I enabled javascript in Blackberry device also but still it is not working..
As i am new to this blackberry developing, unable to find whats there problem with my app while running in Blackberry device.
As per the following code should i have to add any external code to get data from server (like just to access internet in Blackberry device after signing)
In simulator it is working good & getting data from server. When executing in Blackberry device only main page UI (UI in index.html) is loading but not getting data from server.
Can anyone help me with this.....

This question is variation of questions "Why I have issues with connection on the BlackBerry". I'll try to give you idea how to solve them.
The network connection is much complex unlike j2me, android or iphone connection where you mostly ask system to open TCP/HTTP/UDP connection. RIM introduced Network Transports. I'm not sure about reasons - or they wanted to give developer power to select specific transport, or because BES admins/Carriers could restrict some connections, or other reasons. But side effect that BB developer has to specify which transport he wants to use for current connection on the device. The dramatic thing that default connection is Direct TCP (through the APN carrier settings). And direct TCP works perfect on simulators. But most used connection on the BB devices are BIS-B and WiFi. Also BIS-B was unavailable for usual developer before and they just opened it for everyone recently.
Before 5.0 OS developer had huge amount of code to determine what transports are available on the device and there was loop by transports trying to open in in order.
RIM introduced ConnectionFactory in 5.0 OS which provides standard mechanism to open determine available transports and open the connection (example).
You always have to use ConnectionFactory where you want to open connection. It doesn't matter if you reach remote host directly through Connector or through BrowserField. You have to use ConnectionFactory.
Dramatic thing is that even if you use it you can't reach BIS-B transport. As I mentioned before it was available only for alliance members. RIM doesn't restrict using of BIS-B for any developers right now. But I don't see that they also give any example. To allow ConnectionFactory to open BIS-B you need next line:
connFact.setTransportTypeOptions(TransportInfo.TRANSPORT_BIS_B,
new BisBOptions("mds-public"));
This is just small summary of connections on the BlackBerries. But it should give you right direction to solve your problem.

Related

How to get and set values from a UPS device using SNMP?

I have a java web application running in my workplace.
I was asked to create a new application to "communicate" with network devices and read their statuses.
As an example I started working with a UPS, which is connected to my network with its own Network Interface Card.
I can monitor its status and details with its built-on platform entering with its IP address on a browser. But the idea is to add some of these details to the original web application.
To my understanding I can use a SNMP library for Java and create an application to get and set values to it. In my case i'm using the SNMP4j(V3) library, I imported it to Eclipse (IDE), but have no idea on how to continue from there really.

Push notification using atmosphere

I am using Atmosphere RC 2.4.5(java 1.8, jsp, tomcat 8, and javascript Atmosphere client) for pushing messages from server to the clients. Everything works as expected, and didn't have any trouble with the implementation of it, but now I have doubt about the next thing:
I implemented a feature where admin user can send some notification to all users currently using the app. But if in that exact time while the message was pushing through web sockets, some user clicked link and started navigation to another page. His web socket would be closed and he would never get the message.
Does anyone know how this can be achieved using the atmosphere, so no messages would be lost.
Thanks all.
You can find your solution based on this page from documentation of atmosphere-js :
Sharing connection between Browser's windows and tabs
By default, the atmosphere.js library will open a new connection (based on the available transports: websocket, long-polling, streaming, sse, jsonp or ajax) every time a new window or tab is opened by the Browser. In some case it may be more efficient to share a connection between windows/tabs. To enable the mechanism, all you need to do is to set the shared property of an AtmosphereRequest object:
Here's example :
var request = new $.atmopshere.AtmosphereRequest();
request.shared = true;
request.transport = 'websocket'
$.atmosphere.subscribe(request);
One of these lines can be the solution of your problem :
request.shared = true;

Need to call from jxfs client to jxfs server

I am very new to jxfs things. I have a requirement to call jxfs server which is in cloud server from the jxfs client which is in ATM environment.. How can i call?.. I need to call this one through the Jxfs RMI concept. It would be appreciated one if any example code is available. If atleast you are having code for calling from jxfs server to jxfs client, please post it.
Thanks in advance guys.
One of the interesting things about J/XFS and remote device access (based on RMI) is that it is just matter of configuration.
You need to configure a J/XFS repository in order to handle a remote device (basically set 'remoteAccess' to true).
Then accessing these devices from the programming point of view is just the same as they were local devices.
Architecture is explained here: ftp://ftp.cencenelec.eu/CWA/CEN/WS-J-XFS/cwa14923/cwa14923-01-2004-May.pdf
Details, when programming may differ depending on the J/XFS implementation you are using.
Trying to answer your question below:
Whenever you want to access a device remotely in J/XFS, RMI is used. You need to make the following setup:
On a server (should be accessible) you need to start a JxfsServer. The JxfsServer will use a Read.repository
whith all the ATM's and devices configured on them as workstations, with the right IP addresses.
On the ATM, you need to install:
J/XFS libs
J/XFS device services for the devices on the ATM
Setup the DSstarter:
Will use the SpecificDeviceManagerRMI connecting to the JxfsServer you started before.
On your server (cloud) wherever you are going to use the J/XFS client you can get the remote controls by performing
the J/XFS initialization as follows:
jxfsDM_ = JxfsDeviceManager.getReference();
jxfsDM_.initialize("com.jxfs.forum.communication.rmi.SpecificDeviceManagerRMI,<atmWorkstation>,AppTest,2006;<jxfsserverhostname>,");
Then you can get the remote device controls with getDevice(...), and start using them as if they were local devices.
Please, note that handling RMI ports can be tricky, specially in a secured environment as ATM network. Make sure all the ports you need are open.

Push message to AIR app from Java Server

I am looking for solutions for a problem that we are facing. We are planning to make a POC for Desktop Alert application. We will have a desktop AIR app that will connect to a Java Server. The server will need to notify Desktop App when it has a notification which will be displayed on the screen.
A couple of options that we have discovered are :
1. Keep a persistent connection between the AIR app and the Server, using some sockets and listen to any changes.
2. Poll the Server at intervals to check if some new data has come.
Since these options don't seem optimal (persistent connection) or seems performance wise (polling) better.
Is there a better solution for this problem or do we have to choose one of these?
For this, you could use a BlazeDS message service if you want to push messages to your client. Or a regular remote service with polling enabled.
It is built in out of the box and well tested equipment :)
Other technologies like GraniteDS or WebOrb for java are also possibilities.
Cheers

Android Bluetooth - Can't connect out

I am developing an application which uses Bluetooth to connect to a device and send/receive data. I am doing all of my testing with a Nexus One phone.
I have never been able to establish a SPP (serial port) connection from my phone to any device. However, I have been able to connect from a device (my laptop) to my phone using a Mac equivalent of PuTTY (The only exception to this is the "Bluetooth File Transfer" app from the Marketplace seems to work, but I don't think that uses RFCOM/SPP...).
I keep seeing this message in my LogCat logs:
ERROR/BluetoothService.cpp(78): stopDiscoveryNative: D-Bus error in StopDiscovery: org.bluez.Error.Failed (Invalid discovery session)
as well as these:
java.io.IOException: Operation Canceled
java.io.IOException: Software caused connection abort
I have tried using the UUID of "00001101-0000-1000-8000-00805F9B34FB" and I have also tried using the:
Method m = device.getClass().getMethod("createRfcommSocket", new Class[] { int.class });
sock = (BluetoothSocket) m.invoke(device, Integer.valueOf(1));
method instead of device.createRfcommSocketToServiceRecord(UUID); as well--with no luck.
I am using the BluetoothChat example and variations of that code to do all of my testing...
Solutions or suggestions would be great...or even a better/less complex example of some testing code I can run on the phone, or a python script or something I can run on my computer to help debug?
Thanks! I hope this isn't a bug with the Android OS, but if it is I hope to find a workaround.
EDIT: I should also note that most devices show up as "paired, but not connected" in the Bluetooth settings.
EDIT 2: The solution seems to be simply disabling any Bluetooth listening. See my answer post for more information.
The solution, as it turns out, was to disable the server functionality of the Bluetooth service. By only using createRfcommSocketToServiceRecord and never calling listenUsingRfcommWithServiceRecord (in the BluetoothChat example this means never starting the "AcceptThread") the problem was fixed.
Even though these two calls are supposed to be totally separated and have no affect on each other (according to the Android docs), simply commenting out listenUsingRfcommWithServiceRecord fixed my supposedly unrelated issue.
I can take the Bluetooth Chat program unedited and it will not be able to establish an outgoing connection to ANY bluetooth device I have tested (laptops, desktops, headsets, etc.), but if I remove that one thing it works flawlessly as a client.
Anyway, I hope this will help someone else if they come across the same issue. This must be a bug with the Android OS, or possibly the firmware on the Nexus One.
I would ignore the stopDiscovery error - its good that you're cancelling discovery before making your connection. Per the SDK docs:
Because discovery is a heavyweight
precedure for the Bluetooth adapter,
this method should always be called
before attempting to connect to a
remote device with connect().
Discovery is not managed by the
Activity, but is run as a system
service, so an application should
always call cancel discovery even if
it did not directly request a
discovery, just to be sure.
So with that said, were you able to get the Bluetooth Chat example to work before you made any modifications to the code?
The UUID you want for SPP/RFCOMM is:
static UUID UUID_RFCOMM_GENERIC = new UUID(0x0000110100001000L,0x800000805F9B34FBL);
or defined another way (both accomplish the same thing).
static final UUID UUID_RFCOMM_GENERIC = UUID.fromString("00001101-0000-1000-8000-00805F9B34FB");

Categories

Resources