rubyfit 0.0.3 → 0.0.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -7,11 +7,11 @@
7
7
  // warranties of merchantability, non-infringement, or fitness for a particular
8
8
  // purpose, are specifically disclaimed.
9
9
  //
10
- // Copyright 2013 Dynastream Innovations Inc.
10
+ // Copyright 2014 Dynastream Innovations Inc.
11
11
  ////////////////////////////////////////////////////////////////////////////////
12
12
  // ****WARNING**** This file is auto-generated! Do NOT edit this file.
13
- // Profile Version = 8.10Release
14
- // Tag = $Name: AKW8_100 $
13
+ // Profile Version = 11.0Release
14
+ // Tag = $Name: AKW11_000 $
15
15
  // Product = EXAMPLE
16
16
  // Alignment = 4 bytes, padding disabled.
17
17
  ////////////////////////////////////////////////////////////////////////////////
@@ -7,11 +7,11 @@
7
7
  // warranties of merchantability, non-infringement, or fitness for a particular
8
8
  // purpose, are specifically disclaimed.
9
9
  //
10
- // Copyright 2013 Dynastream Innovations Inc.
10
+ // Copyright 2014 Dynastream Innovations Inc.
11
11
  ////////////////////////////////////////////////////////////////////////////////
12
12
  // ****WARNING**** This file is auto-generated! Do NOT edit this file.
13
- // Profile Version = 8.10Release
14
- // Tag = $Name: AKW8_100 $
13
+ // Profile Version = 11.0Release
14
+ // Tag = $Name: AKW11_000 $
15
15
  // Product = EXAMPLE
16
16
  // Alignment = 4 bytes, padding disabled.
17
17
  ////////////////////////////////////////////////////////////////////////////////
@@ -23,6 +23,7 @@ VALUE mRubyFit;
23
23
  VALUE cFitParser;
24
24
  VALUE cFitHandler;
25
25
  VALUE cFitHandlerPrintFun;
26
+ VALUE cFitHandlerPrintErrFun;
26
27
  VALUE cFitHandlerActivityFun;
27
28
  VALUE cFitHandlerRecordFun;
28
29
  VALUE cFitHandlerLapFun;
@@ -45,6 +46,10 @@ void pass_message(char *msg) {
45
46
  rb_funcall(cFitHandler, cFitHandlerPrintFun, 1, rb_str_new2(msg));
46
47
  }
47
48
 
49
+ void pass_err_message(char *msg) {
50
+ rb_funcall(cFitHandler, cFitHandlerPrintErrFun, 1, rb_str_new2(msg));
51
+ }
52
+
48
53
  static VALUE fit_pos_to_rb(FIT_SINT32 pos) {
49
54
  float tmp = pos * (180.0 / pow(2,31));
50
55
  tmp -= (tmp > 180.0 ? 360.0 : 0.0);
@@ -58,6 +63,7 @@ static VALUE init(VALUE self, VALUE handler) {
58
63
 
59
64
  //callbacks
60
65
  cFitHandlerPrintFun = rb_intern("print_msg");
66
+ cFitHandlerPrintErrFun = rb_intern("print_error_msg");
61
67
  cFitHandlerActivityFun = rb_intern("on_activity");
62
68
  cFitHandlerSessionFun = rb_intern("on_session");
63
69
  cFitHandlerLapFun = rb_intern("on_lap");
@@ -347,7 +353,7 @@ static void pass_device_info(const FIT_DEVICE_INFO_MESG *mesg) {
347
353
  rb_hash_aset(rh, rb_str_new2("battery_voltage"), UINT2NUM(mesg->battery_voltage));
348
354
  if(mesg->device_index != FIT_DEVICE_INDEX_INVALID)
349
355
  rb_hash_aset(rh, rb_str_new2("device_index"), UINT2NUM(mesg->device_index));
350
- if(mesg->device_type != FIT_DEVICE_TYPE_INVALID)
356
+ if(mesg->device_type != FIT_ANTPLUS_DEVICE_TYPE_INVALID)
351
357
  rb_hash_aset(rh, rb_str_new2("device_type"), UINT2NUM(mesg->device_type));
352
358
  if(mesg->hardware_version != FIT_UINT8_INVALID)
353
359
  rb_hash_aset(rh, rb_str_new2("hardware_version"), UINT2NUM(mesg->hardware_version));
@@ -397,19 +403,11 @@ static VALUE parse(VALUE self, VALUE original_str) {
397
403
  FIT_UINT8 buf[8];
398
404
  FIT_CONVERT_RETURN convert_return = FIT_CONVERT_CONTINUE;
399
405
  FIT_UINT32 buf_size;
400
- #if defined(FIT_CONVERT_MULTI_THREAD)
401
- FIT_CONVERT_STATE state;
402
- #endif
403
-
404
- #if defined(FIT_CONVERT_MULTI_THREAD)
405
- FitConvert_Init(&state, FIT_TRUE);
406
- #else
407
406
  FitConvert_Init(FIT_TRUE);
408
- #endif
409
407
 
410
408
  if(RSTRING_LEN(str) == 0) {
411
409
  //sprintf(err_msg, "Passed in string with length of 0!");
412
- pass_message(err_msg);
410
+ pass_err_message(err_msg);
413
411
  return Qnil;
414
412
  }
415
413
 
@@ -421,110 +419,77 @@ static VALUE parse(VALUE self, VALUE original_str) {
421
419
  }
422
420
 
423
421
  do {
424
- #if defined(FIT_CONVERT_MULTI_THREAD)
425
- convert_return = FitConvert_Read(&state, buf, buf_size);
426
- #else
427
422
  convert_return = FitConvert_Read(buf, buf_size);
428
- #endif
429
423
 
430
424
  switch(convert_return) {
431
425
  case FIT_CONVERT_MESSAGE_AVAILABLE: {
432
- #if defined(FIT_CONVERT_MULTI_THREAD)
433
- const FIT_UINT8 *mesg = FitConvert_GetMessageData(&state);
434
- FIT_UINT16 mesg_num = FitConvert_GetMessageNumber(&state);
435
- #else
436
426
  const FIT_UINT8 *mesg = FitConvert_GetMessageData();
437
427
  FIT_UINT16 mesg_num = FitConvert_GetMessageNumber();
438
- #endif
439
-
440
- //pass_message(err_msg);
441
428
 
442
429
  switch(mesg_num) {
443
430
  case FIT_MESG_NUM_FILE_ID: {
444
- //pass_message(err_msg);
445
431
  break;
446
432
  }
447
433
 
448
434
  case FIT_MESG_NUM_USER_PROFILE: {
449
435
  const FIT_USER_PROFILE_MESG *user_profile = (FIT_USER_PROFILE_MESG *) mesg;
450
- //sprintf(err_msg, "User Profile: weight=%0.1fkg\n", user_profile->weight / 10.0f);
451
- //pass_message(err_msg);
452
436
  pass_user_profile(user_profile);
453
437
  break;
454
438
  }
455
439
 
456
440
  case FIT_MESG_NUM_ACTIVITY: {
457
441
  const FIT_ACTIVITY_MESG *activity = (FIT_ACTIVITY_MESG *) mesg;
458
- //sprintf(err_msg, "Activity: timestamp=%u, type=%u, event=%u, event_type=%u, num_sessions=%u\n", activity->timestamp, activity->type, activity->event, activity->event_type, activity->num_sessions);
459
- //pass_message(err_msg);
460
442
  pass_activity(activity);
461
443
 
462
444
  {
463
445
  FIT_ACTIVITY_MESG old_mesg;
464
446
  old_mesg.num_sessions = 1;
465
- #if defined(FIT_CONVERT_MULTI_THREAD)
466
- FitConvert_RestoreFields(&state, &old_mesg);
467
- #else
468
447
  FitConvert_RestoreFields(&old_mesg);
469
- #endif
470
- //sprintf(err_msg, "Restored num_sessions=1 - Activity: timestamp=%u, type=%u, event=%u, event_type=%u, num_sessions=%u\n", activity->timestamp, activity->type, activity->event, activity->event_type, activity->num_sessions);
471
- //pass_message(err_msg);
448
+ sprintf(err_msg, "Restored num_sessions=1 - Activity: timestamp=%u, type=%u, event=%u, event_type=%u, num_sessions=%u\n", activity->timestamp, activity->type, activity->event, activity->event_type, activity->num_sessions);
449
+ pass_message(err_msg);
472
450
  }
473
451
  break;
474
452
  }
475
453
 
476
454
  case FIT_MESG_NUM_SESSION: {
477
455
  const FIT_SESSION_MESG *session = (FIT_SESSION_MESG *) mesg;
478
- //sprintf(err_msg, "Session: timestamp=%u\n", session->timestamp);
479
- //pass_message(err_msg);
480
456
  pass_session(session);
481
457
  break;
482
458
  }
483
459
 
484
460
  case FIT_MESG_NUM_LAP: {
485
461
  const FIT_LAP_MESG *lap = (FIT_LAP_MESG *) mesg;
486
- //sprintf(err_msg, "Lap: timestamp=%u, total_ascent=%u, total_distance=%f\n", lap->timestamp, lap->total_ascent, (lap->total_distance / 100.0) / 1000.0 * 0.621371192);
487
- //pass_message(err_msg);
488
462
  pass_lap(lap);
489
463
  break;
490
464
  }
491
465
 
492
466
  case FIT_MESG_NUM_RECORD: {
493
467
  const FIT_RECORD_MESG *record = (FIT_RECORD_MESG *) mesg;
494
-
495
- //sprintf(err_msg, "Record: timestamp=%u", record->timestamp);
496
- //pass_message(err_msg);
497
468
  pass_record(record);
498
469
  break;
499
470
  }
500
471
 
501
472
  case FIT_MESG_NUM_EVENT: {
502
473
  const FIT_EVENT_MESG *event = (FIT_EVENT_MESG *) mesg;
503
- //sprintf(err_msg, "Event: timestamp=%u, event_type = %i\n", event->timestamp, event->event_type);
504
- //pass_message(err_msg);
505
474
  pass_event(event);
506
475
  break;
507
476
  }
508
477
 
509
478
  case FIT_MESG_NUM_DEVICE_INFO: {
510
479
  const FIT_DEVICE_INFO_MESG *device_info = (FIT_DEVICE_INFO_MESG *) mesg;
511
- //sprintf(err_msg, "Device Info: timestamp=%u, battery_status=%u\n", (unsigned int)device_info->timestamp, device_info->battery_voltage);
512
- //pass_message(err_msg);
513
480
  pass_device_info(device_info);
514
481
  break;
515
482
  }
516
483
 
517
484
  case FIT_MESG_NUM_WEIGHT_SCALE: {
518
485
  const FIT_WEIGHT_SCALE_MESG *weight_scale_info = (FIT_WEIGHT_SCALE_MESG *) mesg;
519
- //sprintf(err_msg, "Device Info: timestamp=%u, battery_status=%u\n", (unsigned int)device_info->timestamp, device_info->battery_voltage);
520
- //pass_message(err_msg);
521
486
  pass_weight_scale_info(weight_scale_info);
522
487
  break;
523
488
  }
524
489
 
525
490
  default: {
526
- //sprintf(err_msg, "Unknown\n");
527
- //pass_message(err_msg);
491
+ sprintf(err_msg, "Unknown message\n");
492
+ pass_message(err_msg);
528
493
  break;
529
494
  }
530
495
  }
@@ -537,28 +502,25 @@ static VALUE parse(VALUE self, VALUE original_str) {
537
502
  }
538
503
 
539
504
  if (convert_return == FIT_CONVERT_ERROR) {
540
- //sprintf(err_msg, "Error decoding file.\n");
541
- pass_message(err_msg);
542
- //fclose(file);
505
+ sprintf(err_msg, "Error decoding file.\n");
506
+ pass_err_message(err_msg);
543
507
  return Qnil;
544
508
  }
545
509
 
546
510
  if (convert_return == FIT_CONVERT_CONTINUE) {
547
- //sprintf(err_msg, "Unexpected end of file.\n");
548
- //pass_message(err_msg);
549
- //fclose(file);
550
- //return Qnil;
511
+ sprintf(err_msg, "Unexpected end of file.\n");
512
+ pass_err_message(err_msg);
513
+ return Qnil;
551
514
  }
552
515
 
553
516
  if (convert_return == FIT_CONVERT_PROTOCOL_VERSION_NOT_SUPPORTED) {
554
- //sprintf(err_msg, "Protocol version not supported.\n");
555
- pass_message(err_msg);
556
- //fclose(file);
517
+ sprintf(err_msg, "Protocol version not supported.\n");
518
+ pass_err_message(err_msg);
557
519
  return Qnil;
558
520
  }
559
521
 
560
522
  if (convert_return == FIT_CONVERT_END_OF_FILE) {
561
- //sprintf(err_msg, "File converted successfully.\n");
523
+ sprintf(err_msg, "File converted successfully.\n");
562
524
  pass_message(err_msg);
563
525
  }
564
526
 
@@ -1,3 +1,3 @@
1
1
  module Rubyfit
2
- VERSION = "0.0.3"
2
+ VERSION = "0.0.4"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rubyfit
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.3
4
+ version: 0.0.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Cullen King
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2013-10-02 00:00:00.000000000 Z
11
+ date: 2014-05-30 00:00:00.000000000 Z
12
12
  dependencies: []
13
13
  description: FIT files are binary, and as a result, are a pain to parse. This is
14
14
  a wrapper around the FIT SDK, which makes creating a stream based parser simple.