Can You Upload A Music File Through Blynk
What is Blynk?
Blynk is a platform with iOS and Android apps to command Arduino, ESP8266, Raspberry Pi and the likes over the Cyberspace.
You lot can easily build graphic interfaces for all your projects by only dragging and dropping widgets. If y'all need more data, please follow these links:
- Blynk site
- Blynk docs
- Blynk community
- Blynk Examples generator
- App Shop
- Google Play
- Blynk library
- Kickstarter
Content
- Download
- Requirements
- Quick Local Server setup
- Enabling mail on Local server
- Quick local server setup on Raspberry PI
- Docker container setup
- Enabling server motorcar restart on unix-like systems
- Enabling server auto restart on Windows
- Update instruction for unix-like systems
- Update pedagogy for Windows
- App and sketch changes for Local Server
- Advanced local server setup
- Administration UI
- HTTP/South RESTful API
- Enabling sms on local server
- Enabling raw data storage
- Automated Let's Encrypt Certificates
- Manual Permit's Encrypt SSL/TLS Certificates
- Generate own SSL certificates
- Install coffee for Ubuntu
- How Blynk Works?
- Blynk Protocol
GETTING STARTED
Blynk server
Blynk Server is an Open-Source Netty based Java server, responsible for forwarding messages between Blynk mobile awarding and various microcontroller boards and SBCs (i.east. Arduino, Raspberry Pi. etc).
Download latest server build hither.
Requirements
- Java eight/11 required (OpenJDK, Oracle)
- Whatever Os that can run java
- At least 30 MB of RAM (could be less with tuning)
- Open ports 9443 (for app and hardware with ssl), 8080 (for hardware without ssl)
Ubuntu java installation pedagogy.
For Windows download Java here and install.
Quick local server setup
-
Make certain y'all are using Java 11
java -version Output: java version "11"
-
Run the server on default 'hardware port 8080' and default 'application port 9443' (SSL port)
java -jar server-0.41.xvi.jar -dataFolder /path
That's it!
NOTE: /path
should exist real existing path to folder where you desire to shop all your data.
-
As an output y'all should see something similar that:
Blynk Server successfully started. All server output is stored in current binder in 'logs/blynk.log' file.
Enabling mail on Local server
To enable mail notifications on Local server you need to provide your own mail credentials. Create file mail.backdrop
inside same folder where server.jar
is. Mail properties:
mail.smtp.auth=true mail.smtp.starttls.enable=truthful post.smtp.host=smtp.gmail.com mail.smtp.port=587 mail service.smtp.username=YOUR_EMAIL_HERE postal service.smtp.password=YOUR_EMAIL_PASS_HERE
Find example here.
Warning : only gmail accounts are allowed.
Notation : you'll need to setup Gmail to allow less secured applications. Go here and then click "Allow less secure apps".
Quick local server setup on Raspberry PI
- Login to Raspberry Pi via ssh;
-
Install coffee 8:
sudo apt install openjdk-8-jdk openjdk-eight-jre
-
Brand sure you are using Coffee 8
coffee -version Output: java version "1.8"
-
Download Blynk server jar file (or manually re-create it to Raspberry Pi via ssh and scp command):
wget "https://github.com/blynkkk/blynk-server/releases/download/v0.41.16/server-0.41.16-java8.jar"
-
Run the server on default 'hardware port 8080' and default 'application port 9443' (SSL port)
java -jar server-0.41.16-java8.jar -dataFolder /abode/pi/Blynk
That'due south it!
-
As output you volition see something similar that:
Blynk Server successfully started. All server output is stored in current folder in 'logs/blynk.log' file.
Docker container setup
Quick Launch
- Install Docker
-
Run Docker container
docker run -p 8080:8080 -p 9443:9443 mpherg/blynk-server
Quick Launch on Raspberry Pi
- Install Docker
-
Run Docker container
docker run -p 8080:8080 -p 9443:9443 linuxkonsult/rasbian-blynk
Full customisation
- Check [README](server/Docker) in docker folder
Enabling server auto restart on unix-like systems
-
To enable server auto restart find /etc/rc.local file and add:
coffee -jar /home/pi/server-0.41.16-java8.jar -dataFolder /home/pi/Blynk &
-
Or if the approach above doesn't work, execute
crontab -e
add the following line
@reboot java -jar /domicile/pi/server-0.41.sixteen-java8.jar -dataFolder /home/pi/Blynk &
save and exit.
Enabling server automobile restart on Windows
-
Create bat file:
start-blynk.bat
-
Put in information technology one line:
java -jar server-0.41.xvi.jar -dataFolder /dwelling/pi/Blynk
-
Put bat file to windows startup folder
You can besides use this script to run server.
Update teaching for unix-similar systems
IMPORTANT Server should be always updated earlier yous update Blynk App. To update your server to a newer version yous would need to kill old process and start a new one.
-
Discover process id of Blynk server
ps -aux | grep java
-
You lot should see something like that
username 10539 1.0 12.1 3325808 428948 pts/76 Sl Jan22 9:xi coffee -jar server-0.41.xvi.jar
-
Kill the old procedure
kill 10539
10539 - blynk server process id from command output above.
- Start new server equally usual
Afterward this steps yous tin update Blynk app. Server version downgrade is not supported.
WARNING! Please do not revert your server to lower versions. You lot may loose all of your information.
Update instruction for Windows
-
Open Task Manager;
-
Detect Coffee process;
-
Finish process;
-
Kickoff new server every bit usual
App and sketch changes
- Specify custom server path in your application
-
Modify your ethernet sketch from
Blynk.brainstorm(auth);
to
Blynk.brainstorm(auth, "your_host", 8080);
or to
Blynk.begin(auth, IPAddress(thirty,xxx,xxx,xxx), 8080);
-
Alter your WIFI sketch from
Blynk.begin(auth, SSID, pass));
to
Blynk.begin(auth, SSID, pass, "your_host", 8080);
or to
Blynk.begin(auth, SSID, pass, IPAddress(XXX,XXX,Thirty,Xxx), 8080);
-
Change your rasp PI javascript from
var blynk = new Blynk.Blynk(AUTH, options = {connector : new Blynk.TcpClient()});
to
var blynk = new Blynk.Blynk(AUTH, options= {addr:"30.xxx.thirty.thirty", port:8080});
-
or in example of USB when running blynk-ser.sh provide '-s' option with accost of your local server
./blynk-ser.sh -s you_host_or_IP
IMPORTANT Blynk is beingness constantly developed. Mobile apps and server are updated often. To avert problems during updates either plough off auto-update for Blynk app, or update both local server and blynk app at same time to avoid possible migration bug.
IMPORTANT Blynk local server is unlike from Blynk Cloud server. They are non related at all. You have to create new business relationship when using Blynk local server.
Advanced local server setup
For more than flexibility you can extend server with more than options by creating server.backdrop
file in same folder as server.jar
. Example could exist found here. Yous could also specify whatever path to server.backdrop
file via command line statement -serverConfig
. You can practise the same with mail.backdrop
via -mailConfig
and sms.properties
via -smsConfig
.
For example:
java -jar server-0.41.sixteen-java8.jar -dataFolder /habitation/pi/Blynk -serverConfig /home/pi/someFolder/server.backdrop
Bachelor server options:
-
Blynk app, https, web sockets, admin port
https.port=9443
-
Http, hardware and web sockets port
http.port=8080
-
For simplicity Blynk already provides server jar with built in SSL certificates, so you lot have working server out of the box via SSL/TLS sockets. Merely as certificate and it'southward private central are in public this is totally non secure. And then in society to set that you demand to provide your own certificates. And change below properties with path to your cert. and private primal and it'southward password. See how to generate cocky-signed certificates here
#points to cert and key that placed in same folder as running jar. server.ssl.cert=./server_embedded.crt server.ssl.key=./server_embedded.pem server.ssl.key.pass=pupkin123
Note: if you use Permit's Encrypt certificates y'all'll take to add together #ascertain BLYNK_SSL_USE_LETSENCRYPT
before #include <BlynkSimpleEsp8266_SSL.h>
in the Arduino Sketch for your hardware.
-
User profiles folder. Folder in which all users profiles will exist stored. Past default System.getProperty("java.io.tmpdir")/blynk used. Volition be created if non exists
data.binder=/tmp/blynk
-
Folder for all application logs. Will be created if it doesn't exist. "." is dir from which y'all are running script.
logs.folder=./logs
-
Log debug level. Possible values: trace|debug|info|error. Defines how precise logging volition be. From left to right -> maximum logging to minimum
log.level=trace
-
Maximum allowed number of user dashboards.
user.dashboard.max.limit=100
-
100 Req/sec rate limit per user. You also may want to extend this limit on hardware side.
user.message.quota.limit=100
-
this setting defines how oftentimes you can ship mail/tweet/push or whatsoever other notification. Specified in seconds
notifications.frequency.user.quota.limit=60
-
Maximum allowed user profile size. In Kb's.
user.contour.max.size=128
-
Number of strings to shop in terminal widget (terminal history data)
terminal.strings.pool.size=25
-
Maximum immune number of notification queue. Queue responsible for processing email, pushes, twits sending. Considering of performance issue - those queue is processed in divide thread, this is required due to blocking nature of all above operations. Usually limit shouldn't be reached
notifications.queue.limit=5000
-
Number of threads for performing blocking operations - push, twits, emails, db queries. Recommended to hold this value low unless you take to perform a lot of blocking operations.
blocking.processor.thread.pool.limit=half-dozen
-
Period for flushing all user DB to disk. In millis
profile.save.worker.flow=60000
-
Specifies maximum period of time when hardware socket could be idle. Subsequently which socket will be closed due to non activity. In seconds. Leave it empty for infinity timeout
hard.socket.idle.timeout=15
-
More often than not required for local servers setup in case user want to log raw information in CSV format. See raw data department for more info.
enable.raw.data.store=true
-
Url for opening admin page. Must start from "/". For "/admin" url path volition expect like that "https://127.0.0.1:9443/admin".
admin.rootPath=/admin
-
Comma separated list of ambassador IPs. Permit admission to admin UI only for those IPs. You lot may prepare it for 0.0.0.0/0 to let access for all. You may utilise CIDR notation. For example, 192.168.0.53/24.
immune.administrator.ips=0.0.0.0/0
-
Default admin proper name and countersign. Will be created on initial server start
[electronic mail protected] admin.pass=admin
-
Host for reset countersign redirect and document generation. By default current server IP is taken from "eth" network interface. Could be replaced with more friendly hostname. It is recommended to override this property with your server IP to avoid possible problems of host resolving.
server.host=blynk-cloud.com
-
Email used for document registration, could be omitted in example you already specified it in mail.properties.
[email protected]
Assistants UI
Blynk server provides administration panel where you tin can monitor your server. It is attainable at this URL:
https://your_ip:9443/admin
WARNING Please change default admin password and name right after login to admin page. THIS IS SECURITY MEASURE.
WARNING Default immune.administrator.ips
setting allows access for everyone. In other words, administration page available from any other computer. Please restrict access to it via holding immune.administrator.ips
.
Turn off chrome https warning on localhost
-
Paste in chrome
chrome://flags/#let-insecure-localhost
-
Y'all should see highlighted text maxim: "Allow invalid certificates for resource loaded from localhost". Click enable.
HTTP/S RESTful
Blynk HTTP/S RESTful API allows to easily read and write values to/from Pins in Blynk apps and Hardware. Http API description could be institute here.
Enabling sms on local server
To enable SMS notifications on Local Server you need to provide credentials for SMS gateway (currently Blynk server supports only i provider - Nexmo. Yous need to create file sms.backdrop
within same binder where server.jar is.
nexmo.api.key= nexmo.api.secret=
And fill in the above backdrop with the credentials you'll get from Nexmo. (Business relationship -> Settings -> API settings). You lot can also send SMS over email if your cell provider supports that. Come across give-and-take for more details.
Enabling raw data storage
By default raw data storage is disabled (as it consumes disk space a lot). When you enable it, every Blynk.virtualWrite
command will exist saved to DB. You will demand to install PostgreSQL Database (minimum required version is 9.5) to enable this functionality:
i. Enabling raw information on server
Enable raw information in server.properties
:
enable.db=truthful enable.raw.db.data.store=truthful
two. Install PostgreSQL. Choice A
sudo sh -c 'echo "deb http://apt.postgresql.org/pub/repos/apt/ `lsb_release -cs`-pgdg main" >> /etc/apt/sources.listing.d/pgdg.listing' wget -q https://www.postgresql.org/media/keys/ACCC4CF8.asc -O - | sudo apt-key add - sudo apt-get update sudo apt-get install postgresql postgresql-contrib
2. Install PostgreSQL. Option B
sudo apt-become update apt-get --no-install-recommends install postgresql-ix.six postgresql-contrib-9.6
3. Download Blynk DB script
wget https://raw.githubusercontent.com/blynkkk/blynk-server/master/server/cadre/src/chief/resource/create_schema.sql wget https://raw.githubusercontent.com/blynkkk/blynk-server/master/server/core/src/main/resources/reporting_schema.sql
four. Move create_schema.sql and reporting_schema.sql to temp folder (to avoid permission bug)
mv create_schema.sql /tmp mv reporting_schema.sql /tmp
Result:
/tmp/create_schema.sql /tmp/reporting_schema.sql
Copy it to clipboard from your panel.
5. Connect to PostgreSQL
sudo su - postgres psql
6. Create Blynk DB and Reporting DB, exam user and tables
\i /tmp/create_schema.sql \i /tmp/reporting_schema.sql
/tmp/create_schema.sql
- is path from pace iv.
You should see next output:
postgres=# \i /tmp/create_schema.sql CREATE DATABASE Y'all are now connected to database "blynk" equally user "postgres". CREATE TABLE CREATE TABLE CREATE Tabular array CREATE TABLE CREATE TABLE CREATE Tabular array CREATE TABLE CREATE Table CREATE TABLE CREATE Tabular array CREATE TABLE CREATE ROLE GRANT GRANT
Quit
\q
Now beginning your server and yous should see next text in postgres.log
file :
2017-03-02 sixteen:17:18.367 - DB url : jdbc:postgresql://localhost:5432/blynk?tcpKeepAlive=true&socketTimeout=150 2017-03-02 16:17:18.367 - DB user : test 2017-03-02 sixteen:17:18.367 - Connecting to DB... 2017-03-02 16:17:18.455 - Continued to database successfully.
Warning: Raw data may consume your disk space very quickly!
CSV information format
Data format is:
value,timestamp,deviceId
For example:
10,1438022081332,0
Where 10
- value of pin. 1438022081332
- the difference, measured in milliseconds, betwixt the current time and midnight, January ane, 1970 UTC. To display the date/fourth dimension in excel you lot may use formula:
=((COLUMN/(60*60*24)/chiliad+25569))
0
- device id
Automatic Let's Encrypt certificates generation
Latest Blynk server has super cool feature - automatic Let'south Encrypt certificates generation. Withal, it has few requirements:
-
Add together
server.host
property inserver.properties
file. For example :server.host=myhost.com
IP is non supported, this is the limitation of Let's Encrypt. As well accept in mind that myhost.com
should be resolved by public DNS severs.
-
Add
contact.email
property inserver.backdrop
. For case :[email protected]
-
You need to start server on port fourscore (requires root or admin rights) or make port forwarding to default Blynk HTTP port - 8080.
That'southward it! Run server as regular and certificates will be generated automatically.
Manual Permit's Encrypt SSL/TLS Certificates
-
First install certbot on your server (machine where you going to run Blynk Server)
wget https://dl.eff.org/certbot-car chmod a+x certbot-auto
-
Generate and verify certificates (your server should exist connected to internet and take open 80/443 ports)
./certbot-auto certonly --hold-tos --email YOUR_EMAIL --standalone -d YOUR_HOST
For example
./certbot-motorcar certonly --hold-tos --email [email protected] --standalone -d blynk.cc
-
Then add to your
server.backdrop
file (in folder with server.jar)server.ssl.cert=/etc/letsencrypt/live/YOUR_HOST/fullchain.pem server.ssl.primal=/etc/letsencrypt/alive/YOUR_HOST/privkey.pem server.ssl.cardinal.pass=
Generate own SSL certificates
-
Generate self-signed certificate and key
openssl req -x509 -nodes -days 1825 -newkey rsa:2048 -keyout server.key -out server.crt
-
Convert server.key to PKCS#8 private primal file in PEM format
openssl pkcs8 -topk8 -v1 PBE-SHA1-2DES -in server.key -out server.enc.key
If you connect hardware with USB script yous have to provide an option '-southward' pointing to "common name" (hostname) you did specified during certificate generation.
As an output y'all'll retrieve server.crt and server.pem files that yous demand to provide for server.ssl properties.
Install java for Ubuntu
sudo add together-apt-repository ppa:openjdk-r/ppa \ && sudo apt-get update -q \ && sudo apt install -y openjdk-11-jdk
or if above doesn't piece of work:
sudo apt-add-repository ppa:webupd8team/coffee sudo apt-get update sudo apt-go install oracle-java8-installer
Port forwarding for HTTP/S API
sudo iptables -t nat -A PREROUTING -p tcp --dport eighty -j REDIRECT --to-port 8080 sudo iptables -t nat -A PREROUTING -p tcp --dport 443 -j REDIRECT --to-port 9443
Enabling QR generation on server
sudo apt-get install libxrender1
Backside wifi router
If you want to run Blynk server behind WiFi-router and want it to be accessible from the Internet, you have to add together port-forwarding rule on your router. This is required in order to forrard all of the requests that come up to the router within the local network to Blynk server.
How to build
Blynk has a agglomeration of integration tests that crave DB, so you lot accept to skip tests during build.
mvn clean install -Dmaven.exam.skip=true
How Blynk Works?
When hardware connects to Blynk deject it opens either keep-alive ssl/tls connection on port 443 (9443 for local servers) or keep-alive obviously tcp/ip connection on port 8080. Blynk app opens mutual ssl/tls connection to Blynk Cloud on port 443 (9443 for local servers). Blynk Deject is responsible for forwarding messages between hardware and app. In both (app and hardware) connections Blynk uses own binary protocol described below.
Blynk protocol
Hardware side protocol
Blynk transfers binary messages between the server and the hardware with the following structure:
Command | Message Id | Length/Status | Body |
---|---|---|---|
1 byte | 2 bytes | 2 bytes | Variable |
Control and Condition definitions: BlynkProtocolDefs.h
Mobile app side protocol
Blynk transfers binary letters between the server and mobile app with the post-obit structure:
Command | Message Id | Length/Condition | Body |
---|---|---|---|
1 byte | 2 bytes | 4 bytes | Variable |
Websockets web side protocol
Blynk transfers binary messages between the server and websockets (for web) with the following structure:
Websocket header | Command | Message Id | Body |
---|---|---|---|
i byte | 2 bytes | Variable |
When command code == 0, than bulletin structure is next:
Websocket header | Command | Message Id | Response code |
---|---|---|---|
1 byte | ii bytes | iv bytes |
Possible response codes. Possible command codes
Message Id and Length are big endian. Trunk has a command-specific format.
Licensing
GNU GPL license
*Note that all licence references and agreements mentioned in the blynk README section above are relevant to that project'due south source code simply.
Source: https://selfhosted.libhunt.com/blynk-server-alternatives
Posted by: feathersairming.blogspot.com
0 Response to "Can You Upload A Music File Through Blynk"
Post a Comment