} dip_msgid_t;
enum {
- AM_DIP = 0x84
+ AM_DIP = 0x84,
+ AM_DIP_DATA_MSG = 0x84, // For MIG tool
+ AM_DIP_MSG = 0x84, // For MIG tool
+ AM_DIP_DATA = 0x84 // For MIG tool
};
typedef uint16_t dip_index_t;
typedef uint8_t dip_estimate_t;
typedef dip_index_t dip_hashlen_t;
-typedef nx_struct dip_msg_t {
+typedef nx_struct dip_msg {
nx_uint8_t type; // dip_msgid_t
nx_uint8_t content[0];
} dip_msg_t;
-typedef nx_struct dip_data_msg_t {
+typedef nx_struct dip_data_msg {
nx_dip_key_t key;
nx_dip_version_t version;
nx_uint8_t size;
nx_uint8_t data[0];
} dip_data_msg_t;
-typedef nx_struct dip_vector_msg_t {
+typedef nx_struct dip_vector_msg {
nx_uint8_t unitLen;
nx_uint32_t vector[0];
} dip_vector_msg_t;
-typedef nx_struct dip_summary_msg_t {
+typedef nx_struct dip_summary_msg {
nx_uint8_t unitLen;
nx_uint32_t salt;
nx_uint32_t info[0];
/* TUNABLE PARAMETERS */
-typedef struct dip_data_t {
- uint8_t data[16];
+typedef nx_struct dip_data {
+ nx_uint8_t data[16];
} dip_data_t;
#define DIP_SUMMARY_VALUES_PER_PACKET 2
}
implementation {
dip_data_t valueCache;
-
+
task void signalNewData() {
signal AppDisseminationValue.changed();
}
-
+
command error_t Init.init() {
call DipHelp.registerKey(key);
return SUCCESS;
command void AppDisseminationValue.set( const t* val ) {
memcpy( &valueCache, val, sizeof(t) );
+ // must signal here instead of posting task to prevent race condition
+ signal AppDisseminationValue.changed();
}
command void AppDisseminationUpdate.change( t* newVal ) {
/* DipLogicC doesn't care what the data actually is,
it just wants the key, so we cast it recklessly */
call DipDisseminationUpdate.change((dip_data_t*)newVal);
+ post signalNewData();
}
command const dip_data_t* DataDisseminationValue.get() {
command void DataDisseminationUpdate.change( dip_data_t* newVal ) {
memcpy( &valueCache, newVal, sizeof(dip_data_t) );
- //post signalNewData();
+ // don't post the task, this came from the network
signal AppDisseminationValue.changed();
}