Skip to content

Commit

Permalink
Fixbug: Send config when config update.
Browse files Browse the repository at this point in the history
  • Loading branch information
oopsdump committed Feb 5, 2017
1 parent 00baebd commit 53c17c5
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -29,12 +29,8 @@ protected function newOwnModel() {
}
protected function createOwnModelRoot($cfg) {
$dev = OwDevices::create($cfg);
if (!$dev->meta()->first()) {
$dev->meta()->create([]);
}
if (!$dev->webportal()->first()) {
$dev->webportal()->create([]);
}
$dev->meta()->firstOrCreate([]);
$dev->webportal()->firstOrCreate([]);
}
protected $indexOwnModelTag = 'dev_id';
protected function newOwnModelTagRelationships() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,7 @@ protected function newOwnModel() {
}
protected function createOwnModelRoot($cfg) {
$sta = OwStations::create($cfg);
if (!$sta->meta()->first()) {
$sta->meta()->create([]);
}
$sta->meta()->firstOrCreate([]);
}
protected $indexOwnModelTag = 'sta_id';
protected function newOwnModelTagRelationships() {
Expand Down
13 changes: 9 additions & 4 deletions src/opwifi/app/Http/Helpers/Opwifi/DeviceConfigApply.php
Original file line number Diff line number Diff line change
Expand Up @@ -79,17 +79,22 @@ static public function devmeta($meta) {

public function check($sha1) {
$meta = $this->devMeta;

$cfg = $meta->config()->first();
if ($cfg && $cfg->pdata) {

if (!$cfg ||
($sha1 == $meta->op_configed_sha1 &&
$meta->op_configed_last > $cfg->updated_at)) {
return null;
}

if ($cfg->pdata) {
$pdata = json_decode($cfg->pdata, true);
if (isset($pdata['config'])) {
$config = $pdata['config'];
}
}

if ($config && $meta &&
$sha1 != $meta->op_configed_sha1) {
if ($config) {
$setting = $this->getSetting('/', $config);
if (count($setting) > 0) {
return $setting;
Expand Down

0 comments on commit 53c17c5

Please sign in to comment.