diff options
author | Omar Tarabai <tarabai@devegypt.com> | 2014-08-11 18:39:39 +0000 |
---|---|---|
committer | Omar Tarabai <tarabai@devegypt.com> | 2014-08-11 18:39:39 +0000 |
commit | d26fff163ec1d081db3293daf9dd566e74f3fde5 (patch) | |
tree | cc8f0de5a3fc57bebcdcb30f28bcd48ff405ee30 /src/include | |
parent | 321e66a9d999edaed3fff1a707d212f750fb40a1 (diff) | |
download | gnunet-d26fff163ec1d081db3293daf9dd566e74f3fde5.tar.gz gnunet-d26fff163ec1d081db3293daf9dd566e74f3fde5.zip |
sensor: api changes
Diffstat (limited to 'src/include')
-rw-r--r-- | src/include/gnunet_protocols.h | 6 | ||||
-rw-r--r-- | src/include/gnunet_sensor_service.h | 45 |
2 files changed, 37 insertions, 14 deletions
diff --git a/src/include/gnunet_protocols.h b/src/include/gnunet_protocols.h index 246f7f836..176391580 100644 --- a/src/include/gnunet_protocols.h +++ b/src/include/gnunet_protocols.h | |||
@@ -2452,6 +2452,12 @@ extern "C" | |||
2452 | */ | 2452 | */ |
2453 | #define GNUNET_MESSAGE_TYPE_SENSOR_ANOMALY_REPORT 809 | 2453 | #define GNUNET_MESSAGE_TYPE_SENSOR_ANOMALY_REPORT 809 |
2454 | 2454 | ||
2455 | /** | ||
2456 | * Message sent from API to service to force a new sensor anomaly status | ||
2457 | * (For testing purposes only) | ||
2458 | */ | ||
2459 | #define GNUNET_MESSAGE_TYPE_SENSOR_ANOMALY_FORCE 810 | ||
2460 | |||
2455 | 2461 | ||
2456 | /******************************************************************************* | 2462 | /******************************************************************************* |
2457 | * PEERSTORE message types | 2463 | * PEERSTORE message types |
diff --git a/src/include/gnunet_sensor_service.h b/src/include/gnunet_sensor_service.h index 4ef2885e6..a31b20e52 100644 --- a/src/include/gnunet_sensor_service.h +++ b/src/include/gnunet_sensor_service.h | |||
@@ -44,6 +44,11 @@ extern "C" | |||
44 | struct GNUNET_SENSOR_Handle; | 44 | struct GNUNET_SENSOR_Handle; |
45 | 45 | ||
46 | /** | 46 | /** |
47 | * Context for an iteration request. | ||
48 | */ | ||
49 | struct GNUNET_SENSOR_IterateContext; | ||
50 | |||
51 | /** | ||
47 | * Structure containing brief info about sensor | 52 | * Structure containing brief info about sensor |
48 | */ | 53 | */ |
49 | struct SensorInfoShort | 54 | struct SensorInfoShort |
@@ -72,13 +77,13 @@ struct SensorInfoShort | |||
72 | }; | 77 | }; |
73 | 78 | ||
74 | /** | 79 | /** |
75 | * Type of an iterator over sensor definitions. | 80 | * Sensor iterate request callback. |
76 | * | 81 | * |
77 | * @param cls closure | 82 | * @param cls closure |
78 | * @param hello hello message for the peer (can be NULL) | 83 | * @param sensor Brief sensor information |
79 | * @param error message | 84 | * @param error message |
80 | */ | 85 | */ |
81 | typedef void (*GNUNET_SENSOR_SensorIteratorCB) (void *cls, | 86 | typedef void (*GNUNET_SENSOR_SensorIterateCB) (void *cls, |
82 | const struct SensorInfoShort * | 87 | const struct SensorInfoShort * |
83 | sensor, const char *err_msg); | 88 | sensor, const char *err_msg); |
84 | 89 | ||
@@ -93,6 +98,15 @@ typedef void (*GNUNET_SENSOR_Continuation) (void *cls, const char *emsg); | |||
93 | 98 | ||
94 | 99 | ||
95 | /** | 100 | /** |
101 | * Disconnect from the sensor service | ||
102 | * | ||
103 | * @param h handle to disconnect | ||
104 | */ | ||
105 | void | ||
106 | GNUNET_SENSOR_disconnect (struct GNUNET_SENSOR_Handle *h); | ||
107 | |||
108 | |||
109 | /** | ||
96 | * Connect to the sensor service. | 110 | * Connect to the sensor service. |
97 | * | 111 | * |
98 | * @return NULL on error | 112 | * @return NULL on error |
@@ -102,30 +116,33 @@ GNUNET_SENSOR_connect (const struct GNUNET_CONFIGURATION_Handle *cfg); | |||
102 | 116 | ||
103 | 117 | ||
104 | /** | 118 | /** |
105 | * Disconnect from the sensor service | 119 | * Cancel an iteration request. |
120 | * This should be called before the iterate callback is called with a NULL value. | ||
106 | * | 121 | * |
107 | * @param h handle to disconnect | 122 | * @param ic context of the iterator to cancel |
108 | */ | 123 | */ |
109 | void | 124 | void |
110 | GNUNET_SENSOR_disconnect (struct GNUNET_SENSOR_Handle *h); | 125 | GNUNET_SENSOR_iterate_cancel (struct GNUNET_SENSOR_IterateContext |
126 | *ic); | ||
111 | 127 | ||
112 | 128 | ||
113 | /** | 129 | /** |
114 | * Client asking to iterate all available sensors | 130 | * Get one or all sensors loaded by the sensor service. |
131 | * The callback will be called with each sensor received and once with a NULL | ||
132 | * value to signal end of iteration. | ||
115 | * | 133 | * |
116 | * @param h Handle to SENSOR service | 134 | * @param h Handle to SENSOR service |
117 | * @param timeout how long to wait until timing out | 135 | * @param timeout how long to wait until timing out |
118 | * @param sensorname information on one sensor only, can be NULL to get all | 136 | * @param sensorname Name of the required sensor, NULL to get all |
119 | * @param sensorname_len length of the sensorname parameter | 137 | * @param callback the function to call for each sensor |
120 | * @param callback the method to call for each sensor | ||
121 | * @param callback_cls closure for callback | 138 | * @param callback_cls closure for callback |
122 | * @return iterator context | 139 | * @return iterator context |
123 | */ | 140 | */ |
124 | struct GNUNET_SENSOR_SensorIteratorContext * | 141 | struct GNUNET_SENSOR_IterateContext * |
125 | GNUNET_SENSOR_iterate_sensors (struct GNUNET_SENSOR_Handle *h, | 142 | GNUNET_SENSOR_iterate (struct GNUNET_SENSOR_Handle *h, |
126 | struct GNUNET_TIME_Relative timeout, | 143 | struct GNUNET_TIME_Relative timeout, |
127 | const char *sensorname, size_t sensorname_len, | 144 | const char *sensor_name, |
128 | GNUNET_SENSOR_SensorIteratorCB callback, | 145 | GNUNET_SENSOR_SensorIterateCB callback, |
129 | void *callback_cls); | 146 | void *callback_cls); |
130 | 147 | ||
131 | #if 0 /* keep Emacsens' auto-indent happy */ | 148 | #if 0 /* keep Emacsens' auto-indent happy */ |