public function import($services, $deviceIndex)
 {
     $subscriptionCount = 0;
     foreach ($services as $service) {
         if (isset($service['serviceUuid']) && is_array($service['serviceUuid'])) {
             $service['serviceUuid'] = $service['serviceUuid'][0];
         }
         if (!($serviceModel = Service::find()->where(array('device' => $deviceIndex, 'serviceUuid' => $service['serviceUuid']))->one())) {
             $serviceModel = new Service();
         }
         $service = array_merge($service, array('device' => $deviceIndex));
         $serviceModel->setAttributes($service);
         if ($serviceModel->save()) {
             $serviceIndex = $serviceModel->getPrimaryKey();
             if (isset($service['charasteristics'])) {
                 $subscriptionCount += \app\models\Charasteristic::import($service['charasteristics'], $serviceIndex);
             }
         }
         //else {
         //die(print_r( $serviceModel->getErrors(),true));
         //}
     }
     return $subscriptionCount;
 }