Skip to main content

JSR 82

35 replies [Last post]
hallenberg
Offline
Joined: 2007-01-05
Points: 0

I might be blind or something, but here goes.

How do I compile JSR 82 support? Setting USE_JSR_82 doesn't help much since there is no jsr82 dir to choose as JSR_82_DIR. Is the source available somewhere else?

Thanks

/ Tomas

Reply viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
andrey_nazarov
Offline
Joined: 2006-10-16
Points: 0

Hello hallenberg,

In generally it should not be differences between USB and UART in Java. May be the cause is in the UART drivers configuration?
Unfortunately, we do not have an experience in work with UART.
Please, share your experience with us if you find a solution of the problem.

Regards,
Andrey

feng_tian
Offline
Joined: 2007-09-20
Points: 0

I found that PhoneMe Advanced also support jsr82, but I can't find the jsr82 dir in the src bundle. Did I miss something, we need CDC support, so we should use PhoneMe advanced

Regards
Feng

akz003
Offline
Joined: 2006-10-13
Points: 0

Hi, Feng

You did not miss anything. JSR82 is released and available for phoneME Feature inside the source bundle. JSR82 has not been released as part of phoneME Advanced so far. Indeed there are a plan to do it within one of the upcoming releases of the phoneME Advanced - but I do not have a precise information which release and when exactly. What I can say for sure is that one of the major changes that are planned to be applied to the JSR is to make it running on top of both phoneME Feature and Advanced code seamlessly.

Regards
Kostya

ticachen
Offline
Joined: 2008-07-29
Points: 0

following marlonj's instruction Everything compiles and seems to run just fine, but when i test some apps there has some troubles.

i use ObexDemo in WTK to test obex, but when calling connect.open() it alway fail, throws exp:
java.io.IOException: Could not establish connection.
- .unknown..createClientConnection(), bci=101
- com.sun.midp.io.j2me.irdaobex.Protocol..unknown.(), bci=569
- javax.microedition.io.Connector..unknown.(), bci=237
- javax.microedition.io.Connector.open(), bci=3
- javax.microedition.io.Connector.open(), bci=3
- javax.microedition.io.Connector.open(), bci=2
- example.obex.demo.ObexImageSender.connect(), bci=19
- example.obex.demo.ObexImageSender.run(), bci=20
- java.lang.Thread.run(), bci=5

and i found this error is in IrConnection.c, in ir_discover() when calling getsockopt(sockfd, SOL_IRLMP, IRLMP_ENUMDEVICES,disc, &len)) ,it failed and the errno is 11,witch means "try again".

i test phoneme in ubuntu7 and my bluetooth device works fine,any ideas?

Message was edited by: ticachen

pratikvpm
Offline
Joined: 2007-07-03
Points: 0

hello....
can u please help me to find where can i download javax.bluetooth and javax.obex package java source code files..?? i can only find html files on java.sun.com....m a novice so may b i missd quite a few things while searching...

aka1278
Offline
Joined: 2006-10-18
Points: 0

Hi pratikvpm,

