Question
I'm developing an application using the IotCon feature on Tizen TV, but I'm encountering issues with CBOR file handling. Here's what I've done:
- Initialized IotCon with
tizen.iotcon.initialize("mnt/host/server.dat")(server.dat file is created automatically) - Created a server and a Door Resource
- Verified that all resources (including my Door Resource) are discoverable using Iotcon Client
- However, GET requests to the Door Resource consistently fail
I suspect the issue lies with the CBOR file:
- When converting it to JSON, I don't see any Door Resource information
- Manual modifications to the JSON (and conversion back to CBOR) prevent server initialization
- Even converting the original CBOR to JSON and back without modifications causes initialization failures
How can I generate a working CBOR file that's compatible with Tizen TV?
Answer
Problem Understanding
The issue appears to stem from improper CBOR file generation or handling in the IotCon implementation. The server fails to initialize when the CBOR file is modified or regenerated, suggesting strict validation requirements.
Solution Methods
-
Use Official Tools for CBOR Generation:
- Instead of manual conversion, use Tizen's provided tools for generating CBOR files
- Ensure the CBOR file includes all required resource definitions before server initialization
-
Verify Resource Registration:
- Double-check that your Door Resource is properly registered before attempting to access it
- Confirm the resource path and attributes match exactly in both your code and CBOR file
-
Debugging Steps:
- Enable detailed logging in IotCon to identify where the initialization fails
- Compare your generated CBOR file with a known working example
Code Examples
// Example of proper resource registration
var doorResource = {
uri: '/door/1',
resourceTypes: ['oic.r.door'],
interfaces: ['oic.if.baseline'],
properties: {
state: 'closed'
}
};
tizen.iotcon.registerResource(
doorResource.uri,
doorResource.resourceTypes,
doorResource.interfaces,
function() {
console.log('Resource registered successfully');
},
function(error) {
console.error('Resource registration failed: ' + error.message);
}
);
Additional Tips
- Always validate your CBOR files using Tizen's validation tools before deployment
- Consider testing with minimal resource configurations first
- Check for platform-specific limitations in the Tizen TV documentation