I try to create Asynchronous(non-blocking) request in my J2me application.
my httpconnection is running perfectly in all nokia devices
but in samsung devices sometime it does- create connection.
code is:
httpConn = (HttpConnection) Connector.open(uri);
httpConn.setRequestMethod(HttpConnection.GET);
httpConn.setRequestProperty("User-Agent","Profile/MIDP-1.0 Confirguration/CLDC-1.0");
respCode = httpConn.getResponseCode();// code break here
this code is running perfectly in nokia devices
but i am facing this issue in samsung devices.
This problem was because of http Request URL length handling i.e. it varies from phone to phone. On this particular series phone max http URL length was very low so i have managed my data in Request header or best approach is to use HttpPost.
Related
I have a peripheral device that needs to be paired with a pin to access its characteristics or perform read/write operations.
Here is a code snippet of what I have been doing till now.
const server = await device.gatt.connect();
console.log(`Bluetooth: Got server:`, server);
const service = await server.getPrimaryService(currentService.uuid);
let characteristic2 = await this.state.service.getCharacteristic(
currentService.characteristicsUUID[1]
);
await characteristic2.writeValue(new Int8Array([1]).buffer);
It shows that characteristicAttrib2.writeValue() is not permitted, even though the read and write access is provided by the characteristic of this service because the device has not been paired using pin. I just want to know if there's any API in web-ble using which the browser can request PIN while paring with the device? And only after pairing with that pin it will provide access to the peripheral device.
The Chromium team is currently working on adding support for pairing with devices when necessary to access protected characteristics. This currently happens automatically on Android and macOS but not on Windows, Linux and Chrome OS.
Follow along on this issue for updates.
I'm implementing a bacnet library to read and write some object instances.
But I don't understand, why with a PC and with an application like Yabe if I ask to a common controller to read more than 300 objects, the segmentation is supported, instead with a mobile phone and on the same request to the same controller the segmentation is not supported.
Both the PC and the smartphone are in the same network on Wifi.
So what is the problem/difference?
It is nothing to take with a PC or a mobile phone. Any IP compatible devices mobile phone, desktop, laptop, Arduino chips will work with BACnet.
Your problem is segmentation. You will have to handle the segmented messages coming from the Controller.
Every BACnet controller vendor specifies the MaxApduLength (i.e max length of data to be transferred within one UDP packet). The standard APDU length is 1476 bytes. So a BACnet controller cannot send the data more than the length of APDU specified within it.
Requesting 300 objects from a controller results definitely in a large APDU than the controller's limit. In this case Controller will send you segmented messages each with sequence number. You will have to handle this all segmented messages and combine them in one message then only you will get exact response. This is same with Yabe and other BACnet clients.
I have also written BACnet libraries for our mobile applications in Java and Swift 4.0 and both can read any number of objects from controller with segmentation support added. I have tested these with controllers having more than 400 objects.
Segmentation is used for APDUs (responses) that are too large to fit in one frame on the datalink. If both devices support segmentation, then great. If one of the device does not support segmentation, and the APDU does not fit, then "Segmentation not supported" error is issued. (and you have to then retry a smaller request).
As part of my requirement, we need to have paring connection between microcontroller (Cortox M3) and Mobile or Pc. We are using Alpwise stack for our purpose. My problem is with the controller configurations, not with the mobile, because without paring i am able to work with it.
Where should i the API "BLESMP_InitiatePairing" api. Presently i am calling the api inside GAP_callback function, inside BLEGAP_EVENT_CONNECTED.
Is this a correct location to call at this API, because if i call over here, control goes to BLEEVENT_PAIRING_COMPLETE (returning SMERROR_UNKNOWREASON) then it goes into BLEEVENT_PAIRING_REQUEST then once again it goes into
BLEEVENT_PAIRING_COMPLETE (returning SMERROR_UNKNOWREASON). Whereas when i call "BLESMP_InitiatePairing" api, it returns me with success message
(You listed the core-bluetooth tag, so I'm assuming you want to use iOS.)
I don't know the specific stack you are using. However, if you are developing an LE peripheral and want to connect with an iOS device as central, it is sufficient to reply to a read / write request with an InsufficientAuthentication error code. iOS will then initiate pairing from its side.
More details on this process can be found in the Bluetooth Accessory Design Guidelines for Apple Products Section 3.9.
The use case is that a user starts playback from their iPhone, lets say, and then picks up their iPad (both running my app) and wants to contect to and control the running video from this other iOS device.
On iOS, I do not see any way to determine if there is a instance of my receiver app already running on the Google ChromeCast device. Once I create my session it seems the only thing I can do is to attach a new protocol message stream, which interrupts whatever might be playing already.
It this suppose to be handled in the iOS client side Framework, perhaps there is some coding I need to do in the HTML receiver app?
Thanks.
There is a way outside the API to determine if an app is running. Do a HTTP GET on the apps URL for the ChromeCast IP address: http://192.168.0.x:8008/apps/
If the HTTP response is 200, nothing is running. If the HTTP response is 204, then an app is running and the HTTP response would be redirected to a URL like: http://192.168.0.x:8008/apps/GoogleMusic
Which tells you which app is running.
Interestingly, Google Play Music cannot be controlled by 2 devices simultaneously, but YouTube can. I suspect Play Music is using RAMP which is what the Cast SDK does for media streams. YouTube could be using a proprietary message stream to control the media playback. So you might have to do the same if you want to have the an app on a device controlled by multiple sender apps.
One method is to check the playStatus after you start your session and before you initiate a loadMedia(). If your app is already running - it should return a non-nil (ie. IDLE, PLAYING, ...) result.
I am new to the J2ME technology. And I am making an application which will transfer the text and image(downloaded through http and stored into an ImageItem of a form) from a client mobile to the server mobile using bluetooth. The connection used is SPP. I have succeded to transfer the text message. But I am unable to transfer the image.
Can anyone help me to transfer the image to the server mobile through bluetooth directly without saving it into the phone memory or memory card.,
I would be thankful to you.
javax.microedition.lcdui.Image.getRGB() is the method you are looking for.
If myImageItem is your ImageItem object, the code would look like this:
------------
Image myImage = myImageItem.getImage();
int[] myImageInts = new int[myImage.getHeight() * myImage.getWidth()];
// Beware of OutOfMemoryError here.
myImage.getRGB(myImageInts, 0, myImageInts.length, 0, 0,
myImage.getWidth(), myImage.getHeight());
------------
You can then convert each int in the array into 4 bytes
(in the correct order please)
and feed these to your Connection's OutputStream.
Alternatively, DataOutputStream.writeInt() does the conversion for you.
Well if your server mobile is using Bluetooth and also running an application written by you, then you can create your own protocol to do this.
For image transfer, it is best to send the bytes that were downloaded over HTTP (and used to create the ImageItem), then receive them at the server end and display in the same way.
What is the specific problem you're encountering while doing this?
funkybro
As funkybro suggested, you can use the bytes to transfer the image to the server mobile. For that you need to can just open the output stream of the connection that you have made to the bluetooth server mobile and then write the byte contents on to the output stream.