Skip to content

Commit

Permalink
fix(ios): fixed all data commands as data in tibuffer was not valid
Browse files Browse the repository at this point in the history
  • Loading branch information
anil-shukla-axway committed Mar 16, 2021
1 parent ecf1073 commit 4dd5487
Showing 1 changed file with 66 additions and 21 deletions.
87 changes: 66 additions & 21 deletions ios/Classes/TiNfcVTagTechnology.m
Original file line number Diff line number Diff line change
Expand Up @@ -68,11 +68,16 @@ - (void)writeSingleBlockWithRequestFlags:(id)args
NSNumber *blockNumberValue = [[args firstObject] valueForKey:@"blockNumber"];
uint8_t blockNumber = [blockNumberValue unsignedCharValue];

TiBuffer *dataBlock = [[args firstObject] valueForKey:@"blockNumber"];
NSArray *dataBlock = [[args firstObject] valueForKey:@"blockNumber"];
unsigned int dataValue[dataBlock.count];
for (int i = 0; i < dataBlock.count; i++) {
dataValue[i] = [dataBlock[i] unsignedIntValue];
}
NSData *data = [[NSData alloc] initWithBytes:dataValue length:dataBlock.count];

[[self.tagProxy asNFCISO15693Tag] writeSingleBlockWithRequestFlags:requestFlags
blockNumber:blockNumber
dataBlock:dataBlock.data
dataBlock:data
completionHandler:^(NSError *_Nullable error) {
if (![self _hasListeners:@"didWriteSingleBlockWithRequestFlags"]) {
return;
Expand Down Expand Up @@ -143,12 +148,18 @@ - (void)writeMultipleBlocksWithRequestFlags:(id)args
NSNumber *requestFlagsValue = [[args firstObject] valueForKey:@"requestFlags"];
uint8_t requestFlags = [requestFlagsValue unsignedCharValue];

TiBuffer *responseDataValue = [[args firstObject] valueForKey:@"blockNumber"];
NSArray *dataBlock = [[NSArray alloc] initWithObjects:responseDataValue, nil];
NSArray *dataBlock = [[args firstObject] valueForKey:@"blockNumber"];
unsigned int dataValue[dataBlock.count];
for (int i = 0; i < dataBlock.count; i++) {
dataValue[i] = [dataBlock[i] unsignedIntValue];
}
NSData *data = [[NSData alloc] initWithBytes:dataValue length:dataBlock.count];

NSArray *dataBlocks = [[NSArray alloc] initWithObjects:data, nil];

[[self.tagProxy asNFCISO15693Tag] writeMultipleBlocksWithRequestFlags:requestFlags
blockRange:NSMakeRange(0, 8)
dataBlocks:dataBlock
dataBlocks:dataBlocks
completionHandler:^(NSError *_Nullable error) {
if (![self _hasListeners:@"didWriteMultipleBlocksWithRequestFlags"]) {
return;
Expand Down Expand Up @@ -305,11 +316,16 @@ - (void)customCommandWithRequestFlag:(id)args

NSNumber *customCommandCode = [[args firstObject] valueForKey:@"customCommandCode"];

TiBuffer *customRequestParameters = [[args firstObject] valueForKey:@"customRequestParameters"];
NSArray *customRequestParameters = [[args firstObject] valueForKey:@"customRequestParameters"];
unsigned int dataValue[customRequestParameters.count];
for (int i = 0; i < customRequestParameters.count; i++) {
dataValue[i] = [customRequestParameters[i] unsignedIntValue];
}
NSData *data = [[NSData alloc] initWithBytes:dataValue length:customRequestParameters.count];

[[self.tagProxy asNFCISO15693Tag] customCommandWithRequestFlag:requestFlags
customCommandCode:[customCommandCode integerValue]
customRequestParameters:customRequestParameters.data
customRequestParameters:data
completionHandler:^(NSData *_Nonnull customResponseParameters, NSError *_Nullable error) {
if (![self _hasListeners:@"didCustomCommandWithRequestFlag"]) {
return;
Expand Down Expand Up @@ -360,11 +376,16 @@ - (void)extendedWriteSingleBlockWithRequestFlags:(id)args

NSNumber *blockNumber = [[args firstObject] valueForKey:@"blockNumber"];

TiBuffer *dataBlock = [[args firstObject] valueForKey:@"dataBlock"];
NSArray *dataBlock = [[args firstObject] valueForKey:@"dataBlock"];
unsigned int dataValue[dataBlock.count];
for (int i = 0; i < dataBlock.count; i++) {
dataValue[i] = [dataBlock[i] unsignedIntValue];
}
NSData *data = [[NSData alloc] initWithBytes:dataValue length:dataBlock.count];

[[self.tagProxy asNFCISO15693Tag] extendedWriteSingleBlockWithRequestFlags:requestFlags
blockNumber:[blockNumber integerValue]
dataBlock:dataBlock.data
dataBlock:data
completionHandler:^(NSError *_Nullable error) {
if (![self _hasListeners:@"didExtendedReadSingleBlockWithRequestFlags"]) {
return;
Expand Down Expand Up @@ -448,11 +469,16 @@ - (void)authenticateWithRequestFlags:(id)args

NSNumber *cryptoSuiteIdentifier = [[args firstObject] valueForKey:@"cryptoSuiteIdentifier"];

TiBuffer *message = [[args firstObject] valueForKey:@"message"];
NSArray *message = [[args firstObject] valueForKey:@"message"];
unsigned int dataValue[message.count];
for (int i = 0; i < message.count; i++) {
dataValue[i] = [message[i] unsignedIntValue];
}
NSData *data = [[NSData alloc] initWithBytes:dataValue length:message.count];

[[self.tagProxy asNFCISO15693Tag] authenticateWithRequestFlags:requestFlags
cryptoSuiteIdentifier:[cryptoSuiteIdentifier integerValue]
message:message.data
message:data
completionHandler:^(NFCISO15693ResponseFlag responseFlag, NSData *_Nonnull response, NSError *_Nullable error) {
if (![self _hasListeners:@"didAuthenticateWithRequestFlags"]) {
return;
Expand All @@ -473,11 +499,16 @@ - (void)challengeWithRequestFlags:(id)args

NSNumber *cryptoSuiteIdentifier = [[args firstObject] valueForKey:@"cryptoSuiteIdentifier"];

TiBuffer *message = [[args firstObject] valueForKey:@"message"];
NSArray *message = [[args firstObject] valueForKey:@"message"];
unsigned int dataValue[message.count];
for (int i = 0; i < message.count; i++) {
dataValue[i] = [message[i] unsignedIntValue];
}
NSData *data = [[NSData alloc] initWithBytes:dataValue length:message.count];

[[self.tagProxy asNFCISO15693Tag] challengeWithRequestFlags:requestFlags
cryptoSuiteIdentifier:[cryptoSuiteIdentifier integerValue]
message:message.data
message:data
completionHandler:^(NSError *_Nullable error) {
if (![self _hasListeners:@"didChallengeWithRequestFlags"]) {
return;
Expand Down Expand Up @@ -536,12 +567,17 @@ - (void)extendedWriteMultipleBlocksWithRequestFlags:(id)args
NSNumber *requestFlagsValue = [[args firstObject] valueForKey:@"requestFlags"];
uint8_t requestFlags = [requestFlagsValue unsignedCharValue];

TiBuffer *responseDataValue = [[args firstObject] valueForKey:@"dataBlock"];
NSArray *dataBlock = [[NSArray alloc] initWithObjects:responseDataValue, nil];
NSArray *dataBlock = [[args firstObject] valueForKey:@"dataBlock"];
unsigned int dataValue[dataBlock.count];
for (int i = 0; i < dataBlock.count; i++) {
dataValue[i] = [dataBlock[i] unsignedIntValue];
}
NSData *data = [[NSData alloc] initWithBytes:dataValue length:dataBlock.count];
NSArray *dataBlocks = [[NSArray alloc] initWithObjects:data, nil];

[[self.tagProxy asNFCISO15693Tag] extendedWriteMultipleBlocksWithRequestFlags:requestFlags
blockRange:NSMakeRange(0, 8)
dataBlocks:dataBlock
dataBlocks:dataBlocks
completionHandler:^(NSError *_Nullable error) {
if (![self _hasListeners:@"didExtendedWriteMultipleBlocksWithRequestFlags"]) {
return;
Expand Down Expand Up @@ -601,11 +637,16 @@ - (void)keyUpdateWithRequestFlags:(id)args

NSNumber *keyIdentifier = [[args firstObject] valueForKey:@"keyIdentifier"];

TiBuffer *message = [[args firstObject] valueForKey:@"message"];
NSArray *message = [[args firstObject] valueForKey:@"message"];
unsigned int dataValue[message.count];
for (int i = 0; i < message.count; i++) {
dataValue[i] = [message[i] unsignedIntValue];
}
NSData *data = [[NSData alloc] initWithBytes:dataValue length:message.count];

[[self.tagProxy asNFCISO15693Tag] keyUpdateWithRequestFlags:requestFlags
keyIdentifier:[keyIdentifier integerValue]
message:message.data
message:data
completionHandler:^(NFCISO15693ResponseFlag responseFlag, NSData *_Nonnull response, NSError *_Nullable error) {
if (![self _hasListeners:@"didKeyUpdateWithRequestFlags"]) {
return;
Expand Down Expand Up @@ -643,11 +684,15 @@ - (void)sendRequestWithFlag:(id)args
NSNumber *flag = [[args firstObject] valueForKey:@"flag"];
NSNumber *commandCode = [[args firstObject] valueForKey:@"commandCode"];

TiBuffer *data = [[args firstObject] valueForKey:@"data"];

NSArray *commandData = [[args firstObject] valueForKey:@"data"];
unsigned int dataValue[commandData.count];
for (int i = 0; i < commandData.count; i++) {
dataValue[i] = [commandData[i] unsignedIntValue];
}
NSData *data = [[NSData alloc] initWithBytes:dataValue length:commandData.count];
[[self.tagProxy asNFCISO15693Tag] sendRequestWithFlag:[flag integerValue]
commandCode:[commandCode integerValue]
data:data.data
data:data
completionHandler:^(NFCISO15693ResponseFlag responseFlag, NSData *_Nullable data, NSError *_Nullable error) {
if (![self _hasListeners:@"didReadBufferWithRequestFlags"]) {
return;
Expand Down

0 comments on commit 4dd5487

Please sign in to comment.