Interpret a byte stream from a Bluetooth-device

Hi
I'm having a problem with interpreting an InputStream from my Bluetooth device. I'm developing an application on SE P900, J2ME MIDP2.0/CLDC 1.0.
Example:
while((read = is.read(byteArray)) != -1) {
   receivedData = new StringBuffer();
   log("Read:  " + read + "bytes");
   for(int i = 0; i <= read; i++) {
      byte tmp = (byteArray);
receivedData.append(tmp);
log(receivedData.toString());
log("Finish :)"); //This is never printet. read is never -1..
//The result of my app in P900:
//Read 2 bytes
//3100
//Read 2 bytes
//0310
The bytestream I get from the bluetooth-device looks something like this:
byte 0: header
byte 1: MSB
byte 2: LSB
byte 3: CRC
I need to find out how I can interpret the inputStream correctly! It is possible that my output is wrong, so that the input is incomplete. But it'd be much easier if I could read the InputStream correct
I've also tried to use the InputStreamReader, since it converts bytes to unicode, but that wont work. Have got a few examples on that, but in J2ME the BufferedReader doesn't exists so I cant it out
Haavard

simple:
byte header = Datain.readByte();
short length = Datain.readUnsignedShort();
byte[] IDinBytes = new Byte[length];
Datain.readFully(IDinBytes );
String ID = New String(IDinBytes );this might also work:
byte header = Datain.readByte();
String ID = Datain.readUTF();but this is really hack, since readUTF() will first read two bytes to indicate the length of the string, and then the string itself. In this case, it works, but in general you should use the first example. Only use readUTF() if you have DataOutputstream on the other side that uses writeUTF(), in all other options, it's more or less a dirty hack ;)

Similar Messages

  • How do you sync "all" the Photo Streams from my iOS6 devices to iPhoto '11

    I just purchased iPhoto 11 for my MacBook running Lion OS. I can't seem to sync all the Photo Streams from my iOS6 devices to my MacBook. I need more than 30 days.

    You need to open iMovie and it will have a event library called iPhoto Videos, click on that and the videos will load in the window next to it, then you make a new project in iMovie.  Then open iDVD and make a new project then import the movies to the program then burn to a DVD..

  • ITunes purchased videos and all DRM movies will not play on iOS 8 devices when streamed from an external drive (or streamed from other wireless devices). Any solution in sight?

    Video streaming of DRM movies, purchased from iTunes and other vendors, to any iOS device is not working.

    I am not sure if you really understand the issue at hand. Possibly that you are just scanning, not reading the whole text, or simply that you just want to close a thread with your last words or derail it for whatever strange reason. So far you have been more destructive than helpful, but again this could be ignorance at best.
    If you would have had the decency to read the entire thread you would have come to the conclusion that every manufacturer, I came across, has posted FAQ's to this issue but Apple. Find a short excerpt below:
    SeaGate  http://knowledge.seagate.com/articles/en_US/FAQ/006135en?language=en_US <http://knowledge.seagate.com/articles/en_US/FAQ/006135en?language=en_US> Playing DRM (Digital Rights Management) protected movies in Seagate Media App Information regarding remote streaming of DRM protected movies. Most forms of DRM (Digital Rights Management) will prevent playing movies on unauthorized devices or from remote storage hosted on wireless drives or NAS drives(Seagate Wireless, Seagate Wireless Plus, Seagate Central or Seagate Personal Cloud). Movies purchased from iTunes can be streamed to iOS 6 and iOS 7 devices which were authorized from remote storage (the video could be selected in Seagate Media App and would be played in a Safari browser), however in iOS 8 this has stopped working. A bug has been filed with Apple, however this functionality has not been restored. Therefore, DRM protected movies purchased on iTunes can no longer be played on devices running iOS 8.
    SanDisk  http://kb.sandisk.com/app/answers/detail/a_id/16668/kw/itunes <http://kb.sandisk.com/app/answers/detail/a_id/16668/kw/itunes> Videos purchased or rented from iTunes will not play in iOS 8 The SanDisk Wireless Media Drive and Wireless Flash Drive support streaming of DRM protected iTunes purchased movie content to authorized devices in iOS 6 and iOS 7 ONLY. The DRM protected content is opened in Safari where the DRM is decrypted and the video is played. iOS 8 issue In iOS 8 Apple device has NOT enabled Safari based DRM decryption. Therefore DRM protected content, i.e. purchased movies or TV shows from iTunes, CANNOT be streamed from the Media Drive/WFD in iOS 8. This issue has been reported to Apple. We do not have any estimated date when Safari will support DRM decryption of iTunes purchased content.
    in contrast: here is the excerpt from the Apple Store http://store.apple.com/us/product/HFSQ2VC/A/sandisk-connect-64gb-wireless-media- drive?fnode=12ea113d2dba9883d5561c573d91…
    Overview
              With the SanDisk Connect Wireless Media Drive and its companion app, you're free to share and stream high-definition content between your iPad, iPhone, iPod touch or Mac devices without a cable connection. Simply connect wirelessly from your iOS device to the media drive and instantly stream your HD movies, browse photos and listen to music from around the house or on the go, while avoiding the common hassles of cables, attachment limits or Internet availability
    AirStash  http://support.airstash.com/entries/55924774-Known-Issues-with-iOS-8-and-or-iPho ne-6-6- <http://support.airstash.com/entries/55924774-Known-Issues-with-iOS-8-and-or-iPho ne-6-6-> (Excerpt) Known Issues with iOS 8 and/or iPhone 6/6+ Apple recently released iOS 8 and the iPhone 6 and iPhone 6+. Here are the remaining issues that we are aware of in the iOS 8 general release: • Video streaming of DRM movies (purchased from iTunes and other vendors): iTunes purchased videos and all DRM movies will not play on iOS 8 devices when streamed from AirStash (or streamed from other wireless devices). These movies are digitally protected and the AirStash app sends them to the Safari browser to play (which works for all prior iOS versions). However, in iOS 8, Safari will no longer allow DRM movies to play. These movies will play when the video is transferred to the iPhone/iPad and played in the Apple's Video App or the corresponding App from the vendor.
    WD - A Western Digital company  http://community.wd.com/t5/My-Passport-Wireless/Streaming-itunes-DRM-movies-to-s afari-on-iPad-not-working-IOS-8/m-p/820913#M387 <http://community.wd.com/t5/My-Passport-Wireless/Streaming-itunes-DRM-movies-to-s afari-on-iPad-not-working-IOS-8/m-p/820913#M387> No official comment here in regards to the issue but a interesting comment by Bill_S, WD Community Manager, who is basically saying that iOS8.x was actually a fix to an issue that DRM protected movies were playing prior to iOS8.x. If this is the case and Apple will not address this issue or fix it since Apple believes that movies should be protected this way, you need to let the community know that movies are restricted this way. Re: Streaming itunes DRM movies to safari on iPad not working - IOS 8 issue? [ Edited ] Options 11-06-2014 03:19 PM - edited 11-06-2014 03:22 PM Actually, this is not something we can NOT fix. It appears that Apple finally fixed an issue they had with their movie DRMs. The files should have never played in the first place. [Edit] If you have an issue with this, you will need to take it up with Apple. Click the Kudos star to say thank you for helpful posts. And be sure to come back to click the 'Accept as Solution' button for the post that solved your issue. This may help someone else.

  • Data transfer from External Bluetooth device to iPhone

    Dear Team,
    We have a requirement, Data Transfer from a SIB (CAN to Bluetooth) to iPhone.
    As we know in iPhone Bluetooth is support for Audio devices.
    Is there any way to achieve the data transfer from an external Bluetooth device to iPhone/iPad?
    With Thanks and Regards
    Chandan Prakash
    Renault Nissan
    Chennai, India

    Ok. There are some apps where we can send and receive data like photos, contacts, etc. We can chat also. So is there any way to receive data?

  • Can I remove a Photo Stream from my iOS device and keep it on my iMac?

    Is there a way to save a Photo Stream on your computer (comments and all) and remove it from your iOS devices?  Going back to read the comments from time to time is nice, but don't want to have a list of Photo Streams as long as my arm on my iPhone and iPad.

    If you're referring to Shared Photos Streams the answer would be no.  If you're the owner of the stream and all you devices are logged into the same Apple ID if you delete the photos in a shared stream on one device they get deleted on all devices.
    iCloud: Photo Stream FAQ
    OT

  • Trying to get data from a bluetooth device using labview. Can anyone help?

    I am currently working on a project to monitor pulse rate and need send the reading via bluetooth. My laptop is bluetooth enabled and is using a toshiba stack. I am new to LabView and need some help with this.
    Message Edited by Iceberg D4 on 05-05-2009 10:58 AM

    You can definitely do this using LabVIEW. Search for labview bluetooth on NIs website to look for articles and documentation with regards to this. One thing I noticed and would like to point out:
    On Windows XP - LabVIEW works with Bluetooth devices that use the Microsoft Bluetooth
    driver included with Windows XP Service Pack 2 and later. Refer to the
    Microsoft Web site for Bluetooth devices that are supported by the
    Microsoft Bluetooth driver. Most Bluetooth devices come packaged with a
    proprietary Bluetooth driver. To use the device with LabVIEW, the
    Bluetooth adapter must be using the Microsoft Bluetooth driver. A
    Microsoft Bluetooth driver for Windows XP SP1 was also available. Refer
    to Microsoft Knowledge Base Article 323183: Availability of Windows XP Service Pack 1 Support for Bluetooth Wireless Devices for more information about Bluetooth-compatible operating systems.
    Have a look at the following:
    http://zone.ni.com/devzone/cda/tut/p/id/3260
    http://zone.ni.com/reference/en-XX/help/371361E-01/lvcomm/bluetooth_vis/
    Adnan Zafar
    Certified LabVIEW Architect
    Coleman Technologies

  • Best way to save images streamed from web to device?

    We have an app for browsing a catalog that streams content from a web server. There is an image for each product, some in JPG format and some in PNG format. Our server is fast and reliable so everything has been running smoothly so far, but we'd like to give users the option of saving the data to their device so they don't have to stream every time. I've only worked with SharedObjects before, which are capped at 100kb and won't be useful in this situation.
    What would be the best approach for storing the images, and keeping them from being overwritten during updates? Saving an uncompressed Bitmap will use too much storage space. Adobe's JPEGEncoder class is completely useless as it takes 10-30 seconds to save a moderately-sized image on a typical device. It also doesn't make sense to re-encode the JPGs, and we need to preserve the transparency in the PNGs.
    Right now we're using a Loader to retrieve the images and using loader.content to access the image data in code. Is it possible to save the image file in its original format locally when it is downloaded with a Loader? We would want the images stored in the application data and not accessible through the gallery. As for saving the data for each product (e.g. price, description, etc), would the built-in SQLite support be sufficient or should we create our own files?
    Thanks for any tips!

    We typically use a native extension to do this, but it is certainly possible in ActionScript.
    When the file has been downloaded, we save it to the applicationStorageDirectory.
    Next time, we check to see if exists locally, if so - use that and don't download.
       var file:String = renameFile(_externalHttpImage);
       //see if we already have a copy of the image
       var loader:Loader = new Loader();
       var ba:ByteArray = new ByteArray();
       if( fileExists(file)){
        file = File.applicationStorageDirectory.resolvePath(file).nativePath;
        loader.contentLoaderInfo.addEventListener(Event.COMPLETE, local_loader_complete);
        loader.contentLoaderInfo.addEventListener(IOErrorEvent.IO_ERROR, errorOnChargeFile);
        var f:File = File.applicationStorageDirectory.resolvePath(file);
        if( f.exists){
         var fs:FileStream;
         try {
          //now load the size of the file
          fs = new FileStream();
          fs.open(f, FileMode.READ);
          fs.readBytes(ba);
          //  trace("READ " + fs.readUTF());
          fs.close();
         catch(e:Error){
          trace( "Error Loading Image File  '" +file + ": " +  e.message+ "\n"+ e.getStackTrace());
        loader.loadBytes(ba);

  • Streaming music to bluetooth device

    I just got a Motorola T505 Bluetooth for the car. It works great on a call but I can't get the music from my Iphone/Ipod to play on the T505. It is supposed to if they are paired which they are and the instructions say it must be paired and streaming??

    Here is an article from the apple support website that might help out.
    http://support.apple.com/kb/HT1841

  • Read byte stream from socket

    Hi, i must create a socket to a telnet server. I must read the server answer. How can i read the input stream and print it? The server's response is not necessarily a line.
    Thanks,
    Andrea

    {http://bytes.com/groups/net-c/629260-reading-network-socket-stream-slow-connection                                                                                                                                                                               

  • How to get data from bluetooth device?

    Hi,
    I'm trying to create an application in which I want to communicate with another bluetooth device for data. As I know using GameToolKit framework we can communicate with another iPhone or iPod device, but in my application I want to get data from different bluetooth device.
    Is it possible in iphone SDK? If yes, can somebody help me out?
    Thanks.

    avinash.ng wrote:
    manage to get data from other devices via the bluetooth ?
    You might want to look over the External Accessory framework, released with 3.0.
    ...keep in mind, however, that the only way to communicate with other BT devices via the EAF is if they are in the 'Made for iPod' accessory program. http://developer.apple.com/iphone/program/accessories/
    However again.... Even though they communicate through standard BT connections, accessories need special hardware in order to process the data stream coming from the iPhone / iPod touch. Unfortunately, this may mean that any idea of communicating with generic BT devices won't work on iPhone OS 3.x.
    If the devices you want to talk to are Bonjour-discoverable via WiFi, they don't need to be part of the MfI program. Does that sound like your case?
    Also you may want to keep in mind that 3rd. party devs in the future may release dongles that connect via the 30-pin dock port, providing access to existing BT devices. If said devs opened their communication protocols, that might enable the goal of communicating with said devices.

  • Data stream from OEM device, TCP/IP "not enough memory"

    Hi Everyone,
    I'm trying to catch a data stream from an OEM device over a TCP/IP link.  I can start the data stream, or pause/resume it, but the OEM device determines when the data stream has ended.  The data stream begins, and within 20 seconds, I get the famed "not enough memory" error.  Once this happens, data is lost from the stream, and quite often the final message indicating completion is missed.  I see two solutions to this.  1) Watch how many bytes are backed up on my TCP/IP port, and issue a pause command until I can process the backed up bytes at which point a resume will be issued.  ...or 2) Use my application's memory usage in the same manner.  Does anyone know how to do either of these things?
    Thanks much

    Hi Toader,
    Thanks for your response.
    1) I'm not sending any data.  I'm trying to consume an incoming data stream which is being driven by an OEM device.  This device basically has an FPGA hooked up to a 100Mbit/s hose.  You can start it, pause it and resume it.  Those are the available operations related to consuming the data stream.  I think the crux of the problem is deciding when to pause the OEM device to give the LabView app a chance to process and store the accumulated portion of the data stream.
    2) Sure, but it's not my program and is large and complicated.  I guess I could write my own program within a program, but I would rather use the existing architecture.  I might write my own micro app, but I doubt it will keep up with the FPGA driven hose.  If I could detect the condition leading up to the "not enough memory" error, which it seems many LV developers have encountered, but not really solved, then I could issue a pause to the OEM device.
    3) Well using a LabView application under a 2Ghz Windows box may not be sufficient hardware.  But I really think it's the Windows operating system that I'm having trouble with, not the hardware platform.
    I've tried several counters in the LabView application, watched task manager before/during/after the "not enough memory" error, and downloaded an interesting app called taskmanager.vi in an attempt to get something to correlate with the error message.  I've not succeeded yet.  Here's what I think is happening.  The Windows OS is managing my wireless hardware, when it receives a TCP/IP packet, it puts it in the Windows Message que of my LabView application.  I think the "not enough memory" error relates to a Windows OS allocation for my message que which is being exceeded.  Any Windows programmers out there who would know how to look at the application's message que during runtime?
    Thanks for your classic suggestions Toader, I may try a micro app which is spawned by the main app when its time to grab the data.  My intuition is that no software limited by the Windows OS is going to keep up with single minded FPGA hardware.
    I thought this very interesting discussion was the answer and it may still be, but after trying 30+ various counters under Memory, System, Process, TCP, and Server, none correlated to the error.
    http://forums.ni.com/t5/LabVIEW/System-monitor-counter/m-p/1653448/message-uid/1653448/highlight/tru...
    I also tried a taskmanager.vi, but none of the various flavors of memory tracked by that little gem correlated with the error either.  At this point, I started to wonder "what memory was there not enough of?".
    Terry

  • Having trouble opening connections and reading from Bluetooth devices.

    Hello,
    As the title states, I am having trouble opening connections and reading data from a Bluetooth device. We are using a PDA to communicate with LabVIEW. First, the Bluetooth Open Connection VI displays a timeout error half of the time. Second, when it does open, it does not read what the PDA is sending. Third, if it does allow an open connection, it will not do it a second time unless the devices are turned off.
    I also have another related question. I am using a Linksys Bluetooth USB adapter, and the driver is proprietary. Labview requires the use of a Microsoft driver, and we are having problems going back and forth between the drivers. What Bluetooth receiver would you suggest using? The reason I ask is the fact that you have Bluetooth examples of client VI's. Therefore, you must use a similar device. Thank you for your time.
    -Jon

    Hi Jon,
    I'm not sure what Bluetooth receivers were used to verify the functionality of the VIs. However, I still want to help you solve your issue. Please make sure that you are running the shipping examples and let me know what version of LabVIEW, what PC OS and what PDA OS you are using. Does the Microsoft driver work for your Bluetooth receiver if you uninstall the Linksys driver?
    With your answers I'll do my best to help you out.
    - Philip Courtois, Thinkbot Solutions

  • Help with Sample on Converting an XML string to a byte stream

    Hello All,<br /><br />I am sure this is something simple, but I am just not figuring it out right now.<br /><br />I am following the sample - "Converting an XML string to a byte stream" from the developer guide since I want to prepopulate just 1 field in my PDF form.<br /><br />How do I reference my form field within my servlet code properly??<br /><br />I have tried a few things now, my field is within a subform, so I thought it would be <root><subformName><fieldname>My data</fieldname></subformName></root>  I have also tried adding <page1> in there too.<br /><br />I am following everything else exactly as given in the sample code.<br /><br />I do have an embedded schema within the form and the field is bound.<br /><br />Thanks,<br />Jennifer

    Well, if you have a schema defined in the form, then the hierarchy of your data must match what is described in the schema. So, can't really tell you what it would look like, but just follow your schema.
    Chris
    Adobe Enterprise Developer Support

  • Parsing input stream from a socket

    Hi, i must read a byte stream from a socket. My problem is that i cannot determine when a stream ends because there are no terminator characters. I tried to use the read() method of BufferedReader class but it blocks when server statement ends. Is there a way to read the stream and answer to the server?
    Thanks,
    Andrea

    andmus wrote:
    Hi, i must read a byte stream from a socket. My problem is that i cannot determine when a stream ends because there are no terminator characters. I tried to use the read() method of BufferedReader class but it blocks when server statement ends. Is there a way to read the stream and answer to the server?
    If you're reading HTTP...
    Unless the request has been sent with Connection: close, it's normal that your read blocks, since the connection is purposefully left open to accomodate further exchanges.
    You'll have to parse the data to know when each message is complete. The first empty line (bytes: \r\n\r\n ASCII) denotes the end of the header. The header will have a Content-Length property which tells you how many bytes are left to read.
    Google the HTTP specs if you don't know them.

  • Audio problem after disconnecting bluetooth device

    Hi All,
    I tried to setup a bluetooth headset with my computer a while back and have since abandoned that idea (which i'm okay with).
    Now though, my iChat won't send the audio to the computer's speakers.
    What setting do i need to change to get this working again?
    I've:
    - deleted the bluetooth headset from my bluetooth devices
    - tried to make sure the settings for AIM and iChat in my sound preferences were set to built in. My AIM setting is 'custom' and i don't seem to be able to change it.
    - checked iChat prefs for any setting that could control this. I saw a posting on the web that indicates an output drop box in the AV prefs but i don't have that (and i don't have a camera hooked up to my machine.
    Anyone have any advice for me?

    I'm not sure what you mean when you say that iChat won't send the audio to the computer's speakers. What audio?
    Things to try:
    1) Zap the parameter RAM by holding down the Command-Option-p-r keys (four keys) at startup until you hear the startup chime ring three times.
    2) If you're using the built-in speakers, try using external speakers or a USB headset.

Maybe you are looking for

  • I cannot get the internet through firefox, but IE is O.K. -- Sometimes it only occurs if I click on a link, andthe link will not open in a new tab, but it can a

    Will someone please send me an email address that I can send the screen dumps to. The pictures with descriptions are much better than anything that I can write here. I really want to use FF, so please help me. PS: I've updated exceptions in both the

  • 10.4.8 and Cisco/VPN problem solved

    Hi, This and related issues have arisen in threads on the past month, regarding the Cisco VPN v 4.9005 (and perhaps other VPN software) not working the same after the 10.4.8 upgrade. The problems relate to either not making a VPN connection, or data

  • Essbase 9.3.1 Standalone Installation Error

    Hello Expects, I am facing the issues with Essbase Standalone Installation(version 9.3.1) and Error is the below. java.lang.NoClassDefFoundError:run Exception in thread "main" Please respond on the above error, if anybody know about it. Thanks & Rega

  • ORA-01555 error ?

    I found one ora-01555 error in alert log at 14:37PM.But when i run the following query select ssolderrcnt from v$undostat where to_char(begin_time,'hh:mi:ss')='14:00:00' and to_char(end_time,'hh:mi:ss')='15:00:00' no rows selected is getting It has t

  • Why can't i reach the required sampling frequency?

    Hi every one, I've got troubles with my program. I wanted to measure signals from PT100 and thermocouples, but whereas my card (NI SCXI 1102B card for the thermocouple, and a PCI-6220 card for the PT100) can support 333kS/s, I can't go faster than 40