Ok, hopefully I can explain a little better by showing the code I am using
This is part of the 638 byte packet that I am trying to send:
Code:
NSString *rootLayer=@"001000004153432d45312e3137000000726e00000004c0de0080c69b11e095720800200c9a66";
If I send that out as a string without interpreting it as hex values then I get this:
Code:
30 30 31 30 30 30 30 30 34 31 35 33 34 33 32 64 001000004153432d
34 35 33 31 32 65 33 31 33 37 30 30 30 30 30 30 45312e3137000000
37 32 36 65 30 30 30 30 30 30 30 34 63 30 64 65 726e00000004c0de
30 30 38 30 63 36 39 62 31 31 65 30 39 35 37 32 0080c69b11e09572
30 38 30 30 32 30 30 63 39 61 36 36 0800200c9a66
As you can see it is sending the exact string that I told it to. I don't want this. I need to send that string as
hexbinary values not ascii chars.
When I take the string above and run it through my code to interpret the string as hex, I get this:
Code:
00 10 00 00 41 53 43 2d 45 31 2e 31 37 00 00 00 ....ASC-E1.17...
72 6e 00 00 00 04 c0 de 00 80 c6 9b 11 e0 95 72 rn..............
08 00 20 0c 9a 66 .. ..f
As you can see, this time it sent the actual
hexbinary codes that I want to send on the wire.
I just reread the post from the link that was posted earlier (which is where I got my code from). Here is probably an easier way of trying to describe what I am doing:
I have an NSString of hexadecimal digits like this:
Code:
NSString *rootLayer=@"001000004153432d45312e3137000000726e00000004c0de0080c69b11e095720800200c9a66";
And I want to change it to NSData like this:
Code:
NSData *rootLayer=<00100000 4153432d 45312e31 37000000 726e0000 0004c0de 0080c69b 11e09572 0800200c 9a66>;
Above, in red, I have corrected the most obvious incorrect uses of the word "hex".
You haven't explained how the hex string came to be. Is there a function or method that built it? From what data? Why doesn't that function or method return binary?
An NSData object is a container for a sequence of binary bytes. That is, its contents are binary. When the contents are displayed, as in <00100000 ..., the values are shown as hexadecimal (i.e. hex), even though the contents remain in binary.
I see that while I was typing this chown33 replied and asked me some questions. I will do my best to answer them
I have posted some real data above. The lights that I am trying to control are christmas lights. Each pixel has three separate rgb leds in them.
What is the manufacturer or brand of the lights? What is the model number (if any)? What country were they sold in? What year?
Or did you make them yourself?
Or did someone else make a custom design just for you?
I have the specs on the data that I need to send to them to turn them on, off, change color, intensity.
Is the spec available online? What's the URL?
I can provide the full breakdown of the packet but to be honest at this point that is the one thing about my project that I do understand
Which doesn't really help anyone else gain an understanding. To do that, you'd have to clearly identify the product, the protocol, where to get detailed information, etc. Please do so.
The above data that I posted is what is called the Root Layer for my packet.
Is that called the Root Layer because that's what the actual protocol spec calls it, or is that just your name for it? Again, not having access to the actual protocol spec impedes everyone else's understanding.
Here is the full breakdown of it:
Code:
00 10 - Define RLP Preamble Size
00 00 - RLP Post Amble Size
41 53 43 2d 45 31 2e 31 37 00 00 00 - Identifies packet as E1.17
72 6e - Protocol flags and Length
00 00 00 04 - Identifies RLP Data as 1.31. Protocol PDU
c0 de 00 80 c6 9b 11 e0 95 72 08 00 20 0c 9a 66 - Senders SID
So, a little clearer?
Not as much as you might think.
Does RLP means "Root Layer Packet"?
I have no idea what E1.17 means, nor how that relates to the protocol or the device. In other words, why would anyone care that the packet is identified as E1.17?
The values of 72 6e as protocol "length" suggests a non-obvious encoding of length. Again, a protocol doc would explain how length is encoded, so someone could simply read it rather than posting queries.
I can't tell what RLP or Protocol PDU means. No idea what 1.31 means either.
What's a SID, and why does a sender need one?