+ g_gps_event_cb(&gps_event, g_user_data);
+ }
+}
+
+void gps_plugin_replay_batch_event(pos_data_t * data, replay_timeout * timer)
+{
+ time_t timestamp;
+ time(×tamp);
+
+ if (timer->batch_fd == NULL) {
+ if (timer->batch_mode == BATCH_MODE_ON) {
+ LOG_PLUGIN(DBG_ERR, "Fail to open file [Not available batch_fd]");
+ return ;
+ }
+ }
+
+ if (data != NULL) {
+ if (timer->batch_mode == BATCH_MODE_ON) {
+ int ret = -1;
+ char buf[256] = {0, };
+
+ sprintf(buf, "%ld;%.6lf;%.6lf;%.2lf;%.2lf;%.2lf;%.2lf;%.2lf;\n", timestamp, data->latitude, data->longitude, data->altitude, data->speed, data->bearing, data->hor_accuracy, data->ver_accuracy);
+ LOG_PLUGIN(DBG_LOW, "Add location info to batch file [%s]", buf);
+
+ ret = fwrite(buf, 1, strlen(buf), timer->batch_fd);
+ if (ret != strlen(buf)) {
+ LOG_PLUGIN(DBG_ERR, "Fail to write file[%s]", BATCH_LOG);
+ }
+
+ (timer->num_of_batch)++ ;
+ }
+ }
+
+ if ( ((timestamp - timer->batch_start_time) >= timer->batch_period) || (timer->batch_mode == BATCH_MODE_EXPIRED) ) {
+ LOG_PLUGIN(DBG_LOW, "Batch invoked, Batch interval is expired or Batch stopped");
+ gps_event_info_t gps_event;
+ memset(&gps_event, 0, sizeof(gps_event_info_t));
+
+ gps_event.event_id = GPS_EVENT_REPORT_BATCH;
+ timer->batch_mode = BATCH_MODE_OFF;
+
+ if (timer->num_of_batch < 1) {
+ LOG_PLUGIN(DBG_ERR, "There is no Batch data");
+ gps_event.event_data.batch_ind.error = GPS_ERR_COMMUNICATION;
+ } else {
+ gps_event.event_data.batch_ind.error = GPS_ERR_NONE;
+ gps_event.event_data.batch_ind.batch.num_of_location = timer->num_of_batch;
+ }
+
+ if (g_gps_event_cb != NULL) {
+ g_gps_event_cb(&gps_event, g_user_data);
+ }
+
+ if (timer->batch_fd != NULL) {
+ fclose(timer->batch_fd);
+ timer->batch_fd = NULL;
+ timer->num_of_batch = 0;
+ }