-
Notifications
You must be signed in to change notification settings - Fork 170
Binary protocol over bluetooth #82
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
Open
raduiliescu
wants to merge
5
commits into
StephenBlackWasAlreadyTaken:master
Choose a base branch
from
raduiliescu:binary_proto_pull
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
67bab23
binary_protocol: add support for unpacking binary data
raduiliescu a7bdd1b
binary_protocol: add a placer for binary packet info
raduiliescu e47f67d
binary_protocol: decode binary data packet
raduiliescu 1447550
binary_protocol: add support for binary protocol on ble bluetooth
raduiliescu 279a207
binary_protocol: add versioning support and fallback to current strin…
raduiliescu File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
8 changes: 8 additions & 0 deletions
8
app/src/main/java/com/eveningoutpost/dexdrip/Models/DexdripPacket.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,8 @@ | ||
| package com.eveningoutpost.dexdrip.Models; | ||
|
|
||
| /** | ||
| * Created by Radu Iliescu on 25.02.2015. | ||
| */ | ||
| public class DexdripPacket { | ||
| public static final int PACKET_DATA = 1; | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
52 changes: 52 additions & 0 deletions
52
app/src/main/java/com/eveningoutpost/dexdrip/utils/PacketUtil.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,52 @@ | ||
| package com.eveningoutpost.dexdrip.utils; | ||
|
|
||
| import java.nio.ByteBuffer; | ||
| import java.nio.IntBuffer; | ||
| import java.nio.LongBuffer; | ||
| import java.nio.ShortBuffer; | ||
|
|
||
| /** | ||
| * Created by Radu Iliescu on 26.02.2015. | ||
| */ | ||
| public class PacketUtil { | ||
| public static int int32FromBuffer(byte data[], int offset) { | ||
| ByteBuffer bb = ByteBuffer.wrap(data, offset, 4); | ||
| IntBuffer sb = bb.asIntBuffer(); | ||
| return sb.get(); | ||
| } | ||
|
|
||
| public static int uint32FromBuffer(byte data[], int offset) { | ||
| int ret = int32FromBuffer(data, offset); | ||
|
|
||
| if (ret < 0) { | ||
| ret += 1 << 32; | ||
| } | ||
|
|
||
| return ret; | ||
| } | ||
|
|
||
| public static int int16FromBuffer(byte data[], int offset) { | ||
| ByteBuffer bb = ByteBuffer.wrap(data, offset, 2); | ||
| ShortBuffer sb = bb.asShortBuffer(); | ||
| return sb.get(); | ||
| } | ||
|
|
||
| public static int uint16FromBuffer(byte data[], int offset) { | ||
| int ret = int16FromBuffer(data, offset); | ||
|
|
||
| if (ret < 0) { | ||
| ret += 1 << 16; | ||
| } | ||
|
|
||
| return ret; | ||
| } | ||
|
|
||
| public static int uint8FromBuffer(byte data[], int offset) { | ||
| int ret = data[offset]; | ||
|
|
||
| if (ret < 0) { | ||
| ret += 1 << 8; | ||
| } | ||
| return ret; | ||
| } | ||
| } |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
First off, this PR is super cool, my biggest issue is that I dont want an app update to make someones currently functional wixel stop being able to communicate with xDrip, can we split this setSerialDataToTransmitterRawData and have it go down two logical paths, one if its the old style, one if its the new style,
Also I would love it if the start of each of these new packets was a version number (this being version 1, that way if we down the road add in some more params we can easily check which version of the a transmitter data parser to use)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Have added a fallback mechanism see line 397