Thursday, December 31, 2015

iOS Hotspot Network SubSystem



The hotspot network subsystem allows a hotspot helper application to participate in the process of classifying and authenticating to Wi-Fi hotspots. A hotspot helper application can receive commands and provides a responses to a command once it has been processed. In most instances application command processing occurs while application is running in the background. 

The application receives command to process as part of two main functions: authentication and scan list filtering. 

References:


iOS Search API Best Practices



There are two categories of content. 

1. Private : Directly indexed using NSUserActivity and CoreSpotLight APIs. App can index content that user has created locally and this content remains in the user’s device and is searchable only locally. 

2. Public : Content that comes from the website. Apple uess a web crawler, called Applebot, to gather publicly available information that has been marked up using standard web markup techniques. This info is then presented to users when they use Search in iOS 9.0 or from Safari Suggestions. 

Which is the Right API to use? 

NSUserActivity : New methods and properties in the NSUserActivity class help one to index items from the app as the user does an activity in the app. This could include creating or visiting a piece of content, viewing a set of items such as visiting a navigation point. As the users do these activities in the app, the NSUSErActivity API can be used to indxed such actions. For e.g. Health app can add activities that let users search for “Steps” and be taken directly to that pane in the health app. 

Core Spotlight: The framework enables indexing of app content that is searchable privately on a persons device. One can add. delete , update and delete items in core spotlight index and that info will be searchable for easy access. Using a search extension, we can add content in the background even if app is not running. This allows the index to be up to date as the content changes even if the user activity isn’t actively using the app. This is for great things like messaging and conversations stored on the server but accessed through the app or locally generated content 

Web Markup: This is useful for apps that has mirrored content on the web. Applebot crawls the website and show its content on search results. By Implementing web markup we can make results look richer, increase engagement and seamless redirect users to specific content in the app. 

References:

A Few GIMP Tips



Bucket Fill Transparency

http://hamwaves.com/gimp.transparency/en/

Adding transparency to an Image

Below Steps can be followed for this:

- Open the Image with GIMP
- Windows -> Dockable Dialogs -> Layers
- Adjust the opacity here to slightly adjust the transparency (85% etc)

Another a large number of tutorials available here:



Chromcast How to Cast from a device



For Casting from a Youtube app, the steps are easy as below 

1. Download the latest youtube app on the phone (Android, iOS)
2. Connect the device to the same WiFi as the chrome cast 
3. Open the Youtube app on the device and press the Cast button 



references:

What is SIP MSRP (Message Session Relay Protocol)

MSRP is a text based connection oriented protocol for exchanging arbitrary MIME content, especially instant messages. 
MSRP sessions are typically arranged the same way a session of audio or video media is set up. One UA sends another UA invitation containing an offered session description that includes a session of MSRP. 


References: 


Crash reporting in iOS programmatically




The concept is useful to get some level of information after a crash, however, the stormy environment that exist soon after the crash occurs is not easy to capture all the details. Some of the framework such as Crittercism which uses the PLCrashreporter , https://www.plcrashreporter.org/ and other sites such as KSCrashReporter are very useful to get the details of crash that happens. 

https://github.com/kstenerud/KSCrash

References

iOS ABAddressbook concepts a few notes

Properties: There are two kind of properties single value and multi value. Multi value properties contains data that can have multiple values. 
Multi value properties can either be mutable or unmutable. 

Following is example to get the single value property 

ABRecordRef personRef = ABPersonCreate();
CFErrorRef anError = NULL;
bool didSet;

didSet = ABRecordSetValue(aRecord,kABPersonFirstNameProperty,CFSTR(“Katie”), &anErr);
CFStringRef firstName = ABRecordCopyValue(aRecord,kABPersonFirstNameProperty);
CFRelease(firstName); 

Multi Value Properties 

MultiValue properties consist of list of values. Each value has a text label and an identifier associated with it. There can be more than one value with the same label, but the identifier is always unique. There are constants defined for some commonly used text labels. For e.g. Phone number of a person can be many. 


REferences:


https://developer.apple.com/library/prerelease/ios/documentation/ContactData/Conceptual/AddressBookProgrammingGuideforiPhone/Chapters/BasicObjects.html#//apple_ref/doc/uid/TP40007744-CH3-SW1

List of available trust certificates in iOS

the iOS trust store contains trusted root certificates that are pre-installed with iOS

About trust and trust certificates 

Each iOs trust store listed below contains three categories of certificates. 

Trusted certificates establish a chain of trust that verifies other certificates signed by the trusted roots. for e.g. establish a secure connection to a web server. When IT administrator create configuration profiles for iOs, these trusted root certificates need not be included. 

Always ask certificates are untrusted but not blocked. When one of these certificates is used, one will be prompted to choose whether or not to trust it.

Blocked certificates are believed to be compromised and will never be trusted. 


References:
https://support.apple.com/en-in/HT204132

RTCP some detailes



the RTCP packet contains below items 

8 bytes of UDP header 
12 bytes min of RTCP header
Variable, with 32 bit boundary of of RTCP data 

RTCP is delivered over RTP UDP port number + 1
(usually one port number per multi media session) 

Usually, RTCP packets are bundled and may contains several packets which is encapsulated in the same UDP data gram (to reduce the overhead due to headers) 

The RTCP header has the following components

version - 2 bits
Padding bit - 1 bits 
RR count - 5 bits
Packet Type - 8 bits 
Message Length - 16 bits 

The following are the possible packet types possible in the RTCP data 

192 - FIR => Full INTRA frame request 
193 - NACK => Negetive Acknowledgement 
200 - SR => Sender report for transmission and reception statistics from active senders (periodically transmitted) 
201 - RR => Receiver report for reception statistics from participants that are not active senders (periodically transmitted) 
202 - SDES => Source Description items (including CNAME - canonical name) 
203 - BYE => Good bye indicates end of participation 
204 - APP => Application specific functions 
207 - XR => RTCP extension 

References:

A Few Notes on MQTT



MQTT decouples SUBSCRIBERS for PUBLISHERS 

- Anyone can PUBLISH and any one can SUBSCRIBE to the data. As long as the data is in the understandable format, the exchange will be smooth. 

MQTT allows wildcard subscriptions 

Some of the Published data can be as below 

scores/football/big12/Texas
scores/football/big12/TexasTech
scores/football/big12/Okalahoma
scores/football/big12/IowaState

Everyone of the above will PUBLISH to the MQTT broker. 

The interested parties and their SUBSCRIPTION can be below 

Texas Fan => scores/football/big12/Texas
Big12 Fan => scores/football/big12/+
ESPN => scores/#

+ represents single level wild card
# represents multi level wild card 

Some of the network properties of MQTT are: 

Small Packet Size: 
PUBLISH is 2-4 bytes
CONNECT is 14 bytes 
HTTP is 0.1 - 1 KB

the headers is binary payload and it is not text 
Small clients that has 30KB foot print and as well as huge memory foot print clients can be well supported at the same time 

Minimal protocol exchanges between ends. MQTT has a configurable keep alive 2 byte PINGREQ/PINGRES

MQTT supports QoS for reliable messaging:
There are 3 QoS levels 
1. QoS 0: at most once  (PUBLISH) 
- Doesn’t survive failure
- Doesn’t repeat 

2. QoS 1: At least once (PUBLISH, PUBLIC ACK) 
Survives connection loss
can be duplicated 
3. QoS 2 : exactly once (PUBLISH, PUBREC, PUBREL, PUBCOMP)
Service connection loss,
Never duplicated 



References:

Configuration Profiles - Purpose, Categories, Types, Structure and Payload overview



Purpose: 

configuration profiles and installation of them allows an organization to streamline the process of deploying and managing large number of computers. Below are the few types of settings, we can inlcude as part of the configuration profile. 

- Passcode and Security policies
- Network settings including WiFi, VPN, 802.1x 
- Account settings including LDAP, calendar, and instant messaging
- Credentials and Keys
- Login items 
- Dock preferences
- gatekeeper settings 
- PArental controls 
- Custom settings with key - value pairs for specific prefernce domains

Categories:

Below are the two categories of profiles that can be installed on OS X computer.

User Profiles: Contains settings for individual users or user groups such as passwords, parental controls 
Device Profils : which contains settings for individual devices or device groups, such as directory bindings, energy saver, and restrictions 
In OS X, a profile created for a device or device group is applied at the System level, while the profile created for a user or user group is at the user level. 

Types:
There are three types of profiles

1. Configuration Profiles 
2. Managed Profiles 
3. Trust Profiles 



References:

Android Google Cast App Development



Typical Sender app flow is 

1. Sender app starts MediaRouter device discovery.  MediaRouter.addCallback 
2. MediaRouter informs the sender app of the route that user has selected MediaRouter.Callback.onRouteSelected
3. Sender app retrieves CastDevice instance CastDevice.getFromBundle 
4. Sender app creates a GoogleApiClient GoogleApiClient.Connect
5. SDK confirms that GoogleApiClient is connected GoogleApiClient.ConnectionCallbacks.onConnected 
6. Sender App launches the receiver app Caster.castApi.launchApplication
7. SDK confirms that the receiver is connected ResultCallback 
8. Sender app creates a communication channel Cast.CastApi.sendMessageReceivedCallbacks 
9. Sender sends the message to the receiver over the communication channel. Cast.CastApi.sendMessage 

References:

What is Google Chromcast


Chromcast is a thumb sized media streaming device that plugs into the HDMI port on TV. Simply use an Android phone, tablet, iPhone  iPad , Mac , Windows laptop or chromebook to cast favorite entertainment and apps right to the big screen. 

Chrome cast works with a great number of apps. Such as Youtube, YuppTV, Google Play, Erose Now, Spuul etc. For everything else, we can mirror what we see on small screen to the big screen. With chromcast, the phone becomes the personalized remote control. 

When the casting is not perfomed, the TV screen becomes a beatiful backdrop filled with images one can customize. There seems to be also a guest mode. guests don’t need to connect to the home wifi, 

The chromcast device can be plugged into any HDTV, then connect with the WiFi , and cast from the device.  

References

Android TV and Chromcast

Chromcast is basically gateway to content. One cannot install anything to it and neither cannot control anything on it without another device. and cannot even set it up without a browser or an Android app. 

Google TV is full blown Android device, it has access to official Google play store and can install applications and games rent or buy movies to play directly n the TV through the device listen to the Google play. This also comes with a remote and lets to control the device using this remote. 

References:

Android TV - A quick look



Android TV delivers world of content on to the living room. 

From user experience perspective, apps such as YouTube, Netflix, and BBC iPlayer put personalized recommendations for videos, shows and sports on the homescreen 

A user can press on Mic on Android TV what is wanted. It could be “Jurassic Park”, “whats tomorrows weather forecast”

There is a cast feature which allows to cast movies and TV Shows music, games, sports and more - and this can be done from Android, iOS, Mac, Windows or Chromebook to the TV. 
Just tap on the cast button on the mobile app to start playing on TV. 

There are two options for user. Android TV built in or by connecting Android TV device to existing TV set. 

References:

Apple tvOS - A quick look

tvOS 



Its an innovative TV platform that redefines what can be done in the living room. Users can now deliver good apps and games on the big screen using the tvOS SDK. 

This allows to create experiences that connect to and immerse users even when the screen is across the room. We can take advantage of powerful GPU, CPU capabilities of the 1080p display and the new TV remote features a touch surface built in accelerometer and gyroscope. 

When developing with tvOS, we can take advantage of many of the same frameworks such as Metal, cloudKit, UIKit, and Game center to create rich games and apps that look amazing on Apple TV. 

New templates using XML and Javascript are also available as a framework for tvOS apps so that developer can use predefined layouts and Javascript APIs to quickly create beatiful apps ideal for streaming media. 

references:

Tuesday, December 29, 2015

Java PNS quirks

While trying to run the NotificationManager class, it seemed to give the exception like below

C:\server>java -cp . NotificationManager test
_server_push_cert2.p12 pass123 f5e10e727d3252b2b793740f2a940ac027f41761cee37b
99f2ec836ae7ed7d89 production
Error: A JNI error has occurred, please check your installation and try again
Exception in thread "main" java.lang.NoClassDefFoundError: org/json/JSONExceptio
n
        at java.lang.Class.getDeclaredMethods0(Native Method)
        at java.lang.Class.privateGetDeclaredMethods(Unknown Source)
        at java.lang.Class.privateGetMethodRecursive(Unknown Source)
        at java.lang.Class.getMethod0(Unknown Source)
        at java.lang.Class.getMethod(Unknown Source)
        at sun.launcher.LauncherHelper.validateMainClass(Unknown Source)
        at sun.launcher.LauncherHelper.checkAndLoadMain(Unknown Source)
Caused by: java.lang.ClassNotFoundException: org.json.JSONException
        at java.net.URLClassLoader.findClass(Unknown Source)
        at java.lang.ClassLoader.loadClass(Unknown Source)
        at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
        at java.lang.ClassLoader.loadClass(Unknown Source)
        ... 7 more


It actually went away once gave the classpaths properly like below. 

C:\server>java -cp .;JavaPNS_2.2.jar;log4j-1
.2.17.jar;bcprov-jdk15-146.jar NotificationManager cca_server_push_cert2.p12 pass123 f5e10e727d3252b2b793740f2a940ac027f41761cee37b99f2ec836ae7ed7d89 product
ion
---- Notification test starts ---
log4j:WARN No appenders could be found for logger (javapns.notification.Payload)
.
log4j:WARN Please initialize the log4j system properly.
log4j:WARN See http://logging.apache.org/log4j/1.2/faq.html#noconfig for more in

fo.

Thursday, December 24, 2015

Android bringing Activity to foreground

To bring activity to the foreground, Below simple code can be done. 

Intent notificationIntent = new Intent(this, MainActivity.class);
notificationIntent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP | Intent.FLAG_ACTIVITY_SINGLE_TOP);
PendingIntent pendingIntent = PendingIntent.getActivity(this, 0, notificationIntent, 0);
try
{
    pendingIntent.send();
}
catch (CanceledException e)
{
    e.printStackTrace();

}

References:
http://stackoverflow.com/questions/12074980/bring-application-to-front-after-user-clicks-on-home-button

Saturday, December 19, 2015

iOS 9.0 Search Using NSUserActivity

The concept is simple, below code helps app to be listed in the spot light search



References:
http://code.tutsplus.com/tutorials/ios-9-introducing-search-apis--cms-24375

Tuesday, December 8, 2015

Android Error because of library files are in application path + module path

Error:Execution failed for task ':app:dexDebug'.
> com.android.ide.common.internal.LoggedErrorException: Failed to run command:
  /Users/retheesh.r/Library/Android/sdk/build-tools/21.1.2/dx --dex --no-optimize --output /Users/retheesh.r/Desktop/RR/per/Projects/EyeOMe/app/build/intermediates/dex/debug --input-list=/Users/retheesh.r/Desktop/RR/per/Projects/EyeOMe/app/build/intermediates/tmp/dex/debug/inputList.txt
  Error Code:
  2
  Output:
  UNEXPECTED TOP-LEVEL EXCEPTION:
  com.android.dex.DexException: Multiple dex files define Lde/mindpipe/android/logging/log4j/LogCatAppender;
  at com.android.dx.merge.DexMerger.readSortableTypes(DexMerger.java:596)
  at com.android.dx.merge.DexMerger.getSortedTypes(DexMerger.java:554)
  at com.android.dx.merge.DexMerger.mergeClassDefs(DexMerger.java:535)
  at com.android.dx.merge.DexMerger.mergeDexes(DexMerger.java:171)
  at com.android.dx.merge.DexMerger.merge(DexMerger.java:189)
  at com.android.dx.command.dexer.Main.mergeLibraryDexBuffers(Main.java:454)
  at com.android.dx.command.dexer.Main.runMonoDex(Main.java:303)
  at com.android.dx.command.dexer.Main.run(Main.java:246)
  at com.android.dx.command.dexer.Main.main(Main.java:215)
  at com.android.dx.command.Main.main(Main.java:106)


This issue was because the Log4J jar file was included in the app jar directory and as well inside the module lib folder. 


Monday, November 30, 2015

Github learning - Hands on

the git config seems to be for the git directory that is initialized 

$git config user.name “Test Name“
error: could not lock config file .git/config: No such file or directory

unless the git init is called, the config cannot be done 

$git init
$git config user.name “Test Name“
$ git config user.email “test.name@gmail.com"


However, if we use the —- global switch, the configuration applies globally 

git config --get --global user.name 

This above command gives the user name that is configured globally. 


References:

Android Creating Library project


Android seems to have brought back the android libray project creation in Android latest studio. Below given the steps for it 

Go to File -> New -> New Module 
Select Java Library at the end of Options List 
Enter the name of the jar lib and name of the class and hit finish action 

Now as usual we can add this as dependancy by right clicking the app module and on the dependancy tab, press + and select the newly created 
jar file as dependancy. 

After building, if notice in the build / libs folder, the jar file can be found with the name classes.jar. This can be distributed across. 
To note, if right click and try to add resource folder to this directory, we cannot find the option to add resource directory unlike it can be 
found when right clicking on the library module project which outputs aar file.  

References:


Saturday, November 28, 2015

Android Fixing Manifest Error - manifest merger failure


When included a new Android Library module, got the conflict below. This happens when the Manifest merge fails between the module and the Application.

Error:(10, 9) Attribute application@label value=(IoT League) from AndroidManifest.xml:10:9
Error:(10, 9) Execution failed for task ':app:processDebugManifest'.
> Manifest merger failed : Attribute application@label value=(MyTestApp) from AndroidManifest.xml:10:9
  is also present at MyTestApp2:mytestlib:unspecified:13:9 value=(@string/app_name)
  Suggestion: add 'tools:replace="android:label"' to element at AndroidManifest.xml:7:5 to override

To solve it, below can be added in the application manifest 

"http://schemas.android.com/apk/res/android"
package=“com.testapp” xmlns:tools="http://schemas.android.com/tools"

android:allowBackup="true"
android:icon="@drawable/ic_launcher"
android:label=“MyTestApp2”
android:theme="@style/AppTheme"
tools:replace="android:label" 


References:

Friday, November 27, 2015

Android Project Management options

In Android studio, a module is first level of containment within a project that encapsulates specific types of source code files and resources. 
There are several module types in a project.

Android Application Modules : This is container for applications source code, resource files, and application level settings such as module level build file, resource files and android manifest file. The application module contents are eventually built into .apk files that get installed into device

Test Modules : Contains code to test the application and are built into test applications that run on a device. Bu default the test module can get the JUnit test cases inserted

Library Modules: Contains shareable android source code and resources that can referred in Android projects. Library modules cannot be installed onto a device, however, they are pulled into the .apk file at build time. 

App Engine modules: Android studio lets to easily add cloud backend to the application. A backend allows to implement functionality such as backing up user data to the cloud, serveing content to client apps, real time interactions, sending push notification through GCM. App Engine modules are App Engine Java servlet module for backend development, App Engine Java Endpoint module convert server side Java annotations into RESTful backend APIs, and App Engine Backend with GCM to send push messages to the server to Android devices. 


Referecens

Thursday, November 26, 2015

MAC some network debugging tips

To list all the active internet connection, lsof -i
this was giving output something like below

COMMAND     PID       USER   FD   TYPE             DEVICE SIZE/OFF NODE NAME
UserEvent   361 retheesh.r    4u  IPv4 0xff43389e676bc9b7      0t0  UDP *:*
SystemUIS   430 retheesh.r   19u  IPv4 0xff43389e60c1d5d7      0t0  UDP *:53182
SystemUIS   430 retheesh.r   21u  IPv4 0xff43389e6425e317      0t0  UDP *:*
sharingd    451 retheesh.r   25u  IPv4 0xff43389e60c1f8ff      0t0  UDP *:*
sharingd    451 retheesh.r   29u  IPv4 0xff43389e64203507      0t0  UDP *:*
com.apple   608 retheesh.r    6u  IPv4 0xff43389e676bc2af      0t0  UDP *:*
Skype       929 retheesh.r   21u  IPv4 0xff43389e60c1dcdf      0t0  UDP localhost:64712

When tried to open a page from Chrome, it listed as Google in the list above.


References:

Java How to Instantiate a class with Parameter arguments

Below is the way to do it. By default, the Class object has a newInstance method. however, this does not accept the parameter. 
We have a way to get the constructors of a class by using the getDeclaredConstructor method. This method accepts variable list of arguments
so that we can pass in the type of arguments of the constructor we would like to invoke. Sample is given below 

myConnection = myConnectionClass.getDeclaredConstructor(String.class,Hashtable.class).newInstance("CONN_ID",connProps);


References


What are the reasons for 488 SIP response

The Incoming NOTIFY to the client was generating a 488 Not accepted here response back to the server. Based on the description on the links given below, it appears that if the SIP header or body parameters are not in the formatted expected by the client, then it can send back the 488 message. 

In my case, the XML was not correctly formatted and hence it was giving this error. 

references:

Android Loading Spinner

There are two types of progress bar, loading bar and loading spinner. Below is what we can do to add a loading spinner. 

"1.0" encoding="utf-8"?


android:id="@+id/relativeLayout1"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
xmlns:android="http://schemas.android.com/apk/res/android"
android:padding="5dp"

android:id="@+id/relativeLayout2"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
xmlns:android="http://schemas.android.com/apk/res/android"
android:padding="5dp"

android:id="@+id/item_img"
android:layout_height="wrap_content"
android:layout_width="wrap_content"
android:layout_centerInParent="true"
/
style="?android:attr/progressBarStyleSmall"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/progressBar"
android:layout_centerInParent="true" /

android:id="@+id/item_title"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:singleLine="true"
android:ellipsize="end"
android:padding="1dp"
android:layout_below="@id/relativeLayout2"
android:layout_centerHorizontal="true"
/

References:


Android updating UI from network thread

When updating the UI after a network operation, it needs to be on a main UI thread. This can be done in android by using the runOnUIThread method

runOnUiThread(new Runnable() {
        @Override
        public void run() {
            View baseView = accessory.getViewReference();
            ProgressBar pg = (ProgressBar)baseView.findViewById(R.id.progressBar);
            if(pg != null) {
                progressBar.setVisibility(View.GONE);
            }
        }
    });

references:

Saturday, November 14, 2015

Apple HomeKit a revisit


With home kit, apple created a common language that smart devices from any manufacturer can understand and support. HomeKit also leverages Siri to have voice controls in it. 
Devices from various manufactures can understand and interact each other with HomeKit. 

Manufacturers must add support for HomeKit to their smart devices for those devices to be considered HomeKit enabled. Apple announced partnership with many manufacturers such as iHome, Philips, iDevices, Belkin, HoneyWell and Kwikset. 

In home kit, everything such as home, room, device, function, setting etc must have its own name and be stored in a common database accessible by Siri. For e.g. if one own a House and a condo, we will have to assign each home a different name. Every single room in all of the homes must have different name as well. 

Every function or service that the device is capable of providing will need a distinct name in home kit. So, if we want a cup of coffee, we can name the machine “Coffee Pot” and function as “Brew”. 

Grouping allows to for instance turn off all the lights in a house with a single spoken command. Grouping also includes sub-features such as Action Sets or scenes. An example scene could be “Its bedtime” and various devices and actions are connected to that scene (such as locking doors, turning off lights, setting up the alarm clock etc) 

HomeKit includes end to end encryption between iOS devices and smart devices. HomeKit API also demands that the App that uses the API must run in the foreground. 

Apple Allows HomeKit to work with non HomeKit devices that use competing protocols such as Zigbee or Z-Wave. A bridged accessory would connect a non-HomeKit devices to iOS device and therefore allowing to control using Siri commands. 


References:

SmartThings is an App + Hub + Devices (things)

All things are connected to Hub, be it 2 or 200. The hub has various protocols implementations such as Zigbee or Z-wave or others. 



The App is having below few features 

- The landing page shows overall status of the home. whether everything is okay. and if something gone wrong, ARM, or Disarm the home etc
- Then the next tab shows Home in which there are rooms and individual things.
- Rooms can be Kitchen or any other things
- Things are the IoT things 
- SmartApps are basically rule based items 
- Family is the presence of other members in the family  
- The third tab has Routines which is basically a specific event and associated actions on things. For e.g. One such event is Good morning. This has internally turn off AC, turn off certain bulbs etc. 
- Next Tab is for notifications. This tab has two sections, on is for messages. This is like a chat window, where it displays instructions given by the user and the feedback given by the things. The Activity Feed represents the activities performed 
- The last tab is the market place where we can buy the hardware and also the SmartApps which is nothing but rules. 


references:

Tuesday, November 10, 2015

The TCP 3way handshake

Three important flags are below ones. 

1. SYN
2. SYNC ACK
3. FIN 

Whoever initiates the connection, sends the SYN flag as 1. rest all flags will be zero. When the receiver acknowledges, the ACK flag will be set as 1 in the response. Now if the receiver also like to communicate back, it will send the SYN flag as 1 in the same response. Now from the client it will send the ACK to indicate that the handshake is now complete. These 3 packets complete the 3 way handshake. 

The parties on both ends of the TCP connection maintains a 32 bit counter to keep track of how much data it sent across. The sequence number is included in each transmitted packet and acknowledges by the opposite host as acknowledgement number to inform the sending host that the transmitted data was received successfully. 


References:

Monday, November 9, 2015

Linphone Bandwidth calculation for a call



Lets consider an incoming call. this is done by calling linphone_core_accept_call_with_params. This method accepts the LinphoneCall which is to be accepted and 
the LinphoneCallParams for accepting the call. Internally this calls sal_call_accept. Now this methods creates a response 200 with the help of method 
sal_op_create_response_from_request. In this method, it adds the headers such as Contact, Allow, Expires, any custom headers etc. It then calls handle_offer_answer_response 
which internally creates the sdp_answer from the remote media description. Here it extracts the h->bandwidth from the remote media description. 
the SDP is now set to the answer response. This response is sent back to the remote using the belle_sip_server_transaction_send_response 

Now it needs to create the New Media description using the method sal_call_get_final_media_description 

Now it calls linphone_core_update_streams. Internally it calls linphone_call_start_media_streams as the streams has to be started from the receiver end. 
It then internally calls linphone_call_start_audio_stream which calls make_profile and the resultant profile is set to the AudioCall. 

When making the profile is where the bandwidth related checks are done. It calls the method get_ideal_audio_bw which has the logic like below 

If the client Application specifies any upload bandwidth, 

it finds then the minimum of the bandwidth by considering the remote bandwidth and the upload bandwidth specified in the file. 
It then calls the method linphone_core_update_allocated_audio_bandwidth_in_call which is called with PayloadType and the maxbw 
if the payload type is vbr, then the updated bandwidth is considered. 



references:

Saturday, October 31, 2015

Linphone - How it manages IPv6 connection in iOS


Android Bluetooth - Hands on


Android Bluetooth APIs - Learning Part II

Below is the snippet to retrieve list of bonded devices. 

Set pairedDevices = btAdapter.getBondedDevices();

getName() returns the public identifier of the devices
getAddress() returns the MAC address of the device 

In order to find the nearby devices, which is called scanning we need to use the below code

btAdapter.startDiscovery() is the method to start scanning operation. btAdapter.cancelDiscovery() will cancel the initiated scanning 

These two methods are working via Asynchronous feedbacks by Broadcast Receivers. 

private final BroadcastReceiver receiver = new BroadcastReceiver()
{
public void onReceive(Context context, Intent intent)
{
String action = intent.getAction();
if(BluetoothDevice.ACTION_FOUND.equals(action))
{
BluetoothDevice device = intent.getParcellableExtra(BluetoothDevice.EXTRA_DEVICE);
}
}
}

Connecting to a Device:

Similar to any other connection, there is a Server and Client which communicates via RFCOMM sockets. 
On Android, RFCOMM sockets are represented as BluetoothSocket object. 

Below is the code to connect to a Bluetooth Device 

public class ConnectThreads extends Thread
{
private BluetoothSocket bTSocket;
public boolean connect(BluetoothDevice btDevice, UUID uuid)
{
BluetoothSocket socket = null;
try
{
socket = btDevice.createRFCommSocketToServiceRecord()
}
catch(Exception ex)
{
ex.printStackTrace();
}
try
{
socket.connect();
}
catch(Exception ex)
{
ex.printStackTrace();
try
{
}
catch(Excpetion ex)
{
}
}

}
}


References:

Linphone Management of Bandwidth parameter

References:
https://www.linphone.org/docs/liblinphone/group__media__parameters.html#ga1e0c01a25f78d14c6813213adf795e54

SIP SDP bandwidth information

The SDP includes an optional bandwidth attribute with the following syntax 

b=:

where is single alpha numeric word giving the meaning of the bandwidth figure, and where the default units of 
bandwidth value is kilobits per second. This attribute specifies the proposed bandwidth to be used by the session or media. 

The typical use is with the modifier “AS” (Application specific Maximum) which may be used to specify the total bandwidth for a 
single media stream from one site (source)

another modifier value is CT. If the bandwidth of a session or a media in a session is different from the bandwidth implicit from the scope, 
a b=“CT” line should be supplied for the session giving the proposed upper limit to the bandwidth used (the “conference total” bandwidth) 
The primary purpose of this is to give an approximate idea as to whether two or more sessions can co-exist simultaneously. when using CT 
modifier with RTP, if several RTP sessions are part of the conference, the conference total refers to the total bandwidth of all the RTP sessions. 


References:

Free Icon download Websites

Quirks of Unzipping on MAC

Some of the files were not able to be unzipped using either “unzip” command or “ditto” command via terminal
however, since they were getting opened perfectly using the “Archive Utility”, one option was to use the 
terminal to open such files. e.g. below 

open -a "Archive Utility" 0B9822F3-FE6C-4FB6-AB47-C98DA932279D_205155390.zip

The only inconvenience is that we cannot specify the destination folder. 

This can be automated using a simple shell script like this 

for file in *; do
echo $file
open -a "Archive Utility" $file
done


References:

What is needed for Support IPv6

An operating system that support IPv6: Windows Vista and modern versions and Mac OS and Linux latest versions support IPv6. Windows XP doesnt, and we should not be using XP anymore. 

A router with IPV6 support: Most of the modern routers comes with IPv6 support 

An ISP that supports IPV6. 


The below page helps to test the IPv6 http://ds.testmyipv6.com/ 

The IPv6 only test:

If we attempt to connect to this server and times out, then it means that we don’t have IPv6 path to the server. The below could be possible reason for this

1. The client is not having globally routable address on the internet and therefor not actually making the connection to this server 
2. The client is IPv6 capable, but does not know that it is limited to the local network. But there is no IPv6 connectivity beyond the router 

If the browser returns an error saying that the host cannot be found, then the DNS servers that we are using don’t know how to look up the address of the server based on the hostname. They are unable to resolve the AAAA record. If one is using the DNS server addresses provided by the ISP, then we need to ring them up and ask to fix ASAP. 

If we are using local gateway or router for DNS, then router is not capable or forwarders used by the router (likely the ISP’s servers) is not capable. 

IF browser is able to connect to IPV6 only page, but still shows red box when taking the Dual Stack test, the browser seems to be preferring IPV4 over IPV6, which is undesirable. 



References

Serializing the objects Java

Serialization is quite simple, if we have requirement to Serialize and ArrayList that contains a number of Objects, below are the steps to do

1. Create the object that goes into the array list as Serializable objects
2. Optionally, add a field into the object which can tell the version of the class structure.

Now just add to the array list and serialize the array list, be

public class Accessory implements Serializable

{
    private int type;
    private int state;
    private String name;
    private String uuid;

    public Accessory(int type, int state, String name, String uuid)
    {
        this.type = type;
        this.state = state;
        this.name = name;
        this.uuid = uuid;
    }
}

 public void saveAccessories(ArrayList accessoryList)
    {
        try
        {
            FileOutputStream fos= new FileOutputStream("myfile");
            ObjectOutputStream oos= new ObjectOutputStream(fos);
            oos.writeObject(accessoryList);
            oos.close();
            fos.close();
        }
        catch(IOException ioe)
        {
            ioe.printStackTrace();
        }
    }
    
    public ArrayList loadAccessories()
    {
        try
        {
            FileInputStream fis = new FileInputStream("myfile");
            ObjectInputStream ois = new ObjectInputStream(fis);
            Object obj = ois.readObject();
            ois.close();
            return (ArrayList)obj;
        }
        catch (Exception ex)
        {
            ex.printStackTrace();
        }
        return null;
    }

References:
http://www.journaldev.com/2452/java-serialization-example-tutorial-serializable-serialversionuid

Friday, October 30, 2015

iOS Push Notification - Debugging

Since the app is not receiving the valid push notification token from OS, there are a few reasons why the APNS token does not get delivered to the app. One of them is network is blocking the 5223 for inbound and outbound TCP/TLS traffic. 

If still not receiving the notification, we can figure out few things by installing a debug profile at the link below, which will let us give the device level Apple Notification server connection logs


Once installed, please restart the device while connected to Xcode, Once the device powers up and app is launched, we can see the logs in the Xcode console.

In the log, there will be logs from the process “apsd” which will help us analyze what is happening. 


If would prefer to delete the is profile at later point, can do this by navigating to Settings > General > Profiles  Delete APS logging profile. 

References: