Make 'chips' and 'states' of the default, not rfid-read

This commit is contained in:
xdrm-brackets 2017-09-28 19:07:30 +02:00
parent 36b3d01006
commit 56f7f99096
2 changed files with 90 additions and 76 deletions

View File

@ -30,58 +30,8 @@
}
/* [2] Get system states (global_state)
=========================================================*/
/* (1) Check data */
if( !isset($arr_r['states']) || !is_array($arr_r['states']) ){
slog('No \'states\' found in response file', "$FEATURE:deploy", 'update');
return 127;
}
/* (2) Reset file */
file_put_contents(STATES_CONF, '');
/* (3) Replace content */
$f = new SplFileObject(STATES_CONF, 'w');
foreach($arr_r['states'] as $state)
$f->fwrite( json_encode([
$state['global_state'],
$state['chips']
]).PHP_EOL );
$f = null;
/* [3] Get chip list (chips)
=========================================================*/
/* (1) Check data */
if( !isset($arr_r['chips']) || !is_array($arr_r['chips']) ){
slog('No \'chips\' found in response file', "$FEATURE:deploy", 'update');
return 127;
}
/* (2) Reset file */
file_put_contents(CHIPS_CONF, '');
/* (3) Replace content */
$f = new SplFileObject(CHIPS_CONF, 'w');
foreach($arr_r['chips'] as $chip)
$f->fwrite( json_encode([
(int) $chip['position'],
$chip['pins'],
$chip['states']
]).PHP_EOL );
$f = null;
/* [4] Get auth list (permissions)
/* [2] Get auth list (permissions)
=========================================================*/
/* (1) Check data */
if( !isset($arr_r['permissions']) || !is_array($arr_r['permissions']) ){
@ -107,7 +57,7 @@
$f = null;
/* [5] Get action list (with timeout)
/* [3] Get action list (with timeout)
=========================================================*/
/* (1) Check data */
if( !isset($arr_r['actions']) || !is_array($arr_r['actions']) ){

View File

@ -109,8 +109,71 @@
/* [4] Deploy default data
=========================================================*/ {
/* (1) Get system states (global_state)
---------------------------------------------------------*/ {
/* (1) Check data */
if( !isset($arr_r['states']) || !is_array($arr_r['states']) ){
slog('No \'states\' found in response file', "$FEATURE:deploy", 'update');
return 127;
}
/* (2) Reset file */
file_put_contents(STATES_CONF, '');
/* (3) Replace content */
$f = new SplFileObject(STATES_CONF, 'w');
foreach($arr_r['states'] as $state)
$f->fwrite( json_encode([
$state['global_state'],
$state['chips']
]).PHP_EOL );
$f = null;
}
/* (2) Get chip list (chips)
---------------------------------------------------------*/ {
/* (1) Check data */
if( !isset($arr_r['chips']) || !is_array($arr_r['chips']) ){
slog('No \'chips\' found in response file', "$FEATURE:deploy", 'update');
return 127;
}
/* (2) Reset file */
file_put_contents(CHIPS_CONF, '');
/* (3) Replace content */
$f = new SplFileObject(CHIPS_CONF, 'w');
foreach($arr_r['chips'] as $chip)
$f->fwrite( json_encode([
(int) $chip['position'],
$chip['pins'],
$chip['states']
]).PHP_EOL );
$f = null;
}
}
/* [5] Launch deploy script for each feature
=========================================================*/
=========================================================*/ {
slog('Deploying each feature', "api:deploy", 'update');
/* (1) For each feature */
@ -141,6 +204,7 @@
}
}
return 0;
}