     }
     
     // we're in json mode
-    var cmdObj: [String: Any] = [
-      "command": cmd.command.rawValue
-    ]
-    
+    var cmdstr = ""
     // decode the command type and build the command depending on the command
-    switch cmd.command {
-    case .passthrough:
-      cmdObj["bus"] = cmd.bus
-      cmdObj["enabled"] = cmd.enabled
-    case .af_bypass:
-      cmdObj["bus"] = cmd.bus
-      cmdObj["bypass"] = cmd.bypass
-    case .payload_format:
-      cmdObj["format"] = cmd.format
-    case .predefined_odb2:
-      cmdObj["enabled"] = cmd.enabled
-    case .modem_configuration:
-      cmdObj["server"] = [
-        "host": cmd.server_host,
-        "port": cmd.server_port
-      ]
-    case .rtc_configuration:
-      cmdObj["unix_time"] = cmd.unix_time
-    case .version, .device_id, .sd_mount_status, .platform:
-      // no additional args
-      break
-
-    }
-    
-    do {
-      let data = try JSONSerialization.data(withJSONObject: cmdObj, options: [])
-      // append to tx buffer
-      BLETxDataBuffer.add(data)
-      
-      // trigger a BLE data send
-      BLESendFunction()
-    } catch {
-      vmlog("Error serializing command to JSON", error)
-    }
+    if cmd.command == .version || cmd.command == .device_id || cmd.command == .sd_mount_status || cmd.command == .platform {
+      // build the command json
+      cmdstr = "{\"command\":\"\(cmd.command.rawValue)\"}\0"
+    }
+    else if cmd.command == .passthrough {
+      // build the command json
+      cmdstr = "{\"command\":\"\(cmd.command.rawValue)\",\"bus\":\(cmd.bus),\"enabled\":\(cmd.enabled)}\0"
+    }
+    else if cmd.command == .af_bypass {
+      // build the command json
+      cmdstr = "{\"command\":\"\(cmd.command.rawValue)\",\"bus\":\(cmd.bus),\"bypass\":\(cmd.bypass)}\0"
+    }
+    else if cmd.command == .payload_format {
+      // build the command json
+      cmdstr = "{\"command\":\"\(cmd.command.rawValue)\",\"format\":\"\(cmd.format)\"}\0"
+    }
+    else if cmd.command == .predefined_odb2 {
+      // build the command json
+      cmdstr = "{\"command\":\"\(cmd.command.rawValue)\",\"enabled\":\(cmd.enabled)}\0"
+    }
+    else if cmd.command == .modem_configuration {
+      // build the command json
+      cmdstr = "{\"command\":\"\(cmd.command.rawValue)\",\"server\":{\"host\":\"\(cmd.server_host)\",\"port\":\(cmd.server_port)}}\0"
+    }
+    else if cmd.command == .rtc_configuration {
+      // build the command json
+      let timeInterval = Date().timeIntervalSince1970
+      cmd.unix_time = NSInteger(timeInterval);
+      print("timestamp is..",cmd.unix_time)
+      cmdstr = "{\"command\":\"\(cmd.command.rawValue)\",\"unix_time\":\"\(cmd.unix_time)\"}\0"
+    } else {
+      // unknown command!
+      return
+      
+    }
+    
+    // append to tx buffer
+    BLETxDataBuffer.add(cmdstr.data(using: String.Encoding.utf8, allowLossyConversion: false)!)
+    
+    // trigger a BLE data send
+    BLESendFunction()
+    
   }
   
   
   // common function for sending a VehicleDiagnosticRequest
   fileprivate func sendDiagCommon(_ cmd:VehicleDiagnosticRequest) {
     vmlog("in sendDiagCommon")
- 
+    
     if !jsonMode {
       // in protobuf mode, build diag message
       let cbuild = ControlCommand.Builder()

      print("")
    }
  }

  
  // change the auto connect config for the VM
  open func setAutoconnect(_ on:Bool) {

          }
          
          // capture this message into the dictionary of latest messages
          latestVehicleMeasurements.setValue(rsp, forKey:name as String)
          
          // look for a specific callback for this measurement name
          var found=false
          for key in measurementCallbacks.keys {
            let act = measurementCallbacks[key]
            if act!.returnKey() as String == name {
              found=true
              act!.performAction(["vehiclemessage":rsp] as NSDictionary)
            }
