summaryrefslogtreecommitdiff
path: root/SmartDeviceLink/SDLTCPTransport.m
diff options
context:
space:
mode:
authorJoel Fischer <joeljfischer@gmail.com>2017-03-06 10:34:05 -0500
committerJoel Fischer <joeljfischer@gmail.com>2017-03-06 10:34:05 -0500
commit853fa76210f5b3af0b85eab0e144697da0491d76 (patch)
tree1fae56240eb5aa4e5654204344fe30df545d4abf /SmartDeviceLink/SDLTCPTransport.m
parentecdc48956e107009cafceccdf8154285d6d139da (diff)
downloadsdl_ios-853fa76210f5b3af0b85eab0e144697da0491d76.tar.gz
SDLDebugTool logs are translated to new logs
Diffstat (limited to 'SmartDeviceLink/SDLTCPTransport.m')
-rw-r--r--SmartDeviceLink/SDLTCPTransport.m30
1 files changed, 15 insertions, 15 deletions
diff --git a/SmartDeviceLink/SDLTCPTransport.m b/SmartDeviceLink/SDLTCPTransport.m
index 4891b49aa..2695e8c6d 100644
--- a/SmartDeviceLink/SDLTCPTransport.m
+++ b/SmartDeviceLink/SDLTCPTransport.m
@@ -4,6 +4,7 @@
#import "SDLTCPTransport.h"
#import "SDLLogMacros.h"
+#import "SDLLogManager.h"
#import "SDLHexUtility.h"
#import <errno.h>
#import <netdb.h>
@@ -33,7 +34,7 @@ static void TCPCallback(CFSocketRef socket, CFSocketCallBackType type, CFDataRef
- (instancetype)init {
if (self = [super init]) {
_sendQueue = dispatch_queue_create("com.sdl.transport.tcp.transmit", DISPATCH_QUEUE_SERIAL);
- // [SDLDebugTool logInfo:@"SDLTCPTransport Init" withType:SDLDebugType_Transport_iAP toOutput:SDLDebugOutput_All toGroup:self.debugConsoleGroupName];
+ SDLLogD(@"TCP Transport initialization");
}
return self;
@@ -44,11 +45,11 @@ static void TCPCallback(CFSocketRef socket, CFSocketCallBackType type, CFDataRef
}
- (void)connect {
- // [SDLDebugTool logInfo:@"TCP Transport attempt connect" withType:SDLDebugType_Transport_TCP];
+ SDLLogD(@"Attemping to connect");
int sock_fd = call_socket([self.hostName UTF8String], [self.portNumber UTF8String]);
if (sock_fd < 0) {
- // [SDLDebugTool logInfo:@"Server Not Ready, Connection Failed" withType:SDLDebugType_Transport_TCP];
+ SDLLogE(@"Server not ready, connection failed");
return;
}
@@ -63,8 +64,7 @@ static void TCPCallback(CFSocketRef socket, CFSocketCallBackType type, CFDataRef
- (void)sendData:(NSData *)msgBytes {
dispatch_async(_sendQueue, ^{
@autoreleasepool {
- NSString *byteStr = [SDLHexUtility getHexString:msgBytes];
- // [SDLDebugTool logInfo:[NSString stringWithFormat:@"Sent %lu bytes: %@", (unsigned long)msgBytes.length, byteStr] withType:SDLDebugType_Transport_TCP toOutput:SDLDebugOutput_DeviceConsole];
+ SDLLogV(@"Sent %lu bytes, %@", (unsigned long)msgBytes.length, [SDLHexUtility getHexString:msgBytes]);
CFSocketError e = CFSocketSendData(socket, NULL, (__bridge CFDataRef)msgBytes, 10000);
if (e != kCFSocketSuccess) {
@@ -80,14 +80,14 @@ static void TCPCallback(CFSocketRef socket, CFSocketCallBackType type, CFDataRef
break;
}
- // [SDLDebugTool logInfo:[NSString stringWithFormat:@"Socket sendData error: %@", errorCause] withType:SDLDebugType_Transport_TCP toOutput:SDLDebugOutput_DeviceConsole];
+ SDLLogE(@"Socket send error: %@", errorCause);
}
}
});
}
- (void)disconnect {
- // [SDLDebugTool logInfo:@"SDLTCPTransport invalidate and dispose"];
+ SDLLogD(@"Disconnect connection");
if (socket != nil) {
CFSocketInvalidate(socket);
@@ -144,24 +144,24 @@ static void TCPCallback(CFSocketRef socket, CFSocketCallBackType type, CFDataRef
// Check if Core disconnected from us
if (CFDataGetLength((CFDataRef)data) <= 0) {
- // [SDLDebugTool logInfo:@"TCPCallback Got a data packet with length 0, the connection was terminated on the other side"];
+ SDLLogW(@"Remote system terminated connection, data packet length 0");
[transport.delegate onTransportDisconnected];
return;
}
// Handle the data we received
- NSMutableString *byteStr = [NSMutableString stringWithCapacity:((int)CFDataGetLength((CFDataRef)data) * 2)];
- for (int i = 0; i < (int)CFDataGetLength((CFDataRef)data); i++) {
- [byteStr appendFormat:@"%02X", ((Byte *)(UInt8 *)CFDataGetBytePtr((CFDataRef)data))[i]];
+ if ([SDLLogManager sharedManager].globalLogLevel == SDLLogLevelVerbose) {
+ NSMutableString *byteStr = [NSMutableString stringWithCapacity:((int)CFDataGetLength((CFDataRef)data) * 2)];
+ for (int i = 0; i < (int)CFDataGetLength((CFDataRef)data); i++) {
+ [byteStr appendFormat:@"%02X", ((Byte *)(UInt8 *)CFDataGetBytePtr((CFDataRef)data))[i]];
+ }
+ SDLLogV(@"Read %d bytes: %@", (int)CFDataGetLength((CFDataRef)data), byteStr);
}
- // [SDLDebugTool logInfo:[NSString stringWithFormat:@"Read %d bytes: %@", (int)CFDataGetLength((CFDataRef)data), byteStr] withType:SDLDebugType_Transport_TCP toOutput:SDLDebugOutput_DeviceConsole];
-
[transport.delegate onDataReceived:[NSData dataWithBytes:(UInt8 *)CFDataGetBytePtr((CFDataRef)data) length:(int)CFDataGetLength((CFDataRef)data)]];
} else {
- NSString *logMessage = [NSString stringWithFormat:@"unhandled TCPCallback: %lu", type];
- // [SDLDebugTool logInfo:logMessage withType:SDLDebugType_Transport_TCP toOutput:SDLDebugOutput_DeviceConsole];
+ SDLLogW(@"Unhandled callback type: %lu", type);
}
}