Jump into concepts and practice - no test required
or
Recommended
Test this pattern10 questions across easy, medium, and hard to know if this pattern is strong
Recall & Review
beginner
What does CBOR stand for and why is it useful for constrained devices?
CBOR stands for Concise Binary Object Representation. It is useful for constrained devices because it is a compact, efficient way to encode data, saving memory and bandwidth.
Click to reveal answer
beginner
How does CBOR differ from JSON in terms of data representation?
CBOR is a binary format, which makes it smaller and faster to parse than JSON, which is text-based. This makes CBOR better for devices with limited resources.
Click to reveal answer
intermediate
Name two key features of CBOR that make it suitable for IoT devices.
1. Compact binary encoding reduces data size. 2. Supports a wide range of data types including integers, strings, arrays, and maps.
Click to reveal answer
beginner
What is a practical example of CBOR use in constrained devices?
CBOR is often used in IoT sensors to send small packets of data like temperature or humidity readings efficiently over low-power networks.
Click to reveal answer
intermediate
Why is CBOR preferred over XML for constrained devices?
CBOR is much smaller and faster to process than XML, which is verbose and text-heavy, making CBOR better for devices with limited CPU and memory.
Click to reveal answer
What type of data format is CBOR?
AText
BBinary
CXML
DHTML
✗ Incorrect
CBOR is a binary data format designed for compactness and efficiency.
Which of these is a main advantage of CBOR for constrained devices?
ACompact encoding
BRequires high CPU power
CHuman-readable text
DLarge file size
✗ Incorrect
CBOR uses compact encoding to reduce data size, ideal for devices with limited resources.
CBOR supports which of the following data types?
AIntegers, strings, arrays, and maps
BOnly strings
COnly integers
DOnly arrays
✗ Incorrect
CBOR supports multiple data types including integers, strings, arrays, and maps.
Why is CBOR better than JSON for constrained devices?
ACBOR is text-based
BCBOR is slower to parse
CCBOR is binary and more compact
DCBOR uses more memory
✗ Incorrect
CBOR is binary and more compact, making it faster and smaller than JSON.
Which scenario best fits CBOR usage?
AStreaming video
BWebpage styling
CWriting large documents
DSending small sensor data packets
✗ Incorrect
CBOR is ideal for sending small, efficient data packets like sensor readings.
Explain what CBOR is and why it is important for constrained devices.
Think about how small devices need efficient data formats.
You got /3 concepts.
Describe a real-world use case where CBOR would be preferred over JSON or XML.
Consider devices with limited memory and network speed.
You got /3 concepts.
Practice
(1/5)
1. What is the main advantage of using CBOR on constrained devices?
easy
A. It uses a compact binary format to save space and power
B. It requires a lot of memory to encode data
C. It only works with large servers
D. It converts data into plain text for readability
Solution
Step 1: Understand CBOR format purpose
CBOR is designed to be a compact binary format, which means it uses less space than text formats.
Step 2: Relate to constrained devices needs
Small devices have limited memory and power, so saving space and power is crucial.
Final Answer:
It uses a compact binary format to save space and power -> Option A
Quick Check:
Compact binary = saves space and power [OK]
Hint: CBOR is compact binary, perfect for small devices [OK]
Common Mistakes:
Thinking CBOR uses more memory
Assuming CBOR is text-based
Believing CBOR only works on big servers
2. Which of the following is the correct way to represent an integer value 10 in CBOR hex notation?
easy
A. 0x0F
B. 0x1A
C. 0x18 0A
D. 0x0A
Solution
Step 1: Recall CBOR integer encoding
Small integers 0-23 are encoded directly in the initial byte with major type 0.
Step 2: Check hex for integer 10
Integer 10 fits in 0-23 range, so encoded as 0x0A (major type 0 + value 10).
Final Answer:
0x0A -> Option D
Quick Check:
Small int 10 = 0x0A [OK]
Hint: Small ints 0-23 encoded as single byte 0x00 to 0x17 [OK]
Common Mistakes:
Using 0x1A which is for 32-bit integers
Adding extra bytes unnecessarily
Confusing hex values for different types
3. Given the CBOR byte sequence 0x83 0x01 0x02 0x03, what is the decoded data?
medium
A. [1, 2, 3]
B. {\"1\": 2, \"3\": 4}
C. [0x83, 0x01, 0x02, 0x03]
D. Error: invalid CBOR
Solution
Step 1: Interpret initial byte 0x83
0x83 means array of length 3 (major type 4 + 3).
Step 2: Decode following bytes
Next three bytes 0x01, 0x02, 0x03 are integers 1, 2, 3 respectively.
Final Answer:
[1, 2, 3] -> Option A
Quick Check:
0x83 = array(3), then 1,2,3 [OK]
Hint: 0x80+N means array of length N [OK]
Common Mistakes:
Confusing array with map
Reading bytes as hex literals
Assuming syntax error without checking
4. You try to decode the CBOR data 0xA2 0x01 0x02 0x03 but get an error. What is the likely cause?
medium
A. 0x03 is not a valid CBOR byte
B. Integer keys must be strings in CBOR maps
C. Map length byte 0xA2 says 2 pairs but only 1 pair provided
D. CBOR does not support maps
Solution
Step 1: Analyze map length byte 0xA2
0xA2 means a map with 2 key-value pairs expected.
Step 2: Count provided pairs
Only bytes 0x01 and 0x02 provide one pair; 0x03 is extra byte, so incomplete data.
Final Answer:
Map length byte 0xA2 says 2 pairs but only 1 pair provided -> Option C
Quick Check:
Map length mismatch = error [OK]
Hint: Map length byte must match actual pairs [OK]
Common Mistakes:
Thinking keys must be strings
Assuming 0x03 is invalid byte
Believing CBOR lacks map support
5. You want to encode a sensor reading with temperature 22 and humidity 55 as a CBOR map. Which byte sequence correctly encodes this data?