Skip to content

Commit

Permalink
docs updated
Browse files Browse the repository at this point in the history
  • Loading branch information
Juraj Veverka committed Apr 26, 2020
1 parent 3943041 commit d0948d4
Show file tree
Hide file tree
Showing 6 changed files with 16 additions and 10 deletions.
12 changes: 7 additions & 5 deletions rpi-powercontroller/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ Detailed [hardware bill of material](docs/hardware-bom.md).
* No frameworks, plain java.

### Configuration
__rpi-powercontroller__ requires external [JSON configuration](src/main/resources/configuration.json) file in order to load initial configuration.
__rpi-powercontroller__ requires external [JSON configuration](src/main/resources/rpi-configuration.json) file in order to load initial configuration.
Please check [configuration manual](docs/rpi-powercontroller-configuration.md) for details.

### Jobs, Tasks and Actions
Expand Down Expand Up @@ -104,18 +104,19 @@ gradle clean build test installDist distZip
i2cdetect -y 1
```
5. Install java, JRE 8 is enough.
* Raspberry PI zero [32bit Oracle JRE 8 for ARM](https://www.oracle.com/java/technologies/javase-jdk8-downloads.html)
* Raspberry 3 or later ``apt install default-jdk``
* RaspberryPI zero [32bit Oracle JRE 8 for ARM](https://www.oracle.com/java/technologies/javase-jdk8-downloads.html)
* RaspberryPI 2, 3 or later ``sudo apt install default-jdk``
6. Create installation directory on target RPi device.
```
mkdir -p /opt/rpi-powercontroller
sudo mkdir -p /opt/rpi-powercontroller
sudo chown pi:pi /opt/rpi-powercontroller
```
7. Build distribution zip and copy the zip and init scripts to target RPi device.
```
gradle clean build test installDist distZip
scp build/distributions/rpi-powercontroller-1.0.0.zip pi@<ip-address>:/opt/rpi-powercontroller/
scp -r scripts/* pi@<ip-address>:/opt/rpi-powercontroller/
scp src/main/resources/configuration.json pi@<ip-address>:/opt/rpi-powercontroller/
scp src/main/resources/rpi-configuration.json pi@<ip-address>:/opt/rpi-powercontroller/
```
8. Finish installation on target RPi device.
```
Expand All @@ -127,6 +128,7 @@ gradle clean build test installDist distZip
sudo chown root:root /etc/systemd/system/rpi-powercontroller.service
sudo systemctl daemon-reload
sudo systemctl enable rpi-powercontroller
touch /opt/rpi-powercontroller/rpi-powercontroller.log
```
Edit JSON configuration file as required, follow configuration manual.
9. Start, stop, get status of rpi-powercontroller service.
Expand Down
8 changes: 6 additions & 2 deletions rpi-powercontroller/scripts/controller-start.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,10 @@
export JAVA_HOME=/opt/rpi-powercontroller/jdk1.8.0_251
export PATH=$JAAVA_HOME/bin:$PATH

CONFIG=/opt/rpi-powercontroller/configuration.json
LOG_FILE=/opt/rpi-powercontroller/rpi-powercontroller.log
CONFIG=/opt/rpi-powercontroller/rpi-configuration.json

mv $LOG_FILE $LOG_FILE.old

/opt/rpi-powercontroller/rpi-powercontroller-1.0.0/bin/rpi-powercontroller $CONFIG > $LOG_FILE 2>&1

/opt/rpi-powercontroller/rpi-powercontroller-1.0.0/bin/rpi-powercontroller $CONFIG
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ public static void main(String[] args) throws IOException {
}
} else {
LOG.info("Using default configuration.");
InputStream is = PowerControllerApp.class.getResourceAsStream("/configuration.json");
InputStream is = PowerControllerApp.class.getResourceAsStream("/rpi-configuration.json");
configuration = mapper.readValue(is, Configuration.class);
}
LOG.info("#CONFIG: id={}", configuration.getId());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ public class ConfigLoadTests {
@Test
public void configLoadTest() throws IOException {
ObjectMapper mapper = new ObjectMapper();
InputStream is = ConfigLoadTests.class.getResourceAsStream("/configuration.json");
InputStream is = ConfigLoadTests.class.getResourceAsStream("/rpi-configuration.json");
Configuration configuration = mapper.readValue(is, Configuration.class);
assertNotNull(configuration);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ public static void init() throws IOException {
httpClient = HttpClients.createDefault();
executorService = Executors.newSingleThreadExecutor();
mapper = new ObjectMapper();
InputStream is = PowerControllerApp.class.getResourceAsStream("/configuration.json");
InputStream is = PowerControllerApp.class.getResourceAsStream("/rpi-configuration.json");
configuration = mapper.readValue(is, Configuration.class);
clientSecret = configuration.getCredentials().get(CLIENT_ID);
services = PowerControllerApp.initialize(mapper, configuration);
Expand Down

0 comments on commit d0948d4

Please sign in to comment.