<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Blog @ SIB Visions &#187; IoT</title>
	<atom:link href="http://blog.sibvisions.com/tag/iot/feed/" rel="self" type="application/rss+xml" />
	<link>https://blog.sibvisions.com</link>
	<description>Blog @ SIB Visions</description>
	<lastBuildDate>Mon, 13 Apr 2026 09:47:01 +0000</lastBuildDate>
		<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>JVx application on embedded devices</title>
		<link>https://blog.sibvisions.com/2015/02/19/jvx-application-on-embedded-devices/</link>
		<comments>https://blog.sibvisions.com/2015/02/19/jvx-application-on-embedded-devices/#comments</comments>
		<pubDate>Thu, 19 Feb 2015 15:58:41 +0000</pubDate>
		<dc:creator>rjahn</dc:creator>
				<category><![CDATA[Development]]></category>
		<category><![CDATA[IoT]]></category>
		<category><![CDATA[JVx]]></category>
		<category><![CDATA[RaspberryPi]]></category>

		<guid isPermaLink="false">http://blog.sibvisions.com/?p=3775</guid>
		<description><![CDATA[In the last weeks, we did many experiments with JVx on Raspberry Pi, especially using a Pi as server for JVx applications. Our vision was that the business logic could run on a Pi without Java application server like Tomcat or Jetty. Our example application was a simple sensor recorder. We read temperature data and [...]]]></description>
			<content:encoded><![CDATA[<p>In the last weeks, we did many experiments with JVx on Raspberry Pi, especially using a Pi as server for JVx applications. Our vision was that the business logic could run on a Pi without Java application server like Tomcat or Jetty. Our example application was a simple sensor recorder. We read temperature data and stored the read data into a JavaDB (on the same device). We knew that Jetty and Tomcat worked on a Pi but it was not necessary to run an application server without web content.</p>
<p>We tried different implementations:</p>
<ul>
<li><strong>Fun</strong>
<p>A recorder class that saved data directly in the JavaDB. A good old Java application with one DBStorage because plain JDBC was painful.</li>
<li><strong>Because JVx can do that</strong>
<p>A simple recorder client with embedded JVx server. The client was a simple class with a DirectServerConnection. The server saved retrieved temperature data in the JavaDB.</li>
<li><strong>Production</strong>
<p>The same simple recorder client but the server run standalone. The DirectServerConnection was replaced with a Netconnection.</li>
</ul>
<p>The first implementation was for fun only and not relevant for our tests. Our Pi should be a server that measures data and allows accessing data from JavaDB (for charts). Some real client applications could use the temperature server for integrating temperature data. The same application could use other Sensor data from different RasPis (measuring lux, webcam, ...) - a RasPi (sensor) network.</p>
<p>The big problem was that JVx server didn't work without an application server. It worked embedded and via http, but we didn't have a plain socket implementation. It wasn't a JVx problem because the server component was ready for socket connections but we didn't have a Socket server. We made some experiments with vert.x and the result was a nice socket server. We also used JVx with vert.x Http server. Both implementations are available on <a href="https://github.com/sibvisions/jvx.vert.x">GitHub</a>. It worked like a charm but we didn't like the library dependencies. We already had a socket server API for our product VisionX, but it wasn't decoupled. Now it is!</p>
<p>We used the VisionX socket API and merged it in our applications library. After some modifications and bugfixes, in JVx, it's now possible to use it without additional dependencies. It's a simple socket server for JVx server component. We've used this server to run VisionX and had no problems. VisionX is a huge JVx application and if VisionX works, all other JVx applications will work.</p>
<p>It's very simple to use the the socket server:</p>
<div class="codesnip-container" >
<div class="java codesnip" style="font-family:monospace;">NetServer server <span class="sy0">=</span> <span class="kw1">new</span> NetServer<span class="br0">&#40;</span><span class="st0">&quot;servername&quot;</span>, 556<span class="br0">&#41;</span><span class="sy0">;</span><br />
server.<span class="me1">start</span><span class="br0">&#40;</span><span class="br0">&#41;</span><span class="sy0">;</span></div>
</div>
<p>The server has a main method and you can use it without additional coding. Simply set the system properties <strong>server.hostname</strong>, <strong>server.port</strong>.</p>
<p>To open a connection, simply call:</p>
<div class="codesnip-container" >
<div class="java codesnip" style="font-family:monospace;">IConnection con <span class="sy0">=</span> <span class="kw1">new</span> NetConnection<span class="br0">&#40;</span><span class="st0">&quot;servername&quot;</span>, 556<span class="br0">&#41;</span><span class="sy0">;</span></p>
<p>MasterConnection appcon <span class="sy0">=</span> <span class="kw1">new</span> MasterConnection<span class="br0">&#40;</span>con<span class="br0">&#41;</span><span class="sy0">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <br />
appcon.<span class="me1">setApplicationName</span><span class="br0">&#40;</span><span class="st0">&quot;tempsensor&quot;</span><span class="br0">&#41;</span><span class="sy0">;</span><br />
appcon.<span class="me1">setUserName</span><span class="br0">&#40;</span><span class="st0">&quot;user&quot;</span><span class="br0">&#41;</span><span class="sy0">;</span><br />
appcon.<span class="me1">setPassword</span><span class="br0">&#40;</span><span class="st0">&quot;password&quot;</span><span class="br0">&#41;</span><span class="sy0">;</span><br />
appcon.<span class="me1">open</span><span class="br0">&#40;</span><span class="br0">&#41;</span><span class="sy0">;</span></div>
</div>
<p>Not really rocket-science and just works!</p>
<p>The only problem was the server name and port configuration, for every client. Not really cool in a "sensor network". So we started a simple Broadcaster. It's a simple class that checks the network for existing servers. It's easy to use on client-side:</p>
<div class="codesnip-container" >
<div class="java codesnip" style="font-family:monospace;">List<span class="sy0">&lt;</span>ConnectInfo<span class="sy0">&gt;</span> liConInfo <span class="sy0">=</span> Broadcaster.<span class="me1">search</span><span class="br0">&#40;</span><span class="st0">&quot;MyAPP&quot;</span><span class="br0">&#41;</span><span class="sy0">;</span></div>
</div>
<p>and the server side isn't too complex:</p>
<div class="codesnip-container" >
<div class="java codesnip" style="font-family:monospace;">Broadcaster broadcaster <span class="sy0">=</span> <span class="kw1">new</span> Broadcaster<span class="br0">&#40;</span><span class="br0">&#41;</span><span class="sy0">;</span><br />
broadcaster.<span class="me1">setServerPort</span><span class="br0">&#40;</span>556<span class="br0">&#41;</span><span class="sy0">;</span><br />
broadcaster.<span class="me1">setIdentifier</span><span class="br0">&#40;</span><span class="st0">&quot;MyAPP&quot;</span><span class="br0">&#41;</span><span class="sy0">;</span><br />
broadcaster.<span class="me1">start</span><span class="br0">&#40;</span><span class="br0">&#41;</span><span class="sy0">;</span></div>
</div>
<p>The result contains a list of available hostnames and ports for the first found server. It's still space for a better solution, but I think that's the reason why vert.x uses <a href="https://hazelcast.org/">hazelcast</a>.</p>
<p>To cut a long story short: It's now possible to use complete JVx applications without Java application server, especially on embedded devices like RaspberryPi.</p>
<p>Sure, it's still recommended to use an application server if your device serves web content or a whole web application e.g. with JVx' vaadin UI (see <a href="https://blog.sibvisions.com/2015/01/08/iot-window-shutter-control-with-jvx-vaadin-and-raspberrypi/">IoT: Window shutter control</a>).</p>
]]></content:encoded>
			<wfw:commentRss>https://blog.sibvisions.com/2015/02/19/jvx-application-on-embedded-devices/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