Due license reasons, JSR-82 source code can not be put to an open source project,
anyway you can find the sources in the latest MR2 source bundle
(at this moment it's b23, located at http://download.java.net/mobileembedded/phoneme/feature/phoneme_feature-...).

Regards,
Alexey Kornev

feng_tian
Offline
Joined: 2007-09-20
Points: 0

I found that PhoneMe Advanced also support jsr82, but I can't find the jsr82 dir in the src bundle. Did I missed something, we need CDC support, so we should use PhoneMe advanced

Regards
Feng

marlonj
Offline
Joined: 2003-06-11
Points: 0

I might be blind also

Where i can download the JSR 82 sources ??
I want to try in a linux box with bluez

marlonj

akz003
Offline
Joined: 2006-10-13
Points: 0

Hi,

this JSR sources are available from the phoneME Feature MR1 source bundle.
https://phoneme.dev.java.net/downloads_page.html#feature

The implementation is for linux and was developed with use of the same stack underneath.

Regards
Kostya

marlonj
Offline
Joined: 2003-06-11
Points: 0

Hello There

Thanks to put me in the right direction, but now i have some problems.
I'm tryng to compile a Linux midp version with jsr 82 support with BlueZ

I download the phoneme_feature-mr1-rel-src-b04-09_nov_2006.zip

I compile the pcsl using
make NETWORK_MODULE=bsd/generic PCSL_PLATFORM=linux_i386_gcc GCC_VERSION=-3.4

I compile the cldc using
cd cldc/build/linux_i386
make JDK_DIR=/home/mjs/sw/j2sdk1.4.2_14 JVMWorkSpace=/home/mjs/sw/phoneME_feature/cldc ENABLE_PCSL=true PCSL_DIST_DIR=/home/mjs/sw/phoneME_feature/pcsl/output/linux_i386 GCC_VERSION=-3.4

I compile the midp using
cd midp/build/linux_fb_gcc
make JDK_DIR=/home/mjs/sw/j2sdk1.4.2_14 PCSL_OUTPUT_DIR=/home/mjs/sw/phoneME_feature/pcsl/output CLDC_DIST_DIR=/home/mjs/sw/phoneME_feature/cldc/build/linux_i386/dist GCC_VERSION=-3.4 USE_JSR_82=true JSR_82_DIR=/home/mjs/sw/phoneME_feature/jsr82 USE_JSR_82_EMULATOR=false

All the build process works fine, but when i try to open the Bluetooth device i receive the exception : Failed turning Bluetooth on

What i doing wrong ???

I have Bluetooth USB Dongle and the hciconfig command returns
hci0: Type: USB
BD Address: 11:11:11:11:11:11 ACL MTU: 678:8 SCO MTU: 48:10
UP RUNNING PSCAN ISCAN
RX bytes:420 acl:0 sco:0 events:19 errors:0
TX bytes:323 acl:0 sco:0 commands:19 errors:0

I also work with avetanaBT and it works

aka1278
Offline
Joined: 2006-10-18
Points: 0

Hi,

Could you try the MR2 release that contains jsr82 as well?

You can find the source at:
http://download.java.net/mobileembedded/phoneme/feature/phoneme_feature-...

Ready to use binaries for Linux/x86 are at:
http://download.java.net/mobileembedded/phoneme/feature/phoneme_feature-...

Please let me know if it helps.

Regards,
Alexey Kornev

marlonj
Offline
Joined: 2003-06-11
Points: 0

Hello

Thanks to Alexey to the message.

I download the MR2 file
http://download.java.net/mobileembedded/phoneme/feature/phoneme_feature-...

And execute the same commands to compile pcsl and cldc, but when i try to compile midp i have to add the TOOLS_DIR variable
make JDK_DIR=/home/mjs/sw/j2sdk1.4.2_14 PCSL_OUTPUT_DIR=/home/mjs/sw/phoneME_feature/pcsl/output CLDC_DIST_DIR=/home/mjs/sw/phoneME_feature/cldc/build/linux_i386/dist GCC_VERSION=-3.4 USE_JSR_82=true JSR_82_DIR=/home/mjs/sw/phoneME_feature/jsr82 USE_JSR_82_EMULATOR=false
TOOLS_DIR=/home/mjs/sw/phoneme_feature/tools

But it throws this error
... compiling 512 .java files and 7 generated .java files
/home/mjs/sw/phoneme_feature/midp/build/linux_fb_gcc/output/generated/classes/com/sun/midp/jsr082/Initializer.java:28: package com.sun.midp.jsr82emul does not exist
import com.sun.midp.jsr82emul.EmulationPolling;

When i try without the USE_JSR_82_EMULATOR it compiles fine.

I think that jsr82 is tryng to use the emulator package even if the configuration specified a real device.

Any ideas ??

marlonj
Offline
Joined: 2003-06-11
Points: 0

Hi Again

I edit the file jsr82/src/core/classes/com/sun/midp/jsr082/Initializer.jpp and

i replace the line :
import com.sun.midp.jsr82emul.EmulationPolling;

with :
// #ifdef USE_JSR_82_EMULATOR
// import the classes
import com.sun.midp.jsr82emul.EmulationPolling;
// #endif

Then i compile again using the USE_JSR_82_EMULATOR=false and the midp compiles, but when i try to run a bluetooth an exception is throw :
Uncaught exception: java.lang.RuntimeException: Failed turning Bluetooth on

I now that the BlueZ is a experimental, but it will be nice to see working

marlonj
Offline
Joined: 2003-06-11
Points: 0

Bluetooth under Linux with BlueZ IT WORKS !!!!!!!!!!

Finally, after some hours of downloading, reading, write, post i was able to test a bluetooth application using the MR2 source, in a linux box with BlueZ

I will resume all :

I download the MR2 file (thanks to Alexey)
http://download.java.net/mobileembedded/phoneme/feature/phoneme_feature-...

I compile the pcsl using
cd pscl
make NETWORK_MODULE=bsd/generic PCSL_PLATFORM=linux_i386_gcc GCC_VERSION=-3.4

I compile the cldc using
cd cldc/build/linux_i386
make JDK_DIR=/home/mjs/sw/j2sdk1.4.2_14 JVMWorkSpace=/home/mjs/sw/phoneme_feature/cldc ENABLE_PCSL=true PCSL_DIST_DIR=/home/mjs/sw/phoneme_feature/pcsl/output/linux_i386 GCC_VERSION=-3.4

I edit the file jsr82/src/core/classes/com/sun/midp/jsr082/Initializer.jpp and

i replace the line :
import com.sun.midp.jsr82emul.EmulationPolling;

with :
// #ifdef USE_JSR_82_EMULATOR
// import the classes
import com.sun.midp.jsr82emul.EmulationPolling;
// #endif

I edit the file jsr82/src/core/native/common/btCommon.h and i replace the following lines

// #define BLUETOOTH_STACK_HEADER "PlainBluetoothStack.h"
#define BLUETOOTH_STACK_HEADER "BlueZStack.h"

// #define BLUETOOTH_STACK_CTOR CPlainBluetoothStack()
#define BLUETOOTH_STACK_CTOR CBlueZStack()

I have to add the method IsInitialized to the BlueZ implementation
I edit jsr82/src/core/native/linux/BlueZStack.h and add the method
bool IsInitialized();

I edit jsr82/src/core/native/linux/BlueZStack.cpp and add a simple implementation at the end of the file
bool CBlueZStack::IsInitialized()
{
return true;
}

I compile midp using
cd midp/build/linux_fb_gcc
make JDK_DIR=/home/mjs/sw/j2sdk1.4.2_14 PCSL_OUTPUT_DIR=/home/mjs/sw/phoneme_feature/pcsl/output CLDC_DIST_DIR=/home/mjs/sw/phoneme_feature/cldc/build/linux_i386/dist TOOLS_DIR=/home/mjs/sw/phoneme_feature/tools USE_JSR_82=true JSR_82_DIR=/home/mjs/sw/phoneme_feature/jsr82 USE_JSR_82_EMULATOR=false GCC_VERSION=-3.4

And now in testing some bluetooth applications !!!!!
Really Cool !!! and god job PhoneME Team !!!!!

hallenberg
Offline
Joined: 2007-01-05
Points: 0

After not using Bluetooth in Java for a long time I noticed today that it doesn't work any more. Later I used the JSR82 code from MR1, but since then I've moved to MR2 without testing Bluetooth. But after following marlonj's instruction there's still something wrong. Everything compiles and seems to run just fine, but I don't find any devices when scanning. Scanning in the linux prompt works perfectly.

Any ideas?

hallenberg
Offline
Joined: 2007-01-05
Points: 0

To fill in some more information so you're actually able to help:
I put in some debug output in BlueZStack.cpp and GenericBluetoothStack.java. Everything seems to work as it's supposed when I start an inquiry from my testmidlet.
CBlueZStack() is initialized and CGenericBluetoothStack::StartInquiry() is called and ReadData() reads 6 bytes (don't know yet if it's supposed to read more though). Then there's a pause for some time.
CGenericBluetoothStack::retrieveEvent() is called and ReadData() reads 4 bytes (still don't know if it's supposed to read more), the code is interpreted as HCI_INQUIRY_COMPLETE. But there are no found devices reported by my midlet, and as you can see only a total of two reads at 6 bytes and 4 bytes respectively.

hallenberg
Offline
Joined: 2007-01-05
Points: 0

I tried using a USB dongle instead of running over a UART, and that works just fine. So for some reason there's a difference between USB and UART in Java, but not when using bluez-utils directly from the console. I'm puzzled...

hallenberg
Offline
Joined: 2007-01-05
Points: 0

I keep answering myself, but it's just to keep others informed of my findings.

I found the problem after some hcidumping and whatnot.

When I scan with the USB dongle I get regular HCI inquiry results (EVT_INQUIRY_RESULT, 0x02). But when scanning with the UART I get the ones that also has RSSI (EVT_INQUIRY_RESULT_WITH_RSSI, 0x22), but those weren't included in the BlueZ hci filter. So after adding the row "hci_filter_set_event(EVT_INQUIRY_RESULT_WITH_RSSI, &flt);" to the filter settings in BlueZStack.cpp I'm getting the responses. Now I only have to add the parsing of the info to GenericBluetoothStack.java.

andrey_nazarov
Offline
Joined: 2006-10-16
Points: 0

Hi,
I see you answer myself more quickly than I answer to you :)

