Skip to content

Commit

Permalink
[Cleanup] iOS: clarify MSD manufacturerId little-endianess
Browse files Browse the repository at this point in the history
  • Loading branch information
chipweinberger committed Jan 27, 2024
1 parent 9f0e2d1 commit 5620749
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions ios/Classes/FlutterBluePlusPlugin.m
Original file line number Diff line number Diff line change
Expand Up @@ -1670,9 +1670,10 @@ - (NSDictionary *)bmScanAdvertisement:(NSString*)remoteId
NSDictionary* manufDataB = nil;
if (manufData != nil && manufData.length >= 2) {

// first 2 bytes are manufacturerId
unsigned short manufId = 0;
[manufData getBytes:&manufId length:2];
// first 2 bytes are manufacturerId (little endian)
uint8_t bytes[2];
[manufData getBytes:bytes length:2];
unsigned short manufId = (unsigned short) (bytes[0] | bytes[1] << 8);

// trim off first 2 bytes
NSData* trimmed = [manufData subdataWithRange:NSMakeRange(2, manufData.length - 2)];
Expand Down

0 comments on commit 5620749

Please sign in to comment.