@@ -329,34 +329,34 @@ void processFTMSWrite() {
329
329
int logBufLength = ss2k_log_hex_to_buffer (pData, length, logBuf, 0 , kLogBufCapacity );
330
330
331
331
int port = 0 ;
332
- uint8_t returnValue[3 ] = {0x80 , (uint8_t )rxValue[0 ], FitnessMachineControlPointResultCodeFlag::Types ::OpCodeNotSupported};
332
+ uint8_t returnValue[3 ] = {0x80 , (uint8_t )rxValue[0 ], FitnessMachineControlPointResultCode ::OpCodeNotSupported};
333
333
334
334
switch ((uint8_t )rxValue[0 ]) {
335
- case 0x00 : // request control
336
- returnValue[2 ] = FitnessMachineControlPointResultCodeFlag::Types ::Success; // 0x01;
335
+ case 0x00 : // request control
336
+ returnValue[2 ] = FitnessMachineControlPointResultCode ::Success; // 0x01;
337
337
pCharacteristic->setValue (returnValue, 3 );
338
338
339
339
logBufLength += snprintf (logBuf + logBufLength, kLogBufCapacity - logBufLength, " -> Control Request" );
340
340
// userConfig.setERGMode(false);
341
- ftmsTrainingStatus[1 ] = FitnessMachineTrainingStatusFlag::Types ::Idle; // 0x01;
341
+ ftmsTrainingStatus[1 ] = FitnessMachineTrainingStatus ::Idle; // 0x01;
342
342
fitnessMachineTrainingStatus->setValue (ftmsTrainingStatus, 2 );
343
343
fitnessMachineTrainingStatus->notify (false );
344
344
pCharacteristic->setValue (returnValue, 3 );
345
345
break ;
346
346
347
- case 0x01 : // reset
348
- returnValue[2 ] = FitnessMachineControlPointResultCodeFlag::Types ::Success; // 0x01;
347
+ case 0x01 : // reset
348
+ returnValue[2 ] = FitnessMachineControlPointResultCode ::Success; // 0x01;
349
349
pCharacteristic->setValue (returnValue, 3 );
350
350
351
351
logBufLength += snprintf (logBuf + logBufLength, kLogBufCapacity - logBufLength, " -> Reset" );
352
- ftmsTrainingStatus[1 ] = FitnessMachineTrainingStatusFlag::Types ::Idle; // 0x01;
352
+ ftmsTrainingStatus[1 ] = FitnessMachineTrainingStatus ::Idle; // 0x01;
353
353
fitnessMachineTrainingStatus->setValue (ftmsTrainingStatus, 2 );
354
354
fitnessMachineTrainingStatus->notify (false );
355
355
pCharacteristic->setValue (returnValue, 3 );
356
356
break ;
357
357
358
- case 0x03 : { // inclination level setting - differs from sim mode as no negative numbers
359
- returnValue[2 ] = FitnessMachineControlPointResultCodeFlag::Types ::Success; // 0x01;
358
+ case 0x03 : { // inclination level setting - differs from sim mode as no negative numbers
359
+ returnValue[2 ] = FitnessMachineControlPointResultCode ::Success; // 0x01;
360
360
pCharacteristic->setValue (returnValue, 3 );
361
361
362
362
port = (rxValue[2 ] << 8 ) + rxValue[1 ];
@@ -366,13 +366,13 @@ void processFTMSWrite() {
366
366
logBufLength += snprintf (logBuf + logBufLength, kLogBufCapacity - logBufLength, " -> Incline Mode: %2f" , rtConfig.getTargetIncline () / 100 );
367
367
uint8_t inclineStatus[3 ] = {0x06 , (uint8_t )rxValue[1 ], (uint8_t )rxValue[2 ]};
368
368
fitnessMachineStatusCharacteristic->setValue (inclineStatus, 3 );
369
- ftmsTrainingStatus[1 ] = FitnessMachineTrainingStatusFlag::Types ::Other; // 0x00;
369
+ ftmsTrainingStatus[1 ] = FitnessMachineTrainingStatus ::Other; // 0x00;
370
370
fitnessMachineTrainingStatus->setValue (ftmsTrainingStatus, 2 );
371
371
fitnessMachineTrainingStatus->notify ();
372
372
} break ;
373
373
374
- case 0x04 : { // Resistance level setting
375
- returnValue[2 ] = FitnessMachineControlPointResultCodeFlag::Types ::Success; // 0x01;
374
+ case 0x04 : { // Resistance level setting
375
+ returnValue[2 ] = FitnessMachineControlPointResultCode ::Success; // 0x01;
376
376
pCharacteristic->setValue (returnValue, 3 );
377
377
378
378
int targetResistance = rxValue[1 ];
@@ -381,7 +381,7 @@ void processFTMSWrite() {
381
381
logBufLength += snprintf (logBuf + logBufLength, kLogBufCapacity - logBufLength, " -> Resistance Mode: %d" , rtConfig.getShifterPosition ());
382
382
uint8_t resistanceStatus[2 ] = {0x07 , rxValue[1 ]};
383
383
fitnessMachineStatusCharacteristic->setValue (resistanceStatus, 3 );
384
- ftmsTrainingStatus[1 ] = FitnessMachineTrainingStatusFlag::Types ::Other; // 0x00;
384
+ ftmsTrainingStatus[1 ] = FitnessMachineTrainingStatus ::Other; // 0x00;
385
385
fitnessMachineTrainingStatus->setValue (ftmsTrainingStatus, 2 );
386
386
fitnessMachineTrainingStatus->notify ();
387
387
} break ;
@@ -395,32 +395,45 @@ void processFTMSWrite() {
395
395
// computeERG(targetWatts);
396
396
logBufLength += snprintf (logBuf + logBufLength, kLogBufCapacity - logBufLength, " -> ERG Mode Target: %d Current: %d Incline: %2f" , targetWatts,
397
397
rtConfig.getSimulatedWatts ().value , rtConfig.getTargetIncline () / 100 );
398
- returnValue[2 ] = FitnessMachineControlPointResultCodeFlag::Types ::Success; // 0x01;
398
+ returnValue[2 ] = FitnessMachineControlPointResultCode ::Success; // 0x01;
399
399
uint8_t ERGStatus[3 ] = {0x08 , (uint8_t )rxValue[1 ], 0x01 };
400
400
fitnessMachineStatusCharacteristic->setValue (ERGStatus, 3 );
401
- ftmsTrainingStatus[1 ] = FitnessMachineTrainingStatusFlag::Types ::WattControl; // 0x0C;
401
+ ftmsTrainingStatus[1 ] = FitnessMachineTrainingStatus ::WattControl; // 0x0C;
402
402
fitnessMachineTrainingStatus->setValue (ftmsTrainingStatus, 2 );
403
403
fitnessMachineTrainingStatus->notify ();
404
404
} else {
405
- returnValue[2 ] = FitnessMachineControlPointResultCodeFlag::Types ::OpCodeNotSupported; // 0x02; no power meter connected, so no ERG
405
+ returnValue[2 ] = FitnessMachineControlPointResultCode ::OpCodeNotSupported; // 0x02; no power meter connected, so no ERG
406
406
logBufLength += snprintf (logBuf + logBufLength, kLogBufCapacity - logBufLength, " -> ERG Mode: No Power Meter Connected" );
407
407
}
408
408
pCharacteristic->setValue (returnValue, 3 );
409
409
} break ;
410
410
411
- case 0x07 : // Start training
412
- returnValue[2 ] = FitnessMachineControlPointResultCodeFlag::Types ::Success; // 0x01;
411
+ case 0x07 : // Start training
412
+ returnValue[2 ] = FitnessMachineControlPointResultCode ::Success; // 0x01;
413
413
pCharacteristic->setValue (returnValue, 3 );
414
414
415
415
logBufLength += snprintf (logBuf + logBufLength, kLogBufCapacity - logBufLength, " -> Start Training" );
416
- ftmsTrainingStatus[1 ] = FitnessMachineTrainingStatusFlag::Types ::Other; // 0x00;
416
+ ftmsTrainingStatus[1 ] = FitnessMachineTrainingStatus ::Other; // 0x00;
417
417
fitnessMachineTrainingStatus->setValue (ftmsTrainingStatus, 2 );
418
418
fitnessMachineTrainingStatus->notify ();
419
419
420
420
break ;
421
421
422
- case 0x11 : { // sim mode
423
- returnValue[2 ] = FitnessMachineControlPointResultCodeFlag::Types::Success; // 0x01;
422
+ case 0x08 : // Stop or Pause
423
+ returnValue[2 ] = FitnessMachineControlPointResultCode::Success; // 0x01;
424
+ pCharacteristic->setValue (returnValue, 3 );
425
+ // rxValue[1] == 1 -> Stop, 2 -> Pause
426
+ // TODO: Move stepper to Min Position
427
+
428
+ logBufLength += snprintf (logBuf + logBufLength, kLogBufCapacity - logBufLength, " -> Stop Training" );
429
+ ftmsTrainingStatus[1 ] = FitnessMachineTrainingStatus::Other; // 0x00;
430
+ fitnessMachineTrainingStatus->setValue (ftmsTrainingStatus, 2 );
431
+ fitnessMachineTrainingStatus->notify ();
432
+
433
+ break ;
434
+
435
+ case 0x11 : { // sim mode
436
+ returnValue[2 ] = FitnessMachineControlPointResultCode::Success; // 0x01;
424
437
pCharacteristic->setValue (returnValue, 3 );
425
438
426
439
signed char buf[2 ];
@@ -435,7 +448,7 @@ void processFTMSWrite() {
435
448
rtConfig.setERGMode (false );
436
449
uint8_t simStatus[7 ] = {0x12 , (uint8_t )rxValue[1 ], (uint8_t )rxValue[2 ], (uint8_t )rxValue[3 ], (uint8_t )rxValue[4 ], (uint8_t )rxValue[5 ], (uint8_t )rxValue[6 ]};
437
450
fitnessMachineStatusCharacteristic->setValue (simStatus, 7 );
438
- ftmsTrainingStatus[1 ] = FitnessMachineTrainingStatusFlag::Types ::Other; // 0x00;
451
+ ftmsTrainingStatus[1 ] = FitnessMachineTrainingStatus ::Other; // 0x00;
439
452
fitnessMachineTrainingStatus->setValue (ftmsTrainingStatus, 2 );
440
453
fitnessMachineTrainingStatus->notify ();
441
454
} break ;
@@ -446,13 +459,13 @@ void processFTMSWrite() {
446
459
fitnessMachineStatusCharacteristic->setValue (spinStatus, 2 );
447
460
uint8_t controlPoint[6 ] = {0x80 , 0x01 , 0x24 , 0x03 , 0x96 , 0x0e }; // send low and high speed targets
448
461
pCharacteristic->setValue (controlPoint, 6 );
449
- ftmsTrainingStatus[1 ] = FitnessMachineTrainingStatusFlag::Types ::Other; // 0x00;
462
+ ftmsTrainingStatus[1 ] = FitnessMachineTrainingStatus ::Other; // 0x00;
450
463
fitnessMachineTrainingStatus->setValue (ftmsTrainingStatus, 2 );
451
464
fitnessMachineTrainingStatus->notify ();
452
465
} break ;
453
466
454
- case 0x15 : { // Set Targeted Cadence
455
- returnValue[2 ] = FitnessMachineControlPointResultCodeFlag::Types ::Success; // 0x01;
467
+ case 0x15 : { // Set Targeted Cadence
468
+ returnValue[2 ] = FitnessMachineControlPointResultCode ::Success; // 0x01;
456
469
pCharacteristic->setValue (returnValue, 3 );
457
470
458
471
int targetCadence = bytes_to_u16 (rxValue[2 ], rxValue[1 ]);
@@ -462,7 +475,7 @@ void processFTMSWrite() {
462
475
uint8_t ERGStatus[3 ] = {0x08 , (uint8_t )rxValue[1 ], 0x01 };
463
476
fitnessMachineStatusCharacteristic->setValue (ERGStatus, 3 );
464
477
465
- ftmsTrainingStatus[1 ] = FitnessMachineTrainingStatusFlag::Types ::Other; // 0x00;
478
+ ftmsTrainingStatus[1 ] = FitnessMachineTrainingStatus ::Other; // 0x00;
466
479
fitnessMachineTrainingStatus->setValue (ftmsTrainingStatus, 2 );
467
480
fitnessMachineTrainingStatus->notify ();
468
481
} break ;
@@ -471,16 +484,16 @@ void processFTMSWrite() {
471
484
logBufLength += snprintf (logBuf + logBufLength, kLogBufCapacity - logBufLength, " -> Unsupported FTMS Request" );
472
485
pCharacteristic->setValue (returnValue, 3 );
473
486
}
474
- SS2K_LOG (BLE_SERVER_LOG_TAG , " %s" , logBuf);
487
+ SS2K_LOG (FMTS_SERVER_LOG_TAG , " %s" , logBuf);
475
488
fitnessMachineStatusCharacteristic->notify ();
476
489
} else {
477
- SS2K_LOG (BLE_SERVER_LOG_TAG , " App wrote nothing " );
478
- SS2K_LOG (BLE_SERVER_LOG_TAG , " assuming it's a Control request" );
490
+ SS2K_LOG (FMTS_SERVER_LOG_TAG , " App wrote nothing " );
491
+ SS2K_LOG (FMTS_SERVER_LOG_TAG , " assuming it's a Control request" );
479
492
480
- uint8_t controlPoint[3 ] = {0x80 , 0x00 , FitnessMachineControlPointResultCodeFlag::Types ::Success};
493
+ uint8_t controlPoint[3 ] = {0x80 , 0x00 , FitnessMachineControlPointResultCode ::Success};
481
494
pCharacteristic->setValue (controlPoint, 3 );
482
495
483
- ftmsTrainingStatus[1 ] = FitnessMachineTrainingStatusFlag::Types ::Other; // 0x00;
496
+ ftmsTrainingStatus[1 ] = FitnessMachineTrainingStatus ::Other; // 0x00;
484
497
fitnessMachineTrainingStatus->setValue (ftmsTrainingStatus, 2 );
485
498
fitnessMachineTrainingStatus->notify (false );
486
499
}
0 commit comments