.NET Components for Mobility

JSR82 <> InTheHand

Last post 04-01-2009 6:04 AM by ubi2009. 2 replies.
Page 1 of 1 (3 items)
Sort Posts: Previous Next
  • 03-31-2009 4:18 AM

    JSR82 <> InTheHand

     hello,

    I'm working on a connection between JSR82 ( Java on a mobile phone)  and PC ( C# ( inthehand) ). 

    The PC works as a server:

    ------------------------------------- 

       public static Guid TEXTSERVICE = new Guid("12100000000000000000000000000121");
            private Thread thread;
            private bool run = true;
            private BluetoothListener btl;
            private ServiceRecordBuilder SvcBuilder;

            public Form1()
            {
                InitializeComponent();
                if (!BluetoothRadio.IsSupported)
                {
                    MessageBox.Show( "No Bluetooth Adapter found!!!");
                }
                else
                {
                    if (BluetoothRadio.PrimaryRadio.Mode == RadioMode.PowerOff)
                        BluetoothRadio.PrimaryRadio.Mode = RadioMode.Discoverable;
                    // Create and start a thread, listening for an incoming text message
                    thread = new Thread(new ThreadStart(runThread));
                    thread.Start();
                }
            }

     ------------------------

     private void runThread()
            {
                try
                {
                    run = true;
                    SvcBuilder = new ServiceRecordBuilder();
                    SvcBuilder.AddServiceClass(BluetoothService.RFCommProtocol);
                    SvcBuilder.ServiceName = "MyService";

                    ServiceRecord record = SvcBuilder.ServiceRecord;

                    btl = new BluetoothListener(TEXTSERVICE, record);
                    btl.Start();
                    while (run)
                    {
                        BluetoothClient btc = btl.AcceptBluetoothClient();
                        StreamReader sr = new StreamReader(btc.GetStream());
                        // Create a delegate for setting the text on the main thread
                        this.Invoke((MethodInvoker)delegate
                        {
                            MessageBox.Show("Message received: ");
                        });
                        sr.Close();

                    }
                }
                // If the thread gets aborted, an exception is thrown
                catch { }
            }
        }
    }

     ----------------------------

    Now I'm able fo find the service ( My Service)  on mobile Phone(Java) side , but don't know what I've got to do for sending a message to the server and get one back.  In  a lot of examples work with a objectnotifier by using RFcomm, but inthehand don't have them, or? Or is there anothersolution for sending messages over bluetooth between C# and Java on a mobile phone? 

     

    It would be nice, if someone could help me. I wasted the whole last day for this problem.

    ubi

     

  • 04-01-2009 5:40 AM In reply to

    Re: JSR82 <> InTheHand

    I've never used the JSR-82 API only read about it briefly, so I can't really help on that end.  I should maybe have a look.  Is there a simple way to get the API onto my PCs or PDAs?

    Alan J. McFarlane
    http://www.alanjmcf.me.uk/
    Please follow-up in the newsgroup for the benefit of all.
    Have I helped? Consider visiting my Amazon wishlist, see my homepage.
  • 04-01-2009 6:04 AM In reply to

    Re: JSR82 <> InTheHand

     I'm using Java ME and Java Wireless Development Kit for my work. In Addition to that, one needs some Java - Plugins. I'm  testing my programs on my mobile phone. 

Page 1 of 1 (3 items)
Copyright © 2001-2010 In The Hand Ltd. All rights reserved. Terms of Use and Privacy Policy.