Skip to content

Commit

Permalink
Bumping version to 0.3.3
Browse files Browse the repository at this point in the history
  • Loading branch information
forki committed Oct 15, 2018
1 parent 55ac796 commit 9bc7078
Show file tree
Hide file tree
Showing 8 changed files with 77 additions and 38 deletions.
23 changes: 22 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -67,10 +67,31 @@ network={

* Create a file called `ssh` (no ending) on the SD-Card. It can be left empty.

#### Activate SPI master driver

* Modify `config.txt` and remove the comment before `dtparam=spi=on`. [more info](https://www.raspberrypi.org/documentation/hardware/raspberrypi/spi/README.md)

### Wiring up the RFID module

* The following schema shows the wiring for the RFID-RC522 Mifare reader.
* ATTENTION: Please note that some vendors have a slightly different layout on the module and that the free pin may be at a different position.

![Wiring](src/PiServer/rpi-mfrc522-wiring2.png)

### Connecting to the Raspberry Pi

* Put the SD-Card into the Raspberry Pi
* Connect the Raspberry Pi with the USB-Charger
* Try to find out the [IP of your device](https://www.raspberrypi.org/documentation/remote-access/ip-address.md)
* Connect to the Raspberry Pi via SSH (you can use [putty](https://www.putty.org/) on Windows)
* Username: "pi", Password: "raspberry"
* Change the default password with the command `passwd`
* Change the default password with the command `passwd`

### Installing latest firmware

* `sudo apt-get update`
* `sudo apt-get install curl unzip`
* `curl -sSL -o firmware.zip https://audio-hub.azurewebsites.net/api/latestfirmware`
* `unzip firmware.zip -d firmware && rm firmware.zip`
* `chmod u+x firmware/install.sh`
* `sudo firmware/install.sh`
3 changes: 3 additions & 0 deletions RELEASE_NOTES.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
# Release Notes

## 0.3.3 - 2018-10-15
* run npm during install

## 0.3.2 - 2018-10-10
* Bundle firmware installer

Expand Down
5 changes: 4 additions & 1 deletion src/Client/ReleaseNotes.fs
Original file line number Diff line number Diff line change
@@ -1,12 +1,15 @@
module internal ReleaseNotes

let Version = "0.3.2"
let Version = "0.3.3"

let IsPrerelease = false

let Notes = """
# Release Notes
## 0.3.3 - 2018-10-15
* run npm during install
## 0.3.2 - 2018-10-10
* Bundle firmware installer
Expand Down
29 changes: 15 additions & 14 deletions src/PiServer/install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,20 +3,21 @@
DOTNETREQ=2.1.5
SCRIPTROOT=`dirname "$0"`
SOURCEPATH=$SCRIPTROOT/bin
DEFAULTDAEMONHOME=/home/pi/PiServer/publish
DEFAULTS=/etc/default/PiServer
PROJECTNAME=PiServer
DEFAULTDAEMONHOME=/home/pi/$PROJECTNAME/publish
DEFAULTS=/etc/default/$PROJECTNAME

DAEMONHOME=$1
if [ "x$DAEMONHOME" = "x" ]; then
if [ -e $SCRIPTROOT/PiServer.defaults ]; then
. $SCRIPTROOT/PiServer.defaults
if [ -e $SCRIPTROOT/$PROJECTNAME.defaults ]; then
. $SCRIPTROOT/$PROJECTNAME.defaults
else
DAEMONHOME=$DEFAULTDAEMONHOME
fi
fi

sudo apt-get update
sudo apt-get install curl libunwind8 gettext apt-transport-https omxplayer pulseaudio-module-bluetooth
sudo apt-get install curl libunwind8 gettext apt-transport-https omxplayer pulseaudio-module-bluetooth npm

curl -sSL -o dotnet.tar.gz https://download.visualstudio.microsoft.com/download/pr/4d555219-1f04-47c6-90e5-8b3ff8989b9c/0798763e6e4b98a62846116f997d046e/dotnet-runtime-2.1.5-linux-arm.tar.gz
sudo mkdir -p /opt/dotnet && sudo tar zxf dotnet.tar.gz -C /opt/dotnet
Expand All @@ -26,22 +27,22 @@ sudo ln -s /opt/dotnet/dotnet /usr/local/bin
pulseaudio -k
pulseaudio --start

if [ -e $SCRIPTROOT/PiServer ]; then
if [ ! -e $DEFAULTS -a $SCRIPTROOT/PiServer.defaults ]; then
cat $SCRIPTROOT/PiServer.defaults | grep -v "DAEMONHOME=" > $DEFAULTS
echo DAEMONHOME=$DAEMONHOME >> $DEFAULTS
if [ -e $SCRIPTROOT/$PROJECTNAME ]; then
if [ ! -e $DEFAULTS -a $SCRIPTROOT/$PROJECTNAME.defaults ]; then
echo DAEMONHOME=$DAEMONHOME > $DEFAULTS
cat $SCRIPTROOT/$PROJECTNAME.defaults | grep -v "DAEMONHOME=" >> $DEFAULTS
fi

if [ ! -d $DAEMONHOME ]; then
mkdir -p $DAEMONHOME
fi

cp -r $SOURCEPATH/. $DAEMONHOME
cp $SCRIPTROOT/PiServer /etc/init.d/
chmod +x /etc/init.d/PiServer
cp $SCRIPTROOT/$PROJECTNAME /etc/init.d/
chmod +x /etc/init.d/$PROJECTNAME
chmod +x $DAEMONHOME/$NAME
systemctl daemon-reload
systemctl enable PiServer
service PiServer start
service PiServer status
systemctl enable $PROJECTNAME
service $PROJECTNAME start
service $PROJECTNAME status
fi
5 changes: 4 additions & 1 deletion src/PiServer/read-tag.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,14 @@ exports.read = function (callback, lastTag) {
//# Get the UID of the card
response = mfrc522.getUid();
if (!response.status) {
console.log("UID Scan Error");
callback(null, "");
return;
}

const uid = response.data;
var data = uid.map(x => x.toString(16)).join('');
if (uid.length < 7){
data = uid[0].toString(16) + uid[1].toString(16) + uid[2].toString(16) + uid[3].toString(16);
}
callback(null, data);
}
Binary file added src/PiServer/rpi-mfrc522-wiring2.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
24 changes: 14 additions & 10 deletions src/PiServer/update.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,26 +4,27 @@

DOTNETREQ=2.1.5
SCRIPTROOT=`dirname "$0"`
DEFAULTS=/etc/default/PiServer
PROJECTNAME=PiServer
DEFAULTS=/etc/default/$PROJECTNAME
SOURCEPATH=$SCRIPTROOT/bin

if [ ! -e $DEFAULTS -a $SCRIPTROOT/PiServer.defaults ]; then
cp $SCRIPTROOT/PiServer.defaults $DEFAULTS
if [ ! -e $DEFAULTS -a $SCRIPTROOT/$PROJECTNAME.defaults ]; then
cp $SCRIPTROOT/$PROJECTNAME.defaults $DEFAULTS
fi

if [ -e $DEFAULTS ]; then
log_action_begin_msg "Loading PiServer settings"
. /etc/default/PiServer
log_action_begin_msg "Loading $PROJECTNAME settings"
. /etc/default/$PROJECTNAME
log_action_end_msg $?

if [ ! -e $DAEMON ]; then
log_failure_msg "PiServer not installed! Update "
log_failure_msg "$PROJECTNAME not installed! Update "
exit 1
fi

if [ -e $SOURCEPATH/$NAME ]; then
log_action_begin_msg "Stop service"
service PiServer stop
service $PROJECTNAME stop
retval=$?
log_action_end_msg $retval
if [ $retval -ne 0 ]; then
Expand All @@ -32,20 +33,23 @@ if [ -e $DEFAULTS ]; then

log_action_begin_msg "Updating"
log_action_cont_msg "Init script"
cp $SCRIPTROOT/PiServer /etc/init.d/
chmod +x /etc/init.d/PiServer
cp $SCRIPTROOT/$PROJECTNAME /etc/init.d/

chmod +x /etc/init.d/$PROJECTNAME
log_action_cont_msg "Reloading system.d"
systemctl daemon-reload
log_action_end_msg $?

log_action_begin_msg "Updating $DAEMONHOME"
rm -R $DAEMONHOME && cp -r $SOURCEPATH/. $DAEMONHOME

(cd $DAEMONHOME && npm install)
chmod +x $DAEMONHOME/$NAME
log_action_end_msg $?

if [ -e $DAEMON ]; then
log_action_begin_msg "Starting service"
service PiServer start
service $PROJECTNAME start
log_action_end_msg $?
fi
else
Expand Down
26 changes: 15 additions & 11 deletions src/Server/Server.fs
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ let getSASMediaLink mediaID = task {
policy.SharedAccessStartTime <- Nullable(DateTimeOffset.UtcNow)
policy.Permissions <- SharedAccessBlobPermissions.Read
let sas = blockBlob.GetSharedAccessSignature(policy)

return blockBlob.Uri.ToString() + sas
}

Expand All @@ -39,7 +39,7 @@ let uploadMusik (stream:Stream) = task {

let blobClient = connection.CreateCloudBlobClient()
let mediaContainer = blobClient.GetContainerReference "media"
let! _ = mediaContainer.CreateIfNotExistsAsync()
let! _ = mediaContainer.CreateIfNotExistsAsync()

let blockBlob = mediaContainer.GetBlockBlobReference(mediaID.ToString())
blockBlob.Properties.ContentType <- "audio/mpeg"
Expand All @@ -50,7 +50,7 @@ let uploadMusik (stream:Stream) = task {

let mapBlobMusikTag (tag:Tag) = task {
match tag.Action with
| TagAction.PlayBlobMusik mediaID ->
| TagAction.PlayBlobMusik mediaID ->
let! sas = getSASMediaLink(mediaID.ToString())
return { tag with Action = TagAction.PlayMusik sas }
| _ -> return tag
Expand Down Expand Up @@ -82,7 +82,7 @@ let tagEndpoint (userID,token) =
pipeline {
set_header "Content-Type" "application/json"
plug (fun next ctx -> task {

let! tag = AzureTable.getTag userID token
let! tag =
match tag with
Expand All @@ -103,7 +103,7 @@ let allTagsEndpoint userID =
tags
|> Array.map mapBlobMusikTag
|> Task.WhenAll

let txt = TagList.Encoder { Tags = tags } |> Encode.toString 0
return! setBodyFromString txt next ctx
})
Expand All @@ -115,8 +115,8 @@ let startupEndpoint =
plug (fun next ctx -> task {
let! sas = getSASMediaLink "d97cdddb-8a19-4690-8ba5-b8ea43d3641f"
let actions = [TagAction.PlayMusik sas]
let txt =

let txt =
actions
|> List.map TagAction.Encoder
|> Encode.list
Expand All @@ -125,16 +125,19 @@ let startupEndpoint =
})
}


let firmwareLink = sprintf "https://github.com/forki/Audio/releases/download/%s/PiFirmware.%s.zip" ReleaseNotes.Version ReleaseNotes.Version

let getLatestFirmware next ctx = redirectTo false firmwareLink next ctx

let firmwareEndpoint =
pipeline {
set_header "Content-Type" "application/json"
plug (fun next ctx -> task {
let current = {
let current = {
Version = ReleaseNotes.Version
Url = sprintf "https://github.com/forki/Audio/releases/download/%s/PiFirmware.%s.zip" ReleaseNotes.Version ReleaseNotes.Version
Url = firmwareLink
}

let txt = Firmware.Encoder current |> Encode.toString 0
return! setBodyFromString txt next ctx
})
Expand All @@ -147,6 +150,7 @@ let webApp =
post "/api/upload" uploadEndpoint
get "/api/startup" startupEndpoint
get "/api/firmware" firmwareEndpoint
get "/api/latestfirmware" getLatestFirmware
}

let configureSerialization (services:IServiceCollection) =
Expand Down

0 comments on commit 9bc7078

Please sign in to comment.