Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixed issue of writing 13 bytes sendSerialMessage with causes error Received message of unknown type 0x0001 #37

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -261,6 +261,23 @@ public void onReadRemoteRssi(final int rssi) {
// No need to assert anything, implicit success based on connection latch
}

@Suppress
public void testSerialMessages13Bytes() throws Exception {
final CountDownLatch testCompletionLatch = new CountDownLatch(1);
Bean bean = discoverBean();
synchronousConnect(bean);
bean.sendSerialMessage(new byte[] { 65, 65, 65, 65, 65, 65, 65,
65, 65, 65, 65, 65, 65 });
bean.readLed(new Callback<LedColor>() {
@Override
public void onResult(LedColor result) {
testCompletionLatch.countDown();
}
});
testCompletionLatch.await(10, TimeUnit.SECONDS);
synchronousDisconnect(bean);
}

@Suppress
public void testFastSerialMessages() throws Exception {
int times = 100;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -204,11 +204,11 @@ public void sendMessage(Buffer message) {
}

// create packet, add to queue, schedule
int packets = (int) (message.size() / PACKET_TX_MAX_PAYLOAD_LENGTH);
int packets = (int) ((message.size() + PACKET_TX_MAX_PAYLOAD_LENGTH - 1) / PACKET_TX_MAX_PAYLOAD_LENGTH);
mOutgoingMessageCount = (mOutgoingMessageCount + 1) % 4;
int size = (int) message.size();
for (int i = 0; i < size; i += PACKET_TX_MAX_PAYLOAD_LENGTH) {
GattSerialPacket packet = new GattSerialPacket(i == 0, mOutgoingMessageCount, packets--, message);
GattSerialPacket packet = new GattSerialPacket(i == 0, mOutgoingMessageCount, --packets, message);
mPendingPackets.add(packet);
}
mHandler.post(mDequeueRunnable);
Expand Down