Hello!
Below is the Netbeans Mobility source code for my application (The application offers SPP service, and then just hangs waiting for a client to connect (using acceptAndOpen() ). The other device (A7 Engineering's eb506 Bluetooth serial adapter connected to a microcontroller ) connects to the phone, but is not linked to my application).
If I make the connection directly from the phone (Nokia 6085) to the eb506, there is no problem connecting and transmitting data - the problem arises when trying to connect from the eb506 to the phone. It is necessary for my application that I connect from the eb506 to the Java server application. Can anyone offer any insight as to why my application is not connecting to the incoming SPP connection from the other device (this is handled in the setupConnection s() method). I've been trying down the path of modifying the ServiceRecord with no positive results.
Thanks for your help (If you can help).
Sincerely,
Brum - import java.io.*;
-
-
import javax.microedition.midlet.*;
-
import javax.microedition.lcdui.*;
-
import javax.microedition.io.*;
-
import javax.bluetooth.*;
-
-
/**
-
* @author Brum
-
*/
-
public class prjMIDlet
-
extends MIDlet implements javax.microedition.lcdui.CommandListener
-
{
-
private Alert safetyAlert = null;
-
private Command mExitCommand = new Command("Exit", Command.EXIT,1);
-
-
StreamConnectionNotifier notifier = null;
-
LocalDevice prjCellPhone = null;
-
DataInputStream input;
-
UUID myService = new UUID("1101",true);
-
String myMIDlet = this.getClass().getName();
-
String filter = "*";
-
-
public void startApp() {
-
initialize(); // Initialize the safetyAlert interface
-
-
try {
-
input = setupConnections(); // Connect the cell phone to the eb506 (create input stream from other device)
-
} catch (BluetoothStateException ex) {
-
ex.printStackTrace();
-
} catch (ClassNotFoundException ex) {
-
ex.printStackTrace();
-
} catch (IOException ex) {
-
ex.printStackTrace();
-
}
-
Display.getDisplay(this).setCurrent(safetyAlert); // display the Alert
-
-
-
try {
-
do {
-
safetyAlert.setString(getMessage(input)); // get incoming message and put it into safetyAlert
-
Display.getDisplay(this).setCurrent(safetyAlert); // display the Alert with the new message
-
} while ((safetyAlert.getString()).length() > 1); // with only a carraige return, no more messages
-
} catch (IOException ex) {
-
ex.printStackTrace();
-
}
-
-
-
try {
-
PushRegistry.registerConnection(new String("btspp://localhost:"
-
+ myService.toString()), myMIDlet, filter); // Register this connection in the PushRegistry for auto start-up
-
} catch (ClassNotFoundException ex) {
-
ex.printStackTrace();
-
} catch (IOException ex) {
-
ex.printStackTrace();
-
}
-
-
// This next section will set the Alert to display the registered PushRegistry connections
-
String[] connectionList = PushRegistry.listConnections(false);
-
int listcount = connectionList.length;
-
StringBuffer connlist = new StringBuffer("Connections (# = "+listcount+"):");
-
while(listcount > 0){
-
connlist.ensureCapacity(connlist.length()+30);
-
connlist.append(connectionList[listcount-1]);
-
listcount--;
-
}
-
safetyAlert.setString(new String(connlist));
-
Display.getDisplay(this).setCurrent(safetyAlert); // display the Alert
-
-
}
-
-
private void initialize() {
-
-
safetyAlert = new Alert("Incoming message: ", "Please Wait...",null,null);
-
safetyAlert.setTimeout(Alert.FOREVER);
-
safetyAlert.addCommand(mExitCommand);
-
safetyAlert.setCommandListener(this);
-
return;
-
}
-
-
public DataInputStream setupConnections() throws BluetoothStateException, IOException, ClassNotFoundException {
-
-
prjCellPhone = LocalDevice.getLocalDevice();
-
-
prjCellPhone.setDiscoverable(DiscoveryAgent.GIAC);
-
notifier = (StreamConnectionNotifier)Connector.open("btspp://localhost:" + myService.toString());
-
-
safetyAlert.setString("waiting for connection");
-
Display.getDisplay(this).setCurrent(safetyAlert); // display the Alert
-
-
/* This next line is where the application stalls, waiting for a client
-
* to connect. I connect with my other device and it is able to connect
-
* to the phone, but is not linked to this application */
-
StreamConnection sconn = notifier.acceptAndOpen();
-
-
/* If I connect with this section of code instead, (connect from phone
-
* directly to my other device), there is no problem with transmitting
-
* data (But the application does not auto-start when the incoming SPP
-
* connection occurs.
-
DiscoveryAgent prjAgent = prjCellPhone.getDiscoveryAgent();
-
String connString = prjAgent.selectService(myService, ServiceRecord.NOAUTHENTICATE_NOENCRYPT, false);
-
StreamConnection sconn = (StreamConnection)Connector.open(connString);
-
input = sconn.openDataInputStream();*/
-
-
-
safetyAlert.setString("client device connected");
-
Display.getDisplay(this).setCurrent(safetyAlert); // display the Alert
-
return sconn.openDataInputStream();
-
}
-
-
-
/* This method gets an ASCII message from the input stream and converts it
-
* to a UniCode string and returns the Unicode string */
-
public String getMessage(DataInputStream d) throws IOException {
-
-
StringBuffer strBuff = new StringBuffer();
-
char store = 0;
-
int count = 0;
-
-
while (count < 32) { // maximum message length is 32 characters
-
count++;
-
store = (char) d.readByte(); // read the next byte of the stream and store as a char
-
if (store == 0x000D)
-
break;
-
strBuff.append(store);
-
}
-
return strBuff.toString();
-
}
-
-
-
public void pauseApp() {
-
}
-
-
public void destroyApp(boolean unconditional) {
-
}
-
-
public void commandAction(javax.microedition.lcdui.Command command, javax.microedition.lcdui.Displayable displayable) {
-
if (displayable == safetyAlert) {
-
if (command == mExitCommand) {
-
Display.getDisplay(this).setCurrent(null);
-
destroyApp(true);
-
notifyDestroyed();
-
}
-
}
-
}
-
}
-
0 2417 Sign in to post your reply or Sign up for a free account.
Similar topics |
by: Wole |
last post by:
I'm working on a project that requires a Web GUI connected to a server
backend application. When a user clicks a button on the GUI the Web
client sends a message to the server application which updates a
database and notifies all Web clients on the LAN that the button has
been pressed. This is the simpliest form of the system which I would
then develop into a complete application. I plan on developing the Web
GUI as an ActiveX Document and...
|
by: jeff |
last post by:
Hiya
I want to create 2 "simple" perl scripts, One of them takes a string
input on the Com port and then sends it via the internet to a website,
The website has a Cgi-Bin and this recieves the string and then either
puts it in to html or txt format which is saved on the website
I know this is a client and server application its just getting it set
up on a Cgi-bin im confused with,
|
by: BravesCharm |
last post by:
I am trying to connect to SQL Server 2005 Express with Visual C# 2005
Express using this code:
static void Main(string args)
{
SqlConnection conn = new SqlConnection(@"Data
Source=.\SQLEXPRESS;AttachDbFilename=|DataDirectory|\temp.MDF;User
ID=MyUsername;password=MyPass;DATABASE=Test;Integrated
Security=False;User Instance=True");
conn.Open();
|
by: GTDriver |
last post by:
I'm trying to connect my application with a web service located on my own web
server(localhost).
I guess when the solution/proect is built it makes a file called 'Web
References\localhost\References.vb'
In this file a line of code reports the following error:
Line of code:
Dim results() As Object = Me.Invoke("GetCustomers", New Object() {Country})
|
by: Bob |
last post by:
I am having trouble grasping the components I need to develop and put
together in order to have a solid, integrated security authentication
mechanism for a custom C# .NET application that involves a client application
connecting to a remote Windows (server) application that is not running IIS
or SQL Server. I want the users to be able to seemlessly start the
application on the client, use the same credentials they used to log on to
their...
| |
by: Cichy |
last post by:
Hello,
I'm writing a Client-Server application using sockets (asynchronous).
There is a Server (Master) which accepts incoming connections, and
Client (Slave).
Afetr establishing connections with all Slaves I wanna hit a button
"Automatic", then everything must be reorganised, there is an
ellection for a new Master.
Everything is all right when I'm connecting manually (when I hit a
button connect), but after hitting this button...
|
by: kimtherkelsen |
last post by:
Hi,
I use the System.Data.OleDb.OleDbConnection class to establish a
connection to a Oracle 10G database.
The dsn connection string I use look like this:
dsn=provider="MSDAORA.1";User ID=test;Data Source="172.30.0.25/
JBOS";Password=test;
This works fine in Windows XP and Windows server 2003 but I have a
customer that try to connect to the database from a Windows 2000
|
by: TerpZebra |
last post by:
I am having difficulty connecting to SQL Server 2000 on one of our
servers via a VB6 program on Vista. I can connect fine to a different
server, but it gives me the following error with the server in
question:
"Unable to connect to database. Please check your internet connection
Error# -2147467259
SQL Server does not exist or
access denied"
|
by: myth0s |
last post by:
Hello everybody :)
I have trouble getting my ASP application to work. I googled a lot for a solution... many solutions I tried came from The Scripts, but none of them worked. Nonetheless, I think somebody out there can help me ;)
So, I have an ASP.NET 2.0 application on the test server. That application doesn't work, I get "Server Application Unavailable" all the time but... while experimenting with all the possibles solutions I found over...
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look !
Part I. Meaning of...
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it.
First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
| |
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed.
This is as boiled down as I can make it.
Here is my compilation command:
g++-12 -std=c++20 -Wnarrowing bit_field.cpp
Here is the code in...
|
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth.
The Art of Business Website Design
Your website is...
|
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own....
Now, this would greatly impact the work of software developers. The idea...
|
by: TSSRALBI |
last post by:
Hello
I'm a network technician in training and I need your help.
I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs.
The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols.
I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
| |
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |