@@ -480,12 +480,12 @@ - (void)peripheralManagerDidUpdateState:(CBPeripheralManager *)peripheral {
480480 error = logPoweredOff;
481481 break ;
482482 }
483-
483+
484484 case CBManagerStateUnauthorized: {
485485 error = logUnauthorized;
486486 break ;
487487 }
488-
488+
489489 case CBManagerStateUnknown: {
490490 error = logUnknown;
491491 break ;
@@ -495,27 +495,27 @@ - (void)peripheralManagerDidUpdateState:(CBPeripheralManager *)peripheral {
495495 error = logResetting;
496496 break ;
497497 }
498-
498+
499499 case CBManagerStateUnsupported: {
500500 error = logUnsupported;
501501 break ;
502502 }
503-
503+
504504 case CBManagerStatePoweredOn: {
505505 // Bluetooth on!
506506 break ;
507507 }
508508 }
509-
509+
510510 NSDictionary * returnObj = nil ;
511511 CDVPluginResult* pluginResult = nil ;
512-
512+
513513 if (error) {
514514 returnObj = [NSDictionary dictionaryWithObjectsAndKeys: @" disabled" , @" status" , error, @" message" , nil ];
515515 } else {
516516 returnObj = [NSDictionary dictionaryWithObjectsAndKeys: @" enabled" , @" status" , nil ];
517517 }
518-
518+
519519 pluginResult = [CDVPluginResult resultWithStatus: CDVCommandStatus_OK messageAsDictionary: returnObj];
520520 [pluginResult setKeepCallbackAsBool: true ];
521521 [self .commandDelegate sendPluginResult: pluginResult callbackId: initPeripheralCallback];
@@ -1584,16 +1584,16 @@ - (void)writeQ:(CDVInvokedUrlCommand *)command {
15841584
15851585 // Set the callback
15861586 [self addCallback: characteristic.UUID forConnection: connection forOperationType: operationWrite forCallback: command.callbackId];
1587-
1587+
15881588 // Get the write type (response or no response)
15891589 writeQtype = [self getWriteType: obj];
1590-
1590+
15911591 writeQLength = [writeQData length ];
15921592 writeQLocation = 0 ;
15931593 writeQChunkSize = [self getChunkSize: obj];
1594-
1594+
15951595 writeQIsRunning = true ;
1596-
1596+
15971597 [self writeDataToCharacteristic: characteristic toPeripheral: peripheral];
15981598}
15991599
@@ -1808,7 +1808,7 @@ - (void)isInitialized:(CDVInvokedUrlCommand *)command {
18081808- (void )isEnabled : (CDVInvokedUrlCommand *)command {
18091809 // See if Bluetooth is currently enabled
18101810 NSNumber * result = [NSNumber numberWithBool: (centralManager != nil && centralManager.state == CBManagerStatePoweredOn)];
1811-
1811+
18121812 NSDictionary * returnObj = [NSDictionary dictionaryWithObjectsAndKeys: result, keyIsEnabled, nil ];
18131813 CDVPluginResult* pluginResult = [CDVPluginResult resultWithStatus: CDVCommandStatus_OK messageAsDictionary: returnObj];
18141814 [pluginResult setKeepCallbackAsBool: false ];
@@ -2015,27 +2015,27 @@ - (void) centralManagerDidUpdateState:(CBCentralManager *)central {
20152015 error = logPoweredOff;
20162016 break ;
20172017 }
2018-
2018+
20192019 case CBManagerStateUnauthorized: {
20202020 error = logUnauthorized;
20212021 break ;
20222022 }
2023-
2023+
20242024 case CBManagerStateUnknown: {
20252025 error = logUnknown;
20262026 break ;
20272027 }
2028-
2028+
20292029 case CBManagerStateResetting: {
20302030 error = logResetting;
20312031 break ;
20322032 }
2033-
2033+
20342034 case CBManagerStateUnsupported: {
20352035 error = logUnsupported;
20362036 break ;
20372037 }
2038-
2038+
20392039 case CBManagerStatePoweredOn: {
20402040 // Bluetooth on!
20412041 break ;
@@ -2659,43 +2659,43 @@ - (void)peripheral:(CBPeripheral *)peripheral didWriteValueForCharacteristic:(CB
26592659 if (connection == nil ) {
26602660 return ;
26612661 }
2662-
2662+
26632663 if (writeQIsRunning && (writeQLocation < writeQLength)) {
26642664 [self writeDataToCharacteristic: characteristic toPeripheral: peripheral];
26652665 } else {
26662666 // Get the proper callback for write operation
26672667 NSString * callback = [self getCallback: characteristic.UUID forConnection: connection forOperationType: operationWrite];
26682668 [self removeCallback: characteristic.UUID forConnection: connection forOperationType: operationWrite];
2669-
2669+
26702670 // Return if callback is null
26712671 if (callback == nil ) {
26722672 return ;
26732673 }
2674-
2674+
26752675 NSMutableDictionary * returnObj = [NSMutableDictionary dictionary ];
2676-
2676+
26772677 [self addDevice: peripheral :returnObj];
26782678 [self addCharacteristic: characteristic :returnObj];
2679-
2679+
26802680 // If error exists, return error
26812681 if (error != nil ) {
26822682 [returnObj setValue: errorWrite forKey: keyError];
26832683 [returnObj setValue: error.description forKey: keyMessage];
2684-
2684+
26852685 CDVPluginResult *pluginResult = [CDVPluginResult resultWithStatus: CDVCommandStatus_ERROR messageAsDictionary: returnObj];
26862686 [pluginResult setKeepCallbackAsBool: false ];
26872687 [self .commandDelegate sendPluginResult: pluginResult callbackId: callback];
26882688 return ;
26892689 }
2690-
2690+
26912691 // Add characteristic value to object
26922692 [self addValue: characteristic.value toDictionary: returnObj];
2693-
2693+
26942694 // Update status
26952695 [returnObj setValue: statusWritten forKey: keyStatus];
2696-
2696+
26972697 writeQIsRunning = false ;
2698-
2698+
26992699 // Return data
27002700 CDVPluginResult *pluginResult = [CDVPluginResult resultWithStatus: CDVCommandStatus_OK messageAsDictionary: returnObj];
27012701 [pluginResult setKeepCallbackAsBool: false ];
@@ -2861,7 +2861,7 @@ - (void) peripheral:(CBPeripheral *)peripheral didReadRSSI:(NSNumber *)RSSI erro
28612861- (void )peripheralIsReadyToSendWriteWithoutResponse : (CBPeripheral *)peripheral {
28622862 CBCharacteristic * const characteristic = currentWriteCharacteristic;
28632863 currentWriteCharacteristic = nil ;
2864-
2864+
28652865 if (characteristic && writeQIsRunning) {
28662866 if (writeQLocation < writeQLength) {
28672867 [self writeDataToCharacteristic: characteristic toPeripheral: peripheral];
@@ -2871,22 +2871,22 @@ - (void)peripheralIsReadyToSendWriteWithoutResponse:(CBPeripheral *)peripheral {
28712871 if (connection == nil ) {
28722872 return ;
28732873 }
2874-
2874+
28752875 // Get the proper callback for write operation
28762876 NSString * callback = [self getCallback: characteristic.UUID forConnection: connection forOperationType: operationWrite];
28772877 [self removeCallback: characteristic.UUID forConnection: connection forOperationType: operationWrite];
2878-
2878+
28792879 NSMutableDictionary * returnObj = [NSMutableDictionary dictionary ];
2880-
2880+
28812881 [self addDevice: peripheral :returnObj];
28822882 [self addCharacteristic: characteristic :returnObj];
2883-
2883+
28842884 [self addValue: characteristic.value toDictionary: returnObj];
2885-
2885+
28862886 [returnObj setValue: statusWritten forKey: keyStatus];
2887-
2887+
28882888 writeQIsRunning = false ;
2889-
2889+
28902890 CDVPluginResult *pluginResult = [CDVPluginResult resultWithStatus: CDVCommandStatus_OK messageAsDictionary: returnObj];
28912891 [pluginResult setKeepCallbackAsBool: false ];
28922892 [self .commandDelegate sendPluginResult: pluginResult callbackId: callback];
@@ -3502,13 +3502,13 @@ -(int) getWriteType:(NSDictionary *)obj {
35023502
35033503-(int ) getChunkSize : (NSDictionary *)obj {
35043504 NSNumber * chunkSize = [obj valueForKey: keyChunkSize];
3505-
3505+
35063506 if (chunkSize == nil ) {
35073507 return 20 ;
35083508 }
3509-
3509+
35103510 int chunkSizeValue = [chunkSize intValue ];
3511-
3511+
35123512 return chunkSizeValue;
35133513}
35143514
@@ -3674,12 +3674,12 @@ - (void)writeDataToCharacteristic:(CBCharacteristic *)characteristic toPeriphera
36743674 data = [self ->writeQData subdataWithRange: NSMakeRange (self ->writeQLocation, self ->writeQChunkSize)];
36753675 self->writeQLocation = self->writeQLocation + self->writeQChunkSize ;
36763676 }
3677-
3677+
36783678 // Since WriteWithoutResponse triggers a different callback which has no access to characteristic
36793679 if (self->writeQtype == CBCharacteristicWriteWithoutResponse) {
36803680 self->currentWriteCharacteristic = characteristic;
36813681 }
3682-
3682+
36833683 [peripheral writeValue: data forCharacteristic: characteristic type: self ->writeQtype];
36843684}
36853685
0 commit comments