Skip to content

Conversation

@hgrf
Copy link
Contributor

@hgrf hgrf commented Jan 30, 2025

Hi Chip,

sorry I did not reply to your comments on #1080.

I have rebased it, rewritten it to use an enumeration and also made "receiveEvent" optional in the constructor of BmCharacteristicData, so that it does not break the Linux and web implementations. I think both of them support this distinction, so if you want me to, I can implement and test it.

@chipweinberger
Copy link
Owner

chipweinberger commented Jan 31, 2025

thanks for the update.

  1. now that i see it in use, receiveType is a better name
  2. will this run on web & linux? i think you need more changes

@chipweinberger
Copy link
Owner

chipweinberger commented Jan 31, 2025

.where((p) => p.receiveEvent != BmReceiveEventEnum.notify);

don't like this so much.

ideally make it clear it is android only, or check for indicate or unknown

required this.success,
required this.errorCode,
required this.errorString,
this.receiveEvent = BmReceiveEventEnum.unknown,
Copy link
Owner

@chipweinberger chipweinberger Jan 31, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lets make it required, for consistency

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Leaving it optional means that we need not make this a breaking change and would be better if possible.

We could default to BmReceiveEventEnum.unknown or we could make the field nullable as done for pin.

#1119 (comment)

Copy link
Owner

@chipweinberger chipweinberger Jan 31, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

breaking is fine tho. I still dont really understand why we wouldn't want to break.

now is the perfect time to break since we have no other users of this interface.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

final bool success;
final int errorCode;
final String errorString;
final BmReceiveEventEnum receiveEvent;
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lets make this nullable

success: json['success'] != 0,
errorCode: json['error_code'],
errorString: json['error_string'],
receiveEvent: BmReceiveEventEnum.values[json['receive_event']],
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lets make an explicit 'parse' helper function

unknown, // 0
read, // 1
notify, // 2
}
Copy link
Owner

@chipweinberger chipweinberger Jan 31, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lets just have this:

enum BmReceiveType {
  read, // 1
  notify, // 2
}

and then make it nullable, and have a BmReceiveType? _parseReceiveTypeFromInteger function

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants