Add notifications on configuration and state changes from OpenThread. (#146)

Example state changes that will cause a notification:
- IPv6 address added/removed
- Device state (offline, detached, attached)
- Device role (disabled, detached, child, router, leader)
- Partition ID
- Key Sequence
- Child added/removed
This commit is contained in:
Jonathan Hui
2016-06-15 12:17:05 -07:00
committed by GitHub
parent c7f2d4b917
commit a7e34a6f17
13 changed files with 196 additions and 67 deletions
+18
View File
@@ -206,6 +206,24 @@ typedef struct otLinkModeConfig
uint8_t mNetworkData : 1;
} otLinkModeConfig;
/**
* This enumeration represents flags that indicate what configuration or state has changed within OpenThread.
*
*/
enum
{
OT_IP6_ADDRESS_ADDED = 1 << 0, ///< IPv6 address was added
OT_IP6_ADDRESS_REMOVED = 1 << 1, ///< IPv6 address was removed
OT_NET_STATE = 1 << 2, ///< Device state (offline, detached, attached) changed
OT_NET_ROLE = 1 << 3, ///< Device role (disabled, detached, child, router, leader) changed
OT_NET_PARTITION_ID = 1 << 4, ///< Partition ID changed
OT_NET_KEY_SEQUENCE = 1 << 5, ///< Thread Key Sequence changed
OT_THREAD_CHILD_ADDED = 1 << 6, ///< Child was added
OT_THREAD_CHILD_REMOVED = 1 << 7 ///< Child was removed
};
/**
* @}
*/
+18
View File
@@ -457,6 +457,24 @@ ThreadError otAddUnicastAddress(otNetifAddress *aAddress);
*/
ThreadError otRemoveUnicastAddress(otNetifAddress *aAddress);
/**
* This function pointer is called to notify certain configuration or state changes within OpenThread.
*
* @param[in] aFlags A bit-field indicating specific state that has changed.
* @param[in] aContext A pointer to application-specific context.
*
*/
typedef void (*otStateChangedCallback)(uint32_t aFlags, void *aContext);
/**
* This function registers a callback to indicate when certain configuration or state changes within OpenThread.
*
* @param[in] aCallback A pointer to a function that is called with certain configuration or state changes.
* @param[in] aContext A pointer to application-specific context.
*
*/
void otSetStateChangedCallback(otStateChangedCallback aCallback, void *aContext);
/**
* @}
*/