I have an assignment to implementation of communication between 2 PC terminals using Ethernet.
There is no big deal in establishing network between 2 nodes. but the the big deal is "8 bit data sent on one node is to be decoded on the other node & the same is to be displayed & if possible though a front end window."
the specs for the front end window on the receiving node is as follows , say for example 10110101 is sent from node 1 , the same is to be decoded & interpreted as below using a frontend GUI window , A-On
B-off
C-On
D-On
E-Off
F-On
G-Off
H-On
So please someone suggest me is any other application available to see the decoding process on terminal or what are the steps i need to intiate.
All your suggestions are appreciated,
Thanks in advance,
I guess your specific solution depends on if you are allowed to use existing libraries. Either way I would checkout networkComms.net, an open source network library written in C#.
You could achieve your basic goal if you modify the basic send example (11 lines of code) here. Instead of sending a random string, send your 8 bits, and on the receiving end, rather than just writing the string to the console do something cleverer:
if (recievedString == "10110101")
{
//Do this
}
else
{
//Do this instead
}
If you are not allowed to use existing libraries and have to write something from scatch perhaps networkComms.net could act as a good guide?
Related
Its taking too long to write a single command on characteristics. I am using below code for a single command and a loop on it.
getConnObservable()
.first()
.flatMap(rxBleConnection -> rxBleConnection.writeCharacteristic(characteristics, command))
.observeOn(AndroidSchedulers.mainThread())
.subscribe(
bytes -> onWriteSuccess(),
this::onWriteFailure
);
Its taking almost 600ms to write on device. I need to write like 100 of commands 1 by 1.
Can anyone please explain what is the best way to do that batch operation
The best way to get the highest performance possible over BLE is to use the same RxBleConnection to carry out all writes—this means to mitigate the overhead of RxJava i.e.:
getConnObservable()
.first()
.flatMapCompletable(rxBleConnection -> Completable.merge(
rxBleConnection.writeCharacteristic(characteristics, command0)).toCompletable(),
rxBleConnection.writeCharacteristic(characteristics, command1)).toCompletable(),
(...)
rxBleConnection.writeCharacteristic(characteristics, command99)).toCompletable(),
))
.observeOn(AndroidSchedulers.mainThread())
.subscribe(
this::onWriteSuccess,
this::onWriteFailure
);
Additionally one could try to negotiate the shortest possible Connection Interval (CI) by subscribing to rxBleConnection.requestConnectionPriority(BluetoothGatt.CONNECTION_PRIORITY_HIGH, delay, timeUnit)
Further speedup can be achieved by setting bluetoothGattCharacteristic.setWriteType(BluetoothGattCharacteristic.WRITE_TYPE_WITHOUT_RESPONSE) if the peripheral/characteristic supports this write type.*
*Be aware that the internal buffer for writes without response is limited and depending on the API level behaves a bit differently. It should not matter for ~100 writes though.
In regards to this conversation:
RxAndroidBle is a Bluetooth Low Energy library and comparing it to Blue2Serial (which uses standard Bluetooth) in terms of performance is not the best thing to do. These have different use-cases—just like using a WiFi or Ethernet cable to get access to the Internet.
Best Regards
I am running the entire sample application provided in RxAndroidBle from scanning to discover services to writeCharacteristic. I am trying to debug into the flow and put a break point in onWriteClick() of the CharacteristicOperationExampleActivity.java file. Clicking the WRITE button does nothing. Break point wasn't caught.
Reading the instruction from the blog RxAndroidBle
Stating that discovering characteristic is optional for write. But the way this sample app's activities are setup, one has to go thru discovering the characteristics before the Characteristic Operation page will be shown. On the characteristic page, I selected the read/write characteristic entry to get to the Operation page. Isn't that the correct way to operate the app?
Also, is there a way to handle writeCharacteristic without having to discover its characteristics? I don't want to show the characteristic view and the user has to pick the correct characteristic to be able to read and write to the BLE device.
In any case, the sample app discovered my BLE device and connected to it but failed to write to it however. Does anyone have experience with RxAndroidBle, please help.
There seems to be a bug in the example - I couldn't make it to work (despite connecting the buttons were disabled) - will need to look into it.
As for the quick-fix you can replace the onConnectToggleClick() method with:
#OnClick(R.id.connect)
public void onConnectToggleClick() {
if (isConnected()) {
triggerDisconnect();
} else {
connectionObservable
.observeOn(AndroidSchedulers.mainThread())
.doOnSubscribe(() -> connectButton.setText("Connecting"))
.subscribe(
rxBleConnection -> {
Log.d(getClass().getSimpleName(), "Hey, connection has been established!");
updateUI();
},
this::onConnectionFailure
);
}
}
The sample application is not meant to be run with any particular BLE device so to show possible BluetoothCharacteristics of an unknown device it needs to perform an explicit discovery to present them to the user. When using the library with a known device you can safely use UUIDs of BluetoothCharacteristics you're interested in without performing the discovery (it will be done underneath either way but you don't need to call it explicitly).
Im working on a program to send and recieve SMS using a GSM modem and my computer.
I have gotten sending and receiving to work - well sort of.
Once in a while my program is sent into a total chrash due to modem is mixing up information about Radio Signal Strength Indication and alike, while also serving my program with the hex code for the message.
My code can handle the hex code just fine. but I have seen the following line popup while im decoding a byte stream:
^RSSI: 2
So far I've seen it send out values between 1 and 10.
Is there an AT Command that can disable them? I have no need for them.
Or alternative: Is there a general syntax for them, so I can filter them out before decoding?
Im leaning towards a filter solution. But that would be more easy to implement if I knew whenever modem is sending out on the form: "^SOMETHING: xxx", then It would be nice to know if it is always followed up be a delimiter say for instance "\r".
You should try turning off periodic messages as using AT^CURC=0.
Information regarding the AT^CURC command:
AT^CURC? Current setting of periodic status messages
AT^CURC=? See what you possible values are
AT^CURC=0 turn off periodic status messages
The best way to tackle this scenario would be to replace that part of the response with an empty string because otherwise, it will be difficult to check even if the command sent to disable it is working or not.
This regex will match all those. You can replace them ideally by an empty string.
(\\n|\\r|\\r\\n)\\^.*(\\n|\\r|\\r\\n)
It is the first time I work with this kind of application. Very little experience I have. And so do the stakeholders. They want something like an (flex AIR)application that is able:
save data locally if the application is close
synchronize data with the server side if needed
Now, it is time for me to "do something" to this requirement before it get fixed. I have so many questions, but here are some less silly one:
The requirement is about "Rarely" connected, not "Occasionally" connected, right?
If I can't change the requirement, what should I do, "hibernate" the AIR application like Windows OS or save only the data to local DB? Their possibility ?
Please give me some advice/recommendation.
Thanks,
P/S: Internally, we did discuss about ADEP Data Services features. And I have a sample from Adobe: http://help.adobe.com/en_US/enterpriseplatform/10.0/AEPDeveloperGuide/WS562be5d616a63050-3e6e4f7d131900899a6-8000.html ==> I don't think I have fully understood it :)
You could indeed save data locally in SQLITE on application close and next time the application is launched you can persist changes to server and retrieve updates if needed.
Depending on complexity and data volume of your application, you could:
[free] implement the synchronization logic by yourself using only remote
objects and polling
[free] implement messaging on BlazeDS (data push) so the server can push
updates in real time if needed
[expensive] use the all in one Adobe synchronization solution (LiveCycle)
It really depends on what kind of application and data we are talking about.
Cheers.
If possible you can use sharedObject...
public var _rememberSo:SharedObject;
_rememberSo = SharedObject.getLocal("loginData");
if (_rememberSo.data.username != undefined && _rememberSo.data.password != undefined)
{
txtUserName.text = _rememberSo.data.username ;
txtPassword.text = _rememberSo.data.password ;
chkSavePassword.selected = true ;
btnLogin.setFocus();
}
else
{
txtUserName.text="";
txtPassword.text="";
txtUserName.setFocus();
}
I have used for locally save the password.. you can use it as per your data...
It may not be the best choice but we did choose ADEP stuff:
Data model driven:
http://www.adobe.com/devnet/livecycle/articles/lcdses2_mdd_quickstart.html
--> which help to generate code for both server side DAO and SQLite DAO.
Adobe synchronization solution : here we create our own lastModified property to compare offline data and server data
If anyone follow our path in the future, pls note 3 things:
it is commercial, no opensource
the documentation is good but not STRAIGHTFORWARD
the samples are good but not STRAIGHTFORWARD
I had to spend 2 days to understand things. And we are now confidence with a fully
How do I discover how many bytes have been sent to a TCP socket but have not yet been put on the wire?
Looking at the diagram here:
I would like to know the total of Categories 2, 3, and 4 or the total of 3 and 4. This is in C(++) and on both Windows and Linux. Ideally there is a ioctl that I could use, but there doesn't seem to be any.
Under Linux, see the man page for tcp(7).
It appears that you can get the number of untransmitted bytes by ioctl(sock,SIOCINQ ...
Other stats might be available from members of the structure given back by the TCP_INFO getsockopt() call.
Some Unix flavors may have an API way to do this, but there is no way to do it that is portable across different variants.
If you want to determine wheter to add data or not: don't worry, send will block until the data is in the queue. If you don't want it to block, you can tell it to send(2):
send(socket, buf, buflen, MSG_DONTWAIT);
But this only works on Linux.
You can also set the socket to non-blocking:
fcntl(socket, F_SETFD, O_NONBLOCK);
This way write will return an error (EAGAIN) if the data cannot be written to the stream.