I am glad that you found the cause.
I'd like to add that sometime the blueZ stack could be default initialized differently (for instance, for different versions of Ubuntu).
May be it is possible to change the inquire mode settings in your system. (it could be easier than change the code). For the USB bluetooth dongle I used the hciconfig utility.
The inquiry mode could be set for the system by the hciconfig utility:
hciconfig hci0 inqmode
0 - Standard mode (The EVT_INQUIRY_RESULT appears)
returns inquiry_info type)
1 - Inquiry with RSSI (The EVT_INQUIRY_RESULT_WITH_RSSI appears,
returns inquiry_info_with_rssi type)
2 - Inquiry with RSSI or Extended inquiry (if any)
(The EVT_EXTENDED_INQUIRY_RESULT appears,
returns extended_inquiry_info type)

Regards,
Andrey

hallenberg
Offline
Joined: 2007-01-05
Points: 0

Well, since changing the code to also allow EVT_INQUIRY_RESULT_WITH_RSSI only took three rows (one row to set up the hci filter, one row to define HCI_INQUIRY_RESULT_WITH_RSSI and one row to extend the switch so HCI_INQUIRY_RESULT_WITH_RSSI and HCI_INQUIRY_RESULT does the same thing, both types are 14 bytes long and have the Bluetooth address in the same place), and will work on more systems straight out of the box I personally think it's better to change the code. Ideally handling of EVT_EXTENDED_INQUIRY_RESULT should be added as well if it's the way you're saying, don't know how that type is composed but it's easy to look up. This would of course also eliminate similar issues in the future.

andrey_nazarov
Offline
Joined: 2006-10-16
Points: 0

You are right of course, the code modification that could eliminate the problem is better. I meant that it is more quickly to try change the settings to be sure that it is the problem cause.

hallenberg
Offline
Joined: 2007-01-05
Points: 0

I had already fixed it when you gave the suggestion, but thanks. I suppose it can help others who don't want to bother about rewriting the code =)

arjunraghavan
Offline
Joined: 2009-02-11
Points: 0

hello

I am facing a problem with creation of service record using Bluez stack.

the response for the request to to create a record is
rsphdr->pdu_id == SDP_ERROR_RSP which means invalid service record.

does any body know the reason?

Regards,
Arjun

bruse
Offline
Joined: 2007-03-30
Points: 0

Which JSR-82 Stack are you using? Try [url=http://www.javabluetoothstack.com/electricblue.htm]ElectricBlue[/url], or if you just want a simulator, try [url=http://www.javabluetoothstack.com/bluesim.htm]BlueSim JSR82 Simulator[/url]

Also check out [url=http://www.jsr82.com]JSR-82 Articles[/url] and [url=http://www.jsr82.com/forum]Discussion Forums[/url]

tusharj9
Offline
Joined: 2005-09-22
Points: 0

Hi,
In CBlueZStack class constructor while initializing bluetooth connection using bluez apis there is this functon call "fcntl(m_fd, F_SETFL, O_NONBLOCK) " .
What is the purpose of this function call ? As I understand call to "fcntl()" with O_NONBLOCK result in modifying the oped file (here socket ) descriptor.
For me , if I comment this function call , subsequent hci_* function work properly . Else these hci_* does not work properly. In fact, hci_read_local_name is not not even returning local device name.
Any suggestions ?

regards,
Tushar

aka1278
Offline
Joined: 2006-10-18
Points: 0

Hi,

phoneME feature VM utilizes only one OS thread. Thus VM is portable to any OS even if particular OS does not support multiple threads. Unfortunately, any call to native code blocks entire VM in this case.

In order to keep away from long VM blocking, all I/O operations should be non-blocking. Bluetooth operations can be slow enough, for instance, connect can take up to 10 seconds. That's why cntl with O_NONBLOCK is called.

On the other hand, handling of non-blocking operations is more complicate than blocking ones due additional efforts to detect 'data is ready' and resume/complete operation upon this event. This is the reason why operations in non-blocking mode can fail while they are OK in blocking mode.

Regards, Alexey Kornev.

arjunraghavan
Offline
Joined: 2009-02-11
Points: 0

hi,

I am able to do device discovery and service discovery with Bluez stack and phoneme_mr2. But I try to make a connection I am getting the following error.

[M] getServiceSearchUrl() serviceSearchUrl = btspp://000519001155:7;master=false;encrypt=false;authenticate=false
[M] connUrlbtspp://000519001155:7;master=false;encrypt=false;authenticate=false
java.lang.RuntimeException: Blocking call performed in the event thread
- .unknown...unknown.(), bci=50
- .unknown..(), bci=240
- .unknown...unknown.(), bci=14
- .unknown..checkForPermission(), bci=202
- .unknown..checkForPermission(), bci=15
- com.sun.midp.midletsuite.MIDletSuiteImpl..unknown.(), bci=29
- com.sun.midp.midletsuite.MIDletSuiteImpl.checkForPermission(), bci=18
- .unknown...unknown.(), bci=29
- com.sun.midp.io.j2me.btspp.Protocol..unknown.(), bci=4
- .unknown...unknown.(), bci=40
- .unknown...unknown.(), bci=12
- .unknown...unknown.(), bci=5
- javax.microedition.io.Connector..unknown.(), bci=237
- javax.microedition.io.Connector.open(), bci=3
- javax.microedition.io.Connector.open(), bci=3
- javax.microedition.io.Connector.open(), bci=2
- BluetoothMidlet.commandAction(), bci=1406
- .unknown...unknown.(), bci=213
- .unknown...unknown.(), bci=48
- .unknown...unknown.(), bci=89
- .unknown...unknown.(), bci=128
- .unknown...unknown.(), bci=52
- .unknown..process(), bci=132
- com.sun.midp.events.EventQueue.run(), bci=104
- java.lang.Thread.run(), bci=5
commandAction: Blocking call performed in the event thread

Has anybody faced a similar situation?

Regards,
Arjun

arjunraghavan
Offline
Joined: 2009-02-11
Points: 0

hi,

i found the reason for that.

In the MIDlet, its trying to make connection from commandAction.
When moved the code for making connection from commandAction to MIDlet body the connection worked fine.

hallenberg
Offline
Joined: 2007-01-05
Points: 0

So, I finally got around to compiling JSR 82 in MR1. I can see that it links against BlueZ and all (had to set emulation to false first of course), and FPC bench shows JSR 82 API = 1.0. But the application I'm using to test still can't seem to use Bluetooth (but at least it starts). Unfortunately I haven't managed to get any own midlet to run yet (never compiled/preverified/packaged one before in my life) so it's kind of hard for me to pinpoint the problem... Using bluetooth (BlueZ) in the shell works just perfectly. Any ideas on what I might be missing?

hallenberg
Offline
Joined: 2007-01-05
Points: 0

I found it. I had to change what bluetooth implementation should be used in jsr82/src/core/native/common/btCommon.h (BlueZStack in my case).

And of course do a make clean...

Seems to work like a charm. Unfortunately I haven't received the GPS unit by mail yet so I haven't been able to test. But since searching for devices works I guess using them should also work.

akz003
Offline
Joined: 2006-10-13
Points: 0

Hi, Tomas

JSR82 is not available into repository but it is available in source bundle for MR1. So you would need to pick it up from there.
The development/bugfixing of JSR82 for MR2 is not completed - means the source code is not completely passing TCK. As soon as it will pass on all platforms we are going to place it for source bundle of promotion of MR2.

Regards,
Kostya

hallenberg
Offline
Joined: 2007-01-05
Points: 0

Thanks, I'll check that out... Is there any information available about what's currently lacking?

/ Tomas

akz003
Offline
Joined: 2006-10-13
Points: 0

Hi, Thomas

MR1 is compliant with older version of JSR82 TCK 1.4.
MR2 will be compliant with the currently available version of TCK 2.1.

Regards
Kostya

hallenberg
Offline
Joined: 2007-01-05
Points: 0

Is there any estimate on the time frame to release? (I bet you've never heard that question before ;))

/ Tomas

akz003
Offline
Joined: 2006-10-13
Points: 0

Hi, Tomas

it seems that MR2 will happen approximately in early Q2.
However JSRs that will start passing TCKs will immediately appear into the source bundles on download pages inside Development Releases that will follow in the nearest days/weeks with appropriate notification message.
So, please stay tuned.

Regards,
Kostya.