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

Not able to add the event subset. #2

Open
maunishpatel1 opened this issue Sep 14, 2023 · 9 comments
Open

Not able to add the event subset. #2

maunishpatel1 opened this issue Sep 14, 2023 · 9 comments
Labels
question Further information is requested

Comments

@maunishpatel1
Copy link

maunishpatel1 commented Sep 14, 2023

Hey,

I am adding a new subset with the prefix 'e'. I want the data to be published whenever the value is updated. However, I am continuously receiving published data but the value has not changed.

I have added the following lines to my application, but they are not functioning as expected.


THINGSET_ADD_GROUP(TS_ID_ROOT, 0x02, "Sample", THINGSET_NO_CALLBACK);
THINGSET_ADD_ITEM_UINT32(0x02, 0x40, "rCounter", &counter, THINGSET_ANY_R, 0);
THINGSET_ADD_ITEM_UINT32(0x02, 0x41, "wCounter", &counter, THINGSET_ANY_RW, 0);


I am trying to display the data using the shell command, but the rCounter and wCounter nodes are not being displayed.


uart:~$ thingset ?
85 {"Sample":null,"pNodeID":"E9C101C32B6A8827","pNodeName":"Thermo","_Reporting":null}


Please let me know if there is anything I am doing wrong.

Thanks in Advance,

@martinjaeger
Copy link
Contributor

Hi @maunishpatel1

I am adding a new subset with the prefix 'e'. I want the data to be published whenever the value is updated. However, I am continuously receiving published data but the value has not changed.

The prefix is mostly for processing the data by a cloud backend or an app. Just adding the e prefix won't make it event-based, as the ThingSet SDK cannot detect when data is changed in RAM. It points to the same data as the application uses.

So, if you want something to be event based (e.g. publish a report after each change in a state machine), you'll need to call e.g. thingset_ble_send_report("eYourEventSubset") from that state machine.

I am trying to display the data using the shell command, but the rCounter and wCounter nodes are not being displayed.

uart:~$ thingset ? 85 {"Sample":null,"pNodeID":"E9C101C32B6A8827","pNodeName":"Thermo","_Reporting":null}

You added a group "Sample" and put the counters into that group. In order to get values of that group, run the following command:

uart:~$ thingset ?Sample

Hope that helps.

@maunishpatel1
Copy link
Author

Hi @martinjaeger,

Thank you for your prompt response!

I understand your point and have also noticed the same thing in the SDK source for the event-based subset.

I added the TemperatureValue and SerialNumber data under the TemperatureSensor sensor group, as shown below.


uart:~$ thingset ?
:85 {"TempratureSensor":null,"ImuSensor":null,"pNodeID":"E9C101C32B6A8827","pNodeName":"ThingSet Node","Log":null,"Reporting":null,"mLive":["Log/t_s","TempratureSens}

uart:~$ thingset ?TempratureSensor
:85 {"TempratureValue":25,"SerialNUmber":""}


I also enabled live notifications for some of the data.


#mLive_ {"Log":{"t_s":0},"TempratureSensor":{"TempratureValue":25,"SerialNUmber":""},"ImuSensor":{"Gyro":0,"SerialNUmber":""}}
#mLive_ {"Log":{"t_s":0},"TempratureSensor":{"TempratureValue":25,"SerialNUmber":""},"ImuSensor":{"Gyro":0,"SerialNUmber":""}}
#mLive_ {"Log":{"t_s":0},"TempratureSensor":{"TempratureValue":25,"SerialNUmber":""},"ImuSensor":{"Gyro":0,"SerialNUmber":""}}


Currently, I'm trying to access the live notification using the shell command. To remove the TemperatureValue node from the live notification, I'm using the commands mentioned below.


uart:~$ thingset -mLive_ "TempratureSensor/TempratureValue"
:AF
#mLive_ {"Log":{"t_s":0},"TempratureSensor":{"TempratureValue":25,"SerialNUmber":""},"ImuSensor":{"Gyro":0,"SerialNUmber":""}}


However, we received an error: AF(THINGSET_ERR_UNSUPPORTED_FORMAT). Do you have any suggestions on what I might be doing wrong?

Best regards,

@martinjaeger
Copy link
Contributor

I guess you have to escape the quotation marks in the shell. Try this:

uart:~$ thingset -mLive_ \"TempratureSensor/TempratureValue\"

@maunishpatel1
Copy link
Author

Thanks @martinjaeger,

Awesome!

It's working fine.

Regards,

@maunishpatel1
Copy link
Author

maunishpatel1 commented Sep 21, 2023

Hi @martinjaeger,

I'm using binary mode in my application and have looked over the details provided in https://thingset.io/spec/v0.6. I have a few questions about this mode:

  1. Does UART communication in binary mode have CRC support?
  2. Can we do live data streaming in binary mode?
  3. Also I cannot use the shell when using the serial and binary mode.

Regarding the records, I have a couple of questions:

  1. Can I create a subrecord under a main record?
  2. How can I access that subrecord using the ThingSet shell commands?

Thanks in advance,

@martinjaeger
Copy link
Contributor

  1. Does UART communication in binary mode have CRC support?

The binary mode is currently not supported for the UART, see here:

image

However, it would be possible to use the same packetization mechanisms as used for BLE.

If you need this and would like to implement it, I'm happy to support.

  1. Can we do live data streaming in binary mode?

Once binary works over serial, it can also be used to send live data.

  1. Also I cannot use the shell when using the serial and binary mode.

The shell will not work in binary mode. It's text-mode only.

Regarding the records, I have a couple of questions:

  1. Can I create a subrecord under a main record?

No, that's currently not possible. Records are already a sort of trick to make the data more dynamic with static memory allocation. Adding a sub-record would under another record would probably be very difficult to implement in C.

@maunishpatel1
Copy link
Author

Thanks a lot, @martinjaeger ,

I find your assistance truly helpful! However, I have a few doubts. Could you please take a look at the data format I wish to achieve? I've attached the file below.

So as we can not create the subrecord under the record is there any other method to achieve the same?

I require that particular data structure for my application. I am simply clarifying the format of the data.

Within the "Sen" node, there are multiple sets of data such as "Ty", "Ser", and "ECG". The "ECG" data is presented in pairs of "V" and "T". The number of "v" and "t" pairs can vary.

How can I achieve this using thingset data format?

data.txt

@martinjaeger
Copy link
Contributor

Unfortunately, such a data structure is not possible at the moment, if both records need to be able to fit a variable amount of data.

@maunishpatel1
Copy link
Author

maunishpatel1 commented Sep 25, 2023

Hello @martinjaeger,

Thank you for reaching out to me.

I see that such a data structure is not possible, which is perfectly understandable. I was wondering, is it possible to add new records dynamically during runtime based on certain events or data you receive?

Currently, while streaming, the record's data is not being streamed. Instead, the number of records is being streamed. Is there any way to stream the data itself?

Also, I was wondering if we could add new nodes inside any group at runtime.

Thank you for taking the time to read this, and I look forward to hearing back from you.

Take care,

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Further information is requested
Projects
None yet
Development

No branches or pull requests

2 participants