{"id":2524,"date":"2016-04-12T17:12:16","date_gmt":"2016-04-12T17:12:16","guid":{"rendered":"http:\/\/www.ckl.io\/?p=2524"},"modified":"2022-07-01T17:59:31","modified_gmt":"2022-07-01T17:59:31","slug":"developing-iot-apps-connecting-smart-devices","status":"publish","type":"post","link":"https:\/\/cheesecakelabs.com\/blog\/developing-iot-apps-connecting-smart-devices\/","title":{"rendered":"Developing IoT apps: connecting to smart devices with Android"},"content":{"rendered":"<p>Internet of Things (IoT) is no longer something reserved for the future or limited to the realm of ideas. It is real and it&#8217;s begun to find its way into our homes turning lamps, locks, security cameras, and several other home appliances into smart devices controlled by your smartphone.<\/p>\n<p>The crucial point, as a developer, is to know how to find and access these devices, allowing people&nbsp;to use&nbsp;this technology to its best extent. To help you in this process, this article lists some of the most popular approaches to finding and connecting to any device in your network when developing IoT apps, and presents some code snippets and examples to get you up and running in no time.<\/p>\n<p><!--more--><\/p>\n<h2>1. DIY &#8211; Network scanning<\/h2>\n<p>Let&#8217;s start with&nbsp;the most basic way, because not all devices implement fancy service discovery protocols. In this example, we need to do all the discovery and connection ourselves. So we roll up our programming sleeves, get our local network netmask and calculate the range of possible IPs.<\/p>\n<pre><code class=\"language-java\">\npublic int getIpv4Netmask(int deviceIP) {\n  try {\n     final byte[] bytes = BigInteger.valueOf(deviceIP).toByteArray();\n     final InetAddress netmaskAddress = InetAddress.getByAddress(bytes);\n     NetworkInterface networkInterface = NetworkInterface.getByInetAddress(netmaskAddress);\n     for (InterfaceAddress address : networkInterface.getInterfaceAddresses()) {\n        final short networkPrefixLength = address.getNetworkPrefixLength();\n        if (networkPrefixLength &lt;= 32) {\n           return networkPrefixLength;\n        }\n     }\n  } catch (UnknownHostException | SocketException e) {\n     e.printStackTrace();\n  }\n  return 0;\n}\n\npublic void someBiggerMethod() {\n  \/\/ ...\n \n  WifiManager wifiManger = (WifiManager) getSystemService(Context.WIFI_SERVICE);\n  DhcpInfo dhcpInfo = wifiManger.getDhcpInfo();\n  int ipAddress = (ByteOrder.nativeOrder().equals(ByteOrder.LITTLE_ENDIAN)) ?\n        Integer.reverseBytes(dhcpInfo.ipAddress) : dhcpInfo.ipAddress;\n  int prefix = getIpv4Netmask(ipAddress);\n  int netmask = 0;\n  for (int j = 0; j &lt; prefix; ++j) {\n     netmask |= (1 &lt;&lt; 31 - j);\n  }\n  int baseNetwork = ipAddress &amp; netmask;\n  int range = (int) Math.pow(2, Integer.SIZE - prefix) - 1;\n  \n  \/\/ ...\n}\n\n<\/code><\/pre>\n<p>This gets you the base network address and the number of possible devices, which will be at least 255 for local networks, and therefore determines the length of our for loop. Inside this loop, we&#8217;ll ping every one of these addresses&nbsp;and&nbsp;log the ones that ACKed us for later connection.<\/p>\n<pre><code class=\"language-java\">\nbyte[] pingIP;\nInetAddress address;\nfor (int i = 0; i &lt; range; ++i) {\n  pingIP = BigInteger.valueOf(baseNetwork | i).toByteArray();\n  address = InetAddress.getByAddress(pingIP);\n  if (address.isReachable(50)) reachableHosts.add(address.getHostName());\n}\n<\/code><\/pre>\n<p>Unfortunately, this only gets you a list of connected IPs, so there&#8217;s still an extra step in identifying whether a particular IP corresponds to your smart device or is the smartTV hanging on your wall. Since we&#8217;re close to the metal here, the obvious course of action&nbsp;is opening a socket and connecting to a pre-defined port.<\/p>\n<pre><code class=\"language-java\">\nInetAddress serverAddr = InetAddress.getByName(ipAddress);\nSocket socket = new Socket(serverAddr, PREDEFINED_PORT);\nPrintWriter out = new PrintWriter(new BufferedWriter(\n     new OutputStreamWriter(socket.getOutputStream())), true);\n<\/code><\/pre>\n<p>If you get a valid connection that passes through your validation process, you just found your device! Otherwise, rinse and repeat until you find it. Needless to say that the above code, as every network operation in Android, must not run in the UI.<\/p>\n<h2>2. Automating the discovery &#8211; zeroconf\/Bonjour<\/h2>\n<p><img decoding=\"async\" class=\"aligncenter wp-image-2547 size-thumbnail\" src=\"https:\/\/ckl-website-static.s3.amazonaws.com\/wp-content\/uploads\/2016\/04\/apple-bonjour-logo-300x300.png\" alt=\"apple bonjour logo: developing iot apps\" width=\"300\" height=\"300\" srcset=\"https:\/\/ckl-website-static.s3.amazonaws.com\/wp-content\/uploads\/2016\/04\/apple-bonjour-logo-300x300.png 300w, https:\/\/ckl-website-static.s3.amazonaws.com\/wp-content\/uploads\/2016\/04\/apple-bonjour-logo.png 332w\" sizes=\"(max-width: 300px) 100vw, 300px\" \/> Let&#8217;s be honest: scanning the network is pretty similar to starting a fire by rubbing sticks \u2013 it takes time and doesn&#8217;t seem very reliable. This is especially true if your network has the bad habit of losing some packages or has DHCP enabled, which may force you to execute the discovery task frequently.<\/p>\n<p>To overcome this, there&#8217;s <a href=\"http:\/\/www.zeroconf.org\/\">zeroconf<\/a> (or Bonjour for Apple products), a blazing fast network discovery tool, with the&nbsp;downside of needing to be configured in your Android app and the IoT device.<\/p>\n<p>The general idea is that one device broadcasts its services to the network and another listens to these broadcasts until it finds something of interest. The latter then resolves the IP of the advertiser of that service and can start communicating.<\/p>\n<p>In Android, this goes by another name: Network Service Discovery (<a href=\"http:\/\/developer.android.com\/intl\/pt-br\/training\/connect-devices-wirelessly\/nsd.html\">NSD<\/a>). All you need to make it work is the <code class=\"language-java\">NsdManager<\/code> class and to know the name of the service you&#8217;re looking for.<\/p>\n<pre><code class=\"language-java\">\nmNsdManager = (NsdManager) context.getSystemService(Context.NSD_SERVICE);\nmDiscoveryListener = new NsdManager.DiscoveryListener() {\n\n   @Override\n   public void onDiscoveryStarted(String regType) {\n      \/\/ ...\n   }\n\n   @Override\n   public void onServiceFound(NsdServiceInfo service) {\n       if (service.getServiceName().contains(myServiceName)){\n           mNsdManager.resolveService(service, mResolveListener);\n       }\n   }\n\n   @Override\n   public void onServiceLost(NsdServiceInfo service) {\n      \/\/ ...\n   }\n  \n   @Override\n   public void onDiscoveryStopped(String serviceType) {\n      \/\/ ...\n   }\n\n   @Override\n   public void onStartDiscoveryFailed(String serviceType, int errorCode) {\n      \/\/ ...\n   }\n\n   @Override\n   public void onStopDiscoveryFailed(String serviceType, int errorCode) {\n      \/\/ ...\n   }\n};\nmNsdManager.discoverServices(SERVICE_TYPE, NsdManager.PROTOCOL_DNS_SD, mDiscoveryListener);\n<\/code><\/pre>\n<p>The service type represents the protocol and the transport layer on which the service operates. The name may be arbitrary and more helpful in finding the right device.<\/p>\n<p>With the <code class=\"language-java\">NsdManager.DiscoveryListener<\/code> configured, all that&#8217;s left is resolving any matching service to get its IP and port number through a resolve service.<\/p>\n<pre><code class=\"language-java\">\nmResolveListener = new NsdManager.ResolveListener() {\n\n   @Override\n   public void onResolveFailed(NsdServiceInfo serviceInfo, int errorCode) {\n      \/\/ ...\n   }\n\n   @Override\n   public void onServiceResolved(NsdServiceInfo serviceInfo) {\n       mService = serviceInfo;\n       Log.i(TAG, \"IP: \" + mService.getHost() + \" Port: \" +  mService.getPort());\n   }\n};\n<\/code><\/pre>\n<p>You will still need&nbsp;to do something with this IP, i.e. open a connection by yourself, maybe using the socket from the first section to send\/receive messages. The next section will discuss how to avoid doing even that.<\/p>\n<h2>3. Transparent network &#8211; AllJoyn\u00ae<\/h2>\n<p><img decoding=\"async\" class=\"aligncenter wp-image-2548 size-full\" src=\"https:\/\/ckl-website-static.s3.amazonaws.com\/wp-content\/uploads\/2016\/04\/CMZoIiBUYAEjc8H.jpg\" alt=\"AllJoyn logo - developing iot android apps\" width=\"600\" height=\"157\"><\/p>\n<p>Designed by the <a href=\"https:\/\/allseenalliance.org\/\">AllSeen Alliance<\/a>, since 2013, a cross-company consortium composed by some big companies such as Microsoft, Philips, and AT&amp;T, AllJoyn\u00ae defines a common protocol for device discovery and communication and has SDKs for all major platforms. In their words:<\/p>\n<blockquote><p>AllJoyn\u00ae is an open source software framework that makes it easy for devices and apps to discover and communicate with each other. Developers can write applications for interoperability regardless of transport layer, manufacturer, and without the need for Internet access.<\/p><\/blockquote>\n<p>The framework works with the concept of Sessions that are created by at least 2 devices connected through a virtual Bus. In Java, a certain device can emit and receive signals, which are messages broadcasted to any device belonging to the same Session.<\/p>\n<p>So first we need to create a <code class=\"language-java\">BusObject<\/code>, which will be used to send our messages. However, to do so we need to instantiate a <a href=\"https:\/\/allseenalliance.org\/docs\/api\/java\/org\/alljoyn\/bus\/BusAttachment.html\"><code class=\"language-java\">BusAttachment<\/code><\/a> object which is our main interface with the framework API. The <code class=\"language-java\">BusAttachment<\/code> is the entity that allows us to connect to a session and find other devices.<\/p>\n<pre><code class=\"language-java\">\nprivate ChatService mChatService = new BusObject();\nprivate BusAttachment mBus = new BusAttachment(APPLICATION_NAME, BusAttachment.RemoteMessage.Receive);\n\npublic void connectToAllJoyn() {\n  org.alljoyn.bus.alljoyn.DaemonInit.PrepareDaemon(getApplicationContext());\n  mBus.registerBusListener(mBusListener)\n  mBus.registerBusObject(mChatService, OBJECT_PATH);\n  mBus.connect()\n}\n\n<\/code><\/pre>\n<p>You may be wondering what the <code class=\"language-java\">BusListener<\/code> object is. This is the interface used to notify when a new service is discovered or when a found one is lost. It will only work after we start our network discovery.<\/p>\n<pre><code class=\"language-java\">\npublic void findService(String serviceName) {\n  mBus.findAdvertisedName(serviceName)\n  private ChatBusListener mBusListener = new BusListener {\n\n    public void foundAdvertisedName(String name, short transport, String namePrefix) {\n      If (name.equals(SERVICE_NAME) storeForLater(); \n    }\n\n    public void lostAdvertisedName(String name, short transport, String namePrefix) {...}\n  }\n}\n<\/code><\/pre>\n<p>After you find the service with the name you were looking for, you should join it before being able&nbsp;to receive and send messages. Joining&nbsp;requires you to set the connection port, that&nbsp;was probably pre-defined, and other options related to the session you&#8217;re about to connect, which can be left empty if you&#8217;re not clear on them.<\/p>\n<pre><code class=\"language-java\">\npublic void joinSession(String serviceName, int contactPort) {\n  Mutable.IntegerValue sessionId = new Mutable.IntegerValue();\n  SessionOpts sessionOpts = new SessionOpts(SessionOpts.TRAFFIC_MESSAGES, true, SessionOpts.PROXIMITY_ANY, SessionOpts.TRANSPORT_ANY);\n  mBus.joinSession(serviceName, contactPort, sessionId, sessionOpts, mOnSessionLostListener();\n}\n<\/code><\/pre>\n<p>To send messages, create a public&nbsp;method&nbsp;annotated with <code>@BusSignalHandler<\/code> and register it&nbsp;with <code class=\"language-java\">registerSignalHandlers()<\/code>, passing the object that contains that public method.<\/p>\n<pre><code class=\"language-java\">\n\/\/ Will search the class for @BusSignalHandler annotated methods\nmBus.registerSignalHandlers(this); \n\n@BusSignalHandler(iface = \"org.alljoyn.bus.samples.chat\", signal = \"Chat\")\npublic void Chat(String message) {\n\t\/\/ Handle message\n}\n<\/code><\/pre>\n<p>To send messages, you&#8217;ll need a <code>@BusInterface<\/code> annotated interface and a SignalEmitter from the Session as follows.<\/p>\n<pre><code class=\"language-java\">\n@BusInterface (name = \"org.alljoyn.bus.samples.chat\")\npublic interface ChatInterface {\n   @BusSignal\n   void Chat(String str) throws BusException;\n}\n\nprivate void sendMessages(String message) {\n SignalEmitter emitter = new SignalEmitter(mChatService, mSessionId, SignalEmitter.GlobalBroadcast.Off);\n mChatInterface = emitter.getInterface(ChatInterface.class);\n mChatInterface.Chat(message);\n}\n<\/code><\/pre>\n<p>When the communication is done, you can leave session and disconnect.<\/p>\n<pre><code class=\"language-java\">\nmBus.leaveSession(mUseSessionId);\nmBus.unregisterBusListener(mBusListener);\nmBus.disconnect();\n<\/code><\/pre>\n<p>And that pretty much sums up the basic usage of AllJoyn\u00ae.<\/p>\n<h2>Wrapping up<\/h2>\n<p>Although not a comprehensive guide on all approaches to discovering and connection to devices in a network, this article sheds some light on how it can be achieved, be it by writing the whole protocol yourself or with the help of some frameworks.<\/p>\n<p>Whichever&nbsp;approach you choose, it is a great time to invest in developing IoT apps and creating solutions for a connected home, car or work place, and if you need some help with that,&nbsp;<a href=\"https:\/\/cheesecakelabs.com\/services\/\">Cheesecake Labs<\/a> is a great match for you.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Internet of Things (IoT) is no longer something reserved for the future or limited to the realm of ideas. It is real and it&#8217;s begun to find its way into our homes turning lamps, locks, security cameras, and several other home appliances into smart devices controlled by your smartphone. The crucial point, as a developer, [&hellip;]<\/p>\n","protected":false},"author":65,"featured_media":2940,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[432],"tags":[15],"class_list":["post-2524","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-engineering","tag-tag-mobile"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v27.1.1 - https:\/\/yoast.com\/product\/yoast-seo-wordpress\/ -->\n<title>Developing IoT apps: finding your IoT devices with Android<\/title>\n<meta name=\"description\" content=\"When developing IoT apps, you&#039;ll need to find and connect to devices in the network. This post shows several approaches to do that with Android.\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/cheesecakelabs.com\/blog\/developing-iot-apps-connecting-smart-devices\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Developing IoT apps: finding your IoT devices with Android\" \/>\n<meta property=\"og:description\" content=\"When developing IoT apps, you&#039;ll need to find and connect to devices in the network. This post shows several approaches to do that with Android.\" \/>\n<meta property=\"og:url\" content=\"https:\/\/cheesecakelabs.com\/blog\/developing-iot-apps-connecting-smart-devices\/\" \/>\n<meta property=\"og:site_name\" content=\"Cheesecake Labs\" \/>\n<meta property=\"article:publisher\" content=\"https:\/\/www.facebook.com\/cheesecakelabs\" \/>\n<meta property=\"article:published_time\" content=\"2016-04-12T17:12:16+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2022-07-01T17:59:31+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/ckl-website-static.s3.amazonaws.com\/wp-content\/uploads\/2016\/04\/howtobepreparedIoT2.jpg\" \/>\n\t<meta property=\"og:image:width\" content=\"2076\" \/>\n\t<meta property=\"og:image:height\" content=\"720\" \/>\n\t<meta property=\"og:image:type\" content=\"image\/jpeg\" \/>\n<meta name=\"author\" content=\"Cheesecake Labs\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:creator\" content=\"@cheesecakelabs\" \/>\n<meta name=\"twitter:site\" content=\"@cheesecakelabs\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"9 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\/\/cheesecakelabs.com\/blog\/developing-iot-apps-connecting-smart-devices\/#article\",\"isPartOf\":{\"@id\":\"https:\/\/cheesecakelabs.com\/blog\/developing-iot-apps-connecting-smart-devices\/\"},\"author\":{\"name\":\"Edson Menegatti\"},\"headline\":\"Developing IoT apps: connecting to smart devices with Android\",\"datePublished\":\"2016-04-12T17:12:16+00:00\",\"dateModified\":\"2022-07-01T17:59:31+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\/\/cheesecakelabs.com\/blog\/developing-iot-apps-connecting-smart-devices\/\"},\"wordCount\":1035,\"commentCount\":1,\"image\":{\"@id\":\"https:\/\/cheesecakelabs.com\/blog\/developing-iot-apps-connecting-smart-devices\/#primaryimage\"},\"thumbnailUrl\":\"https:\/\/ckl-website-static.s3.amazonaws.com\/wp-content\/uploads\/2016\/04\/howtobepreparedIoT2.jpg\",\"keywords\":[\"Mobile\"],\"articleSection\":[\"Engineering\"],\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\/\/cheesecakelabs.com\/blog\/developing-iot-apps-connecting-smart-devices\/#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\/\/cheesecakelabs.com\/blog\/developing-iot-apps-connecting-smart-devices\/\",\"url\":\"https:\/\/cheesecakelabs.com\/blog\/developing-iot-apps-connecting-smart-devices\/\",\"name\":\"Developing IoT apps: finding your IoT devices with Android\",\"isPartOf\":{\"@id\":\"https:\/\/cheesecakelabs.com\/blog\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\/\/cheesecakelabs.com\/blog\/developing-iot-apps-connecting-smart-devices\/#primaryimage\"},\"image\":{\"@id\":\"https:\/\/cheesecakelabs.com\/blog\/developing-iot-apps-connecting-smart-devices\/#primaryimage\"},\"thumbnailUrl\":\"https:\/\/ckl-website-static.s3.amazonaws.com\/wp-content\/uploads\/2016\/04\/howtobepreparedIoT2.jpg\",\"datePublished\":\"2016-04-12T17:12:16+00:00\",\"dateModified\":\"2022-07-01T17:59:31+00:00\",\"author\":{\"@type\":\"person\",\"name\":\"Edson Menegatti\"},\"description\":\"When developing IoT apps, you'll need to find and connect to devices in the network. This post shows several approaches to do that with Android.\",\"breadcrumb\":{\"@id\":\"https:\/\/cheesecakelabs.com\/blog\/developing-iot-apps-connecting-smart-devices\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/cheesecakelabs.com\/blog\/developing-iot-apps-connecting-smart-devices\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/cheesecakelabs.com\/blog\/developing-iot-apps-connecting-smart-devices\/#primaryimage\",\"url\":\"https:\/\/ckl-website-static.s3.amazonaws.com\/wp-content\/uploads\/2016\/04\/howtobepreparedIoT2.jpg\",\"contentUrl\":\"https:\/\/ckl-website-static.s3.amazonaws.com\/wp-content\/uploads\/2016\/04\/howtobepreparedIoT2.jpg\",\"width\":2076,\"height\":720},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/cheesecakelabs.com\/blog\/developing-iot-apps-connecting-smart-devices\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\/\/cheesecakelabs.com\/blog\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Developing IoT apps: connecting to smart devices with Android\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/cheesecakelabs.com\/blog\/#website\",\"url\":\"https:\/\/cheesecakelabs.com\/blog\/\",\"name\":\"Cheesecake Labs\",\"description\":\"Nearshore outsourcing company for Web and Mobile design and engineering services, and staff augmentation for startups and enterprises..\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/cheesecakelabs.com\/blog\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":\"Person\",\"name\":\"Edson Menegatti\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/cheesecakelabs.com\/blog\/#\/schema\/person\/image\/\",\"url\":false,\"contentUrl\":false,\"caption\":\"Edson Menegatti\"},\"description\":\"10 years of experience in Marketing and Sales in the Technology sector. My main purpose is help, support and structure efficient operations and also develop independent and multidisciplinary teams.\",\"url\":\"https:\/\/cheesecakelabs.com\/blog\/autor\/edson\/\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"Developing IoT apps: finding your IoT devices with Android","description":"When developing IoT apps, you'll need to find and connect to devices in the network. This post shows several approaches to do that with Android.","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/cheesecakelabs.com\/blog\/developing-iot-apps-connecting-smart-devices\/","og_locale":"en_US","og_type":"article","og_title":"Developing IoT apps: finding your IoT devices with Android","og_description":"When developing IoT apps, you'll need to find and connect to devices in the network. This post shows several approaches to do that with Android.","og_url":"https:\/\/cheesecakelabs.com\/blog\/developing-iot-apps-connecting-smart-devices\/","og_site_name":"Cheesecake Labs","article_publisher":"https:\/\/www.facebook.com\/cheesecakelabs","article_published_time":"2016-04-12T17:12:16+00:00","article_modified_time":"2022-07-01T17:59:31+00:00","og_image":[{"width":2076,"height":720,"url":"https:\/\/ckl-website-static.s3.amazonaws.com\/wp-content\/uploads\/2016\/04\/howtobepreparedIoT2.jpg","type":"image\/jpeg"}],"author":"Cheesecake Labs","twitter_card":"summary_large_image","twitter_creator":"@cheesecakelabs","twitter_site":"@cheesecakelabs","twitter_misc":{"Written by":null,"Est. reading time":"9 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/cheesecakelabs.com\/blog\/developing-iot-apps-connecting-smart-devices\/#article","isPartOf":{"@id":"https:\/\/cheesecakelabs.com\/blog\/developing-iot-apps-connecting-smart-devices\/"},"author":{"name":"Edson Menegatti"},"headline":"Developing IoT apps: connecting to smart devices with Android","datePublished":"2016-04-12T17:12:16+00:00","dateModified":"2022-07-01T17:59:31+00:00","mainEntityOfPage":{"@id":"https:\/\/cheesecakelabs.com\/blog\/developing-iot-apps-connecting-smart-devices\/"},"wordCount":1035,"commentCount":1,"image":{"@id":"https:\/\/cheesecakelabs.com\/blog\/developing-iot-apps-connecting-smart-devices\/#primaryimage"},"thumbnailUrl":"https:\/\/ckl-website-static.s3.amazonaws.com\/wp-content\/uploads\/2016\/04\/howtobepreparedIoT2.jpg","keywords":["Mobile"],"articleSection":["Engineering"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/cheesecakelabs.com\/blog\/developing-iot-apps-connecting-smart-devices\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/cheesecakelabs.com\/blog\/developing-iot-apps-connecting-smart-devices\/","url":"https:\/\/cheesecakelabs.com\/blog\/developing-iot-apps-connecting-smart-devices\/","name":"Developing IoT apps: finding your IoT devices with Android","isPartOf":{"@id":"https:\/\/cheesecakelabs.com\/blog\/#website"},"primaryImageOfPage":{"@id":"https:\/\/cheesecakelabs.com\/blog\/developing-iot-apps-connecting-smart-devices\/#primaryimage"},"image":{"@id":"https:\/\/cheesecakelabs.com\/blog\/developing-iot-apps-connecting-smart-devices\/#primaryimage"},"thumbnailUrl":"https:\/\/ckl-website-static.s3.amazonaws.com\/wp-content\/uploads\/2016\/04\/howtobepreparedIoT2.jpg","datePublished":"2016-04-12T17:12:16+00:00","dateModified":"2022-07-01T17:59:31+00:00","author":{"@type":"person","name":"Edson Menegatti"},"description":"When developing IoT apps, you'll need to find and connect to devices in the network. This post shows several approaches to do that with Android.","breadcrumb":{"@id":"https:\/\/cheesecakelabs.com\/blog\/developing-iot-apps-connecting-smart-devices\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/cheesecakelabs.com\/blog\/developing-iot-apps-connecting-smart-devices\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/cheesecakelabs.com\/blog\/developing-iot-apps-connecting-smart-devices\/#primaryimage","url":"https:\/\/ckl-website-static.s3.amazonaws.com\/wp-content\/uploads\/2016\/04\/howtobepreparedIoT2.jpg","contentUrl":"https:\/\/ckl-website-static.s3.amazonaws.com\/wp-content\/uploads\/2016\/04\/howtobepreparedIoT2.jpg","width":2076,"height":720},{"@type":"BreadcrumbList","@id":"https:\/\/cheesecakelabs.com\/blog\/developing-iot-apps-connecting-smart-devices\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/cheesecakelabs.com\/blog\/"},{"@type":"ListItem","position":2,"name":"Developing IoT apps: connecting to smart devices with Android"}]},{"@type":"WebSite","@id":"https:\/\/cheesecakelabs.com\/blog\/#website","url":"https:\/\/cheesecakelabs.com\/blog\/","name":"Cheesecake Labs","description":"Nearshore outsourcing company for Web and Mobile design and engineering services, and staff augmentation for startups and enterprises..","potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/cheesecakelabs.com\/blog\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Person","name":"Edson Menegatti","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/cheesecakelabs.com\/blog\/#\/schema\/person\/image\/","url":false,"contentUrl":false,"caption":"Edson Menegatti"},"description":"10 years of experience in Marketing and Sales in the Technology sector. My main purpose is help, support and structure efficient operations and also develop independent and multidisciplinary teams.","url":"https:\/\/cheesecakelabs.com\/blog\/autor\/edson\/"}]}},"_links":{"self":[{"href":"https:\/\/cheesecakelabs.com\/blog\/wp-json\/wp\/v2\/posts\/2524","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/cheesecakelabs.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/cheesecakelabs.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/cheesecakelabs.com\/blog\/wp-json\/wp\/v2\/users\/65"}],"replies":[{"embeddable":true,"href":"https:\/\/cheesecakelabs.com\/blog\/wp-json\/wp\/v2\/comments?post=2524"}],"version-history":[{"count":1,"href":"https:\/\/cheesecakelabs.com\/blog\/wp-json\/wp\/v2\/posts\/2524\/revisions"}],"predecessor-version":[{"id":10355,"href":"https:\/\/cheesecakelabs.com\/blog\/wp-json\/wp\/v2\/posts\/2524\/revisions\/10355"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/cheesecakelabs.com\/blog\/wp-json\/wp\/v2\/media\/2940"}],"wp:attachment":[{"href":"https:\/\/cheesecakelabs.com\/blog\/wp-json\/wp\/v2\/media?parent=2524"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/cheesecakelabs.com\/blog\/wp-json\/wp\/v2\/categories?post=2524"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/cheesecakelabs.com\/blog\/wp-json\/wp\/v2\/tags?post=2524"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}