Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

OpenWSN firmware C code is written in module manner. It's similar with object-oriented programming, though C is not an object language. This structure keeps the code clear and expandable. This is usually used when you want to add a new feature to the code. To write in such way, first thing is to think about what variable that the feature should be maintained, what services that the feature can serve and what's the relationship with other modules in the code (e.g. the each layer protocol has a module corresponded). 

...

The new module variable type needs to be defined in neighbors.h file. When define a new module variable type, the type name has to be ended with suffix of vars_t. For example, neighbors_vars_t is the name of neighbors module type, like this:

...

Modify openwsnmodule_obj.h file

add following code  in openwsnmodule_obj.h.

Code Block
#include "neighbors_obj.h"

...

add following code in openwsnmodule.c file

Code Block
language
cpp
// neighbors_varsneighborsvars
neighbors_vars = PyDict_New();

 // TODO

PyDict_SetItemString(returnVal, "neighbors_vars", neighbors_vars);

...