BodyPositionEvent constructor

BodyPositionEvent({
  1. required List<int> bytes,
  2. required String deviceId,
})

Implementation

BodyPositionEvent({required List<int> bytes, required String deviceId})
    : super(deviceId) {
  ByteData byteData = ByteData.sublistView(Uint8List.fromList(bytes));
  int bodyPos = byteData.getUint8(0);
  switch (bodyPos) {
    case 0:
      _bodyPosition = BodyPosition.unknown;
      break;
    case 1:
      _bodyPosition = BodyPosition.lyingSupine;
      break;
    case 2:
      _bodyPosition = BodyPosition.lyingLeft;
      break;
    case 3:
      _bodyPosition = BodyPosition.lyingProne;
      break;
    case 4:
      _bodyPosition = BodyPosition.lyingRight;
      break;
    case 5:
      _bodyPosition = BodyPosition.upright;
      break;
    case 6:
      _bodyPosition = BodyPosition.sittingUpright;
      break;
    case 7:
      _bodyPosition = BodyPosition.standing;
      break;
    case 99:
      _bodyPosition = BodyPosition.notWorn;
      break;
  }
}