-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
OpenThread API: How to get child table using OpenThread API? #5259
Comments
@BusKetZz yes. That would work. You can use
Or you can check the CLI |
@abtink static void get_child_table(otInstance *instance, otChildInfo *child_table, uint16_t max_children)
{
for (uint16_t child_index = 0; child_index < max_children; child_index++) {
if (otThreadGetChildInfoByIndex(instance, child_index, child_table[child_index]) == OT_ERROR_NOT_FOUND) {
break;
}
}
} Would it work? |
I think you want to go through all entries (entire range of indexes) and skip over the ones that are not found, i.e., do cannot |
So let's modify it a little bit: static void get_child_table(otInstance *instance, otChildInfo *child_table, uint16_t max_children)
{
for (uint16_t child_index = 0; child_index < max_children; child_index++) {
otThreadGetChildInfoByIndex(instance, child_index, child_table[child_index])
}
} This way, I can form UDP payload consisting of an array of |
@BusKetZz , you want to follow the pattern I mentioned in the first reply, i.e. go through all indexes, skip over the ones that |
@abtink static void get_child_table(otInstance *instance, otChildInfo *child_table, uint16_t max_children)
{
otChildInfo child_info;
for (uint16_t child_index = 0; child_index < max_children; child_index++) {
if (otThreadGetChildInfoByIndex(instance, child_index, child_info) == OT_ERROR_NONE) {
*child_table = child_info;
child_table++;
}
}
} Forgive me that I show and ask for help while prototyping, but I think this is the best place to do that :) |
I have additional problem with the build process:
Similary the same issue with
Should I add some files into build process? As I see, file implementing this API is included into compilation so I do not understand why it is not working. I have added |
@BusKetZz , the You should either:
Again, you can refer to the CLI code for example usage. |
@jwhui |
@BusKetZz , if you are using the convenience makefiles in openthread/examples/Makefile-cc2538 Lines 44 to 52 in 57ee45b
Remove mentions of |
Thank you very much for all the information. I have solved my issue by adding |
Hello Guys!
I am not sure whether it is a good place to ask such a question nevertheless I hope you will help :)
I have the OpenThread CLI application and I would like to create UDP datagram with the payload consisted of child table information.
So my question is: how to get child table info and which API should I use?
I have done some research, and I consider to play with otThreadGetChildInfoByIndex() placed in for/while loop. Does it make sense??
Best regards!
The text was updated successfully, but these errors were encountered: