/**
* Collection point reporting task
- * (OR GNUNET_SCHEDULER_NO_TASK)
+ * (or #GNUNET_SCHEDULER_NO_TASK)
*/
GNUNET_SCHEDULER_TaskIdentifier cp_task;
void *last_value;
/**
- * Size of @last_value
+ * Size of @e last_value
*/
size_t last_value_size;
void *pending_msg;
/**
- * Size of @pending_msg
+ * Size of @e pending_msg
*/
size_t pending_msg_size;
/**
* Handle to CADET tranmission request in case we are sending
- * (sending == GNUNET_YES)
+ * (sending == #GNUNET_YES)
*/
struct GNUNET_CADET_TransmitHandle *th;
GNUNET_free (cc);
}
+
/**
* Stop sensor reporting module
*/
-void SENSOR_reporting_stop ()
+void
+SENSOR_reporting_stop ()
{
struct ReportingContext *rc;
struct CadetChannelContext *cc;
- LOG (GNUNET_ERROR_TYPE_DEBUG, "Stopping sensor reporting module.\n");
+ LOG (GNUNET_ERROR_TYPE_DEBUG,
+ "Stopping sensor reporting module.\n");
while (NULL != cc_head)
{
cc = cc_head;
}
if (NULL != peerstore)
{
- GNUNET_PEERSTORE_disconnect (peerstore);
+ GNUNET_PEERSTORE_disconnect (peerstore, GNUNET_YES);
peerstore = NULL;
}
if (NULL != cadet)
}
}
+
/**
* Returns CADET channel established to given peer
* or creates a new one
return cc;
}
+
/**
* Construct a reading message ready to be sent over CADET channel
*
*/
static size_t
construct_reading_message (struct ReportingContext *rc,
- struct GNUNET_SENSOR_ReadingMessage **msg)
+ struct GNUNET_SENSOR_ReadingMessage **msg)
{
struct GNUNET_SENSOR_ReadingMessage *ret;
uint16_t sensorname_size;
return total_size;
}
+
/**
* Function called to notify a client about the connection begin ready
* to queue more data. @a buf will be NULL and @a size zero if the
cc->th = NULL;
cc->sending = GNUNET_NO;
- LOG (GNUNET_ERROR_TYPE_DEBUG, "Copying to CADET transmit buffer.\n");
+ LOG (GNUNET_ERROR_TYPE_DEBUG,
+ "Copying to CADET transmit buffer.\n");
if (NULL == buf)
{
LOG (GNUNET_ERROR_TYPE_WARNING,
return written;
}
+
/**
* Task scheduled to send values to collection point
*
- * @param cls closure, a 'struct CollectionReportingContext *'
+ * @param cls closure, a `struct CollectionReportingContext *`
* @param tc unused
*/
-static void report_collection_point
-(void *cls, const struct GNUNET_SCHEDULER_TaskContext* tc)
+static void
+report_collection_point (void *cls,
+ const struct GNUNET_SCHEDULER_TaskContext* tc)
{
struct ReportingContext *rc = cls;
struct SensorInfo *sensor = rc->sensor;
rc->cp_task = GNUNET_SCHEDULER_NO_TASK;
if (0 == rc->last_value_size) /* Did not receive a sensor value yet */
{
- LOG (GNUNET_ERROR_TYPE_WARNING, "Did not receive a value from `%s' "
- "to report yet.\n", rc->sensor->name);
+ LOG (GNUNET_ERROR_TYPE_WARNING,
+ "Did not receive a value from `%s' to report yet.\n",
+ rc->sensor->name);
rc->cp_task = GNUNET_SCHEDULER_add_delayed (sensor->collection_interval,
&report_collection_point, rc);
return;
}
- LOG (GNUNET_ERROR_TYPE_DEBUG, "Now trying to report last seen value of `%s' "
- "to collection point.\n", rc->sensor->name);
+ LOG (GNUNET_ERROR_TYPE_DEBUG,
+ "Now trying to report last seen value of `%s' "
+ "to collection point.\n",
+ rc->sensor->name);
GNUNET_assert (NULL != sensor->collection_point);
cc = get_cadet_channel (*sensor->collection_point);
if (GNUNET_YES == cc->sending)
{
LOG (GNUNET_ERROR_TYPE_DEBUG,
- "Cadet channel to collection point busy, "
- "trying again for sensor `%s' after %d seconds.\n", rc->sensor->name,
- COLLECTION_RETRY);
+ "Cadet channel to collection point busy, "
+ "trying again for sensor `%s' after %d seconds.\n",
+ rc->sensor->name,
+ COLLECTION_RETRY);
rc->cp_task = GNUNET_SCHEDULER_add_delayed (
GNUNET_TIME_relative_multiply(GNUNET_TIME_UNIT_SECONDS, COLLECTION_RETRY),
&report_collection_point, rc);
&report_collection_point, rc);
}
-/*
+
+/**
* Sensor value watch callback
*/
static int
memcpy (rc->last_value, record->value, record->value_size);
rc->last_value_size = record->value_size;
rc->timestamp = GNUNET_TIME_absolute_get().abs_value_us;
- LOG (GNUNET_ERROR_TYPE_DEBUG, "Received a sensor `%s' watch value at "
- "timestamp %" PRIu64 ", updating notification last_value.\n",
- rc->sensor->name, rc->timestamp);
+ LOG (GNUNET_ERROR_TYPE_DEBUG,
+ "Received a sensor `%s' watch value at "
+ "timestamp %" PRIu64 ", updating notification last_value.\n",
+ rc->sensor->name,
+ rc->timestamp);
return GNUNET_YES;
}
+
/**
* Iterator for defined sensors
* Watches sensors for readings to report
return GNUNET_YES;
}
+
/**
* Function called whenever a channel is destroyed. Should clean up
* any associated state.
* @param channel_ctx place where local state associated
* with the channel is stored
*/
-static void cadet_channel_destroyed (void *cls,
- const struct GNUNET_CADET_Channel *channel,
- void *channel_ctx)
+static void
+cadet_channel_destroyed (void *cls,
+ const struct GNUNET_CADET_Channel *channel,
+ void *channel_ctx)
{
struct CadetChannelContext *cc = channel_ctx;
*/
int
SENSOR_reporting_start (const struct GNUNET_CONFIGURATION_Handle *c,
- struct GNUNET_CONTAINER_MultiHashMap *sensors)
+ struct GNUNET_CONTAINER_MultiHashMap *sensors)
{
static struct GNUNET_CADET_MessageHandler cadet_handlers[] = {
{NULL, 0, 0}
};
- LOG (GNUNET_ERROR_TYPE_DEBUG, "Starting sensor reporting module.\n");
+ LOG (GNUNET_ERROR_TYPE_DEBUG,
+ "Starting sensor reporting module.\n");
GNUNET_assert(NULL != sensors);
cfg = c;
peerstore = GNUNET_PEERSTORE_connect(cfg);
if (NULL == cadet)
{
LOG (GNUNET_ERROR_TYPE_ERROR,
- _("Failed to connect to CADET service.\n"));
+ _("Failed to connect to CADET service.\n"));
SENSOR_reporting_stop ();
return GNUNET_SYSERR;
}
- GNUNET_CRYPTO_get_peer_identity(cfg, &mypeerid);
- GNUNET_CONTAINER_multihashmap_iterate(sensors, &init_sensor_reporting, NULL);
-
+ GNUNET_CRYPTO_get_peer_identity (cfg,
+ &mypeerid);
+ GNUNET_CONTAINER_multihashmap_iterate(sensors,
+ &init_sensor_reporting, NULL);
return GNUNET_OK;
}