All Things CC:

All things Commuication & Computing….

Posts Tagged ‘IOS Programming

SSDP Service/Device Discovery [Part 2, ROM]

leave a comment »

To begin my project – a Remote OSGi Manager (ROM) as described in my first part here, the first task I picked up was to try developing  a very rudimentary app that would discover the RTCOA Thermostat using the SSDP protocol. As you can see from the screenshot – it is really rudimentary user interface but my focus was to get my MVC right, and more importantly get the network interface going for the project. [BTW if you observe carefully – you can see the “Marvell” code that has been used in the RTCOA Thermostat].





After much searching and reviewing samples, I decided to go with the Cocoa Async Sockets, and I have ended up using them for all of the network interface in my iOS/iPad app. I got started with the AsyncUdpSocket to leverage it for running SSDP based discovery of the RTCOA Thermostat. The screenshot above was the start. I took the SSDP objects (serviceSSDP.m, serviceSSDP.h) and moved them to the bigger project. Also as a first step – the SSDP discovery code stopped after discovering the first controller. Given that in my project I was going to support multiple controllers, I ended up modifying the code to take into account that I should be able to discover multiple controllers (or devices) and then add them to a NSMutableArray.



//  serviceSSDP.h
//  SimpleSSDPDiscovery
//  Created by Ashu Joshi on 3/1/12.
//  Copyright (c) 2012 Movinture, LLC. All rights reserved.


#import <Foundation/Foundation.h>
#import “AsyncUdpSocket.h”
#import “connectedLifeController.h”


@interface serviceSSDP : NSObject


// This is the string that is Multicast to Discover the Controller
@property (strong, nonatomic) NSString *discoverControllerString;
// The Controller would respond with the string below upon discovery being received
@property (strong, nonatomic) NSString *responseStringFromController;
// The list of discovered controllers
@property (strong, nonatomic) NSMutableArray *controllerList;


@property (strong, nonatomic) connectedLifeController *currentController;

@property (strong, nonatomic) AsyncUdpSocket *ssdpSocket;


– (BOOL)startControllerDiscoveryProcess;

– (BOOL)startControllerDiscoveryProcess:(NSMutableArray *)listOfControllers;



Once I got the Thermostat to discover using SSDP discovery code using iOS/iPad, I turned my attention to the Plug Computer. I created the framework for my bundle (OSGi terminology for an application). And the first thing I did was to implement code built out code in Java to run a SSDP “advertise” service on the Plug Computer. Before even migrating or trying the code on the Plug Computer I tried the code on my PC/Mac using Eclipse, once it was working I migrated it as a bundle/service in the OSGi framework on the Plug Computer. This code uses threading so that it is always running on the Plug Computer.


In the next part I will give an overview of the Java/OSGi code and the network interface implemented….

Written by Ashu Joshi

April 10, 2012 at 7:46 pm

iOS Programming: Getting Started, & Sticking To It

leave a comment »

Search the web and you will turn up gazillions of resources on getting started with IOS Programming, and I have done the same. In fact for the last three years I have been spending $99 every year paying for the IOS Developer Subscription and buying books. Apple keeps on revving (albeit not at the same rate as Android) the IOS SDK, APIs and the books that I had bought kept getting obsolete! I tried attending local Meetups and trying sample code. All I was able to do was to or rather hack together a few apps that could control or manage a Set Top Box (STB) using iTouch or iPhone. And the user interface on them was horrible…

Finally last December as I became more engaged and serious I latched on to three critical resources, here they are and the challenges with them:
As a prerequisite to all of the above – you need an Intel-based Mac, I had access to my personal iMac and you need to have the IOS SDK. While the SDK is free, having the $99 membership is required to test with an IOS device [you can get started testing with the IOS Simulator which is part of the free SDK and it is very, very good]. Testing on IOS device, IMHO, is very important. But not having one should not prevent you from getting started, it is however a challenge to keep going and be good at it.

Now, based not the version of the OS (Leopard, Snow Leopard, Lion) on the Mac machine you have and the version of SDK you will have to work around and adapt to a few new concepts and technologies introduced by Apple chief among them being “ARC” (Automatic Reference Count) – which reduces the burden not the programmer by making memory management a linker feature. And on that note – you may want to get the 3rd Edition of the IOS Programming mentioned above because the 2nd Edition is pre-IOS 4.3 SDK and that does not support the ARC. This, for a beginner, will add to the confusion of getting started.

You can use the resources above or something else, but the key to success is finding a project of your own that will help you apply the lessons. And as you build your own application or work on your own project Google Search is indispensable, and I would highly recommend Stack Overflow as well.

Written by Ashu Joshi

April 2, 2012 at 11:44 am

Posted in IOS Development

Tagged with