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: