Friday, March 31, 2017

How to use out parameter in C

1. http://student.kfupm.edu.sa/s200372670/Function%20Output%20Parameters%20Implemented%20with%20Pointers(OR%20Function%20with%20Output%20Parameter).htm

Example (i) :
Consider the example of a function that accepts the radius of a circle from the main program and returns the area and circumference of a circle by using the output parameters:

#include <stdio.h>
void area_circum (float radius, float *area, float * circum) ; /* function prototype */
void main (void)
{
float r, a, c ;

printf (“Enter the radius of the circle \n”) ;
scanf (“%f”, &r) ;

area_circum (r, &a, &c) ; /* function call that passes the address of the variables a and c */

printf (“The area is %f and circumference is %f\n”, a, c) ; /* output results */
} //end of main


void area_circum (float radius, float *area, float * circum) // function
{
*area = 3.14 * radius * radius ; /* indirect reference to variable a of main program */
*circum = 2 * 3.14 * radius ; /* indirect reference to variable c of main program */
} // end of function area_circum()

Here the variables area of function area_circum and a of main both refer to the same memory location. Similarly, the variables circum of function area_circum and c of main both refer to the same memory location.

Note that when the function is called in the main program, the output parameters have & attached to them before their name. When the output parameters are used in the function, they are used with * attached to them before their name.

Bluetooth Security

                                    Bluetooth Security


* Authentication
** Authorization
*** Symmetric key security
: generally A trus B if B can prove that it has the same shared key that A does

Multiple Security Modes:

Mode 1: No security other than against " casual evesdroppers"
---> all the BT devices employ "data-hopping", which entails skipping around the radio band up to 1600 times per second( 79 differnet frequencies)

Mode 2: Services Level Security" established after creating the channel, above datalink layer.
---> It depend on device: 
     i) Trusted deivce have unrestricted access to all services, fixed releationship to other devices
     ii) Untrusted devices generally have no permanent relationship and services that it has access to are limited.
It have one of the 3 security levels:
Level 3: Requires Authentication and Authorization. PIN number musht be entered.
Level 2: Authentication only, fixed PIN ok.
Level 1: Open to all devices, the default level. security for legacy applications.

Mode 3: Datalink level Security: Security initiated befor establishing channel, by the Link Manager, as well as by the service level.
--> Security is implemented by symmertic key in a challege-response system.
security implementations in bluetooth units are all the same.
Critical ingredents: PIN,BD_ADDR, RAND(), Link and Encryption Keys

Device Security Levels:

Trust level of the device determines which services that devices hasa access to.

a) Trusted Device: The device has been previously authenticated, a link key is stored and the device is marked as "truested" in the Device database.

b) Untrusted Device: The device has been previously authenticated, a link key is stored but the device is not marked as "trust" in the Device database.

c) Unknown Device: No security information is available for this device, e.g Untrusted.

--------------------------------Security Entities-----------------------

1. PIN: up to 128 bit number, can be fixed(entered in only one device), or can be entered in both devices.
If fixed, much lower security.

2. BD_ADDR: BT devices address, unique 48 bit sequence, Devices must know the address of devices it want to communicate with.
Addresses are publicly avalilable via BT inquires.

3. Private Authentication Keys, or LInk keys: 128 bit random numbers used for authentication purposes. Paired devices share a link key.

4. Private Encryption key: varying length key(8-128 bit), regenerated for each transmission from link key.

5. RAND: frequently changing 128 bit random number generated by the devices. common input fro key generation.
** All BT devices have this random number generator.

---------------------------------------------------Initialization ----------------------------

Needed before two secure devices can communicate five parts:

a) Generation of initialization key pairing--> Initialization key generation only occurs when two devices have not yet communicated before.
Highest security demands PIN be entered by both users.( MOde 3) this key used to secure the process of generating a shared link key between the devices.

Device A and B now share the initalization key, which they use as theri temporary link key while deciding on what kind of link key they willuse for data transmission.
b) Authentication : Does not always need to be mutual, specified by app, If it is mutual then both act as verifiers one after the other,
 Deices A: verifier
 Devices B: Claiment
Basically determines if both have same shared key.

B send its response to A, who checks to see that they match. IF failure, start exponential waiting with a limit set on number of possible attempts.

On success, the BD_ADDR of other devices is sotred in the devices database by the service manager.
c) Generation of link key--> Link key does not change it was made when device was installed.
   Application decieds wheich device will provide its unit key as link key.
   Shared initialization key is used to protect the transaction: it is XORed iwth the new link key.
d) Link key exchange--> After the link key is stored on the other device, the initialization key is discarded.
   Higher securtiy: combinition key is used rather than the link key and this is formed by ( link key, RAND , BD_ADDR) on both A and B.
   Master-slave communications use Master link key. A slave gets a master link key when first connected to master and then changes it when prompted by master.
e) Generation of encryption key in both devices.
   -->Encryption requires an authenticated link with an established link key.
   -->devices musht agree on an encryption key to communicate.
   --> Packete payloads are encrypted ( not the packet headers or access codes)
  ---> Devices negotiatae on what size encryption key they need, typically around 64 bits. Range is 1-16 bytes

Wednesday, March 29, 2017

Interview Question on C and CPP

-------------------HCL------------------   
1. Storage class  (register 16bit, 32bit, 64bit)-- depend on register we can allocated, if register is not availabe then it act as auto.

2. Memory layout

3. program of pre increment and postincrement

4. program--> Pllindorme ( number and stirng)

5. Types of environment variable in linux.

6. Relative path and Absolute path.

7. Copy constructor
class A {
A(A & B){} /how
A(A nn){} // what is difference
};
8. STL is static polymorphism ( correct)
9. For string if we pass it will as it is or we have to do some thing.






----------------------------------------------------

1.  how to prevent the class from inheretance.
Ans:=-- By creating the singltion class, by making the constructor and distructor as private.

2. virtual distructor/constructer.
Ans-- virtual distructor is possible, but virtual constructor is not possible ( compile time error)

3. function pointer
Ans-- int (*pt2Function)(float, char, char) = NULL;                        // C
int (TMyClass::*pt2Member)(float, char, char) = NULL;                // C++
int (TMyClass::*pt2ConstMember)(float, char, char) const = NULL;     // C++

4. int constant pointer and constant integer constant pointer .
Ans-->
int constant pointer--- >>> int *const p;
constant int constant pointer--> const int *const p;

4.difference between the class and strucure ( is structure follow the oops concept).
Ans--
1.by default data member of class is private, and for strructure is public.
2. When we inherit the class to another class it is by default is private, but for structure-- when we inherit class in structure then by default it is pubilc.

5. stack coding - got it

6.class a; cout << sizeof (a).
Ans--- 1 because it will give minimum nonzero to it. so minimum nonzero is 1.

7. static virtual function.
Ans-- we can't declare both static and virtual function at a time.

8. Multiple inheritance y in c++ not in others.

9. how to initilize arrary of object 10. With same value.
Ans-- if we are making object of class then we initilize by using constructor.
but for int a[10] ---- for that still searching.
ANs----- std::vector a(10, Fred(5,7)); the 10 Fred objects in std::vector a will be initialized with Fred(5,7)


10. type of inherientance in C++.
Ans--> single, multiple, multi level, hybrid, hierarchical

11. class a;
{
}
main ()
{
a aa =new a();
free (a);
}QQQ-- what it will give error in compile time or run time, for that we have to include the stdlib.h
-- then it will work fine.
Ans----- free is not declared in this scope.

12. copy constructur working and usages.
Ans-- it is present by default.
construcotr (&copy)---- class a1 = a2;

13. why we use virtual distructor.

Ans-- when we are making object of base class of child class type, and if we delete base object, then it will not delete the child class distructor, so we are making the virtual distructor, then it will call the child distructor.

14. what is STL. ( Standard Templet library

Sequences

C++ Vectors

C++ Lists

C++ Double-Ended Queues

Container Adapters

C++ Stacks

C++ Queues

C++ Priority Queues

Associative Containers

C++ Bitsets

C++ Maps

C++ Multimaps

C++ Sets

C++ Multisets
)

15. what default will created when we create only class??
Ans--> copy constructor,default constructor, distructor, assignment operator, address operator

16. how to delete array object at one shot.  like questin 9. ( int* a= new int [10];  for deletion we will use (delete []a;) )

17. deep copy and shallow copy and when we use deep and when we use shallow.
Ans: deep copy : it create a local copy or and do operation, it will not refelect to the original one, performance is slow.
shallow copy: it refer to the data, its performance is better than the deep copy, if the data size is large, instead of copy the large data, we can pass the reference of data.

18. which operator we can not overload.
Ans:-- the operator which we can't overload
.(member access  or dot operatior), ?: ( ternary or conditional operator), :: ( scope resoloution operator), .*(pointer to member operatior), sizeof,typeid

19. Dagling pointer: is a pointer pointing to something that has been deallocated using delete.

20. Learn Design Pattern.
1. Singlton .

21. Late binding ( It is used by using the keyword virtual)- Run time it will decide which function will call .
--------------------------- asked in shell script---

Questions Asked in the interviews::

1. Automation of the jobs--- (crontab)
2. how to debug the shell script (set -x)
3. If we remove the Header of the script then also script will run ( script will also run)
4. How to check the how many socket descriptor are opened (netstat) (lsof)
=================================================================================================================================
1. What is Embedded System.
Ans-- it is computer system which will do dedicated function within a larger machenical and electrical system
2. Types of scheduling.
Ans-- ( Long Term Scheduler, Short Term scheduler, Medium Term Schedler)
3. What is ARM
Ans-- ARM is  family of instruction set archeticture  for computer process based on RISC(reduce instruction set computing)
4. What is Toolchain.
Ans--
The GNU toolchain is a blanket term for a collection of programming tools produced by the GNU Project. These tools form a toolchain (suite of tools used in a serial manner) used for developing applications and operating systems.

5. declaration of array dynamic ( c and c++) and delete it.
Ans--
IN C lang
int i[size];

int *ii = (int *) malloc (size *sizeof(int) );

IN C++ lang
int i[size];
int *ii =new int[size];


6. What is sizeof.

7. how to compile toolchain.

8. IPC mechanism and types of IPC.
Ans-- Socket programming, shared memory


9. Class follow Abstraction of OOPS concept.

10. How the process are Synchronizating.
Ans-- By using the semaphore variable and Mutex varible.

11. Use of constructor??
Ans---
When you instantiate an object it's constructor will be invoked whereas calling a method is always optional. You therefore might forget to call your initialization method and fail to initialize everything correctly.

12. What is split tool, what it will give. ( it is static analysis tool)

13. Can we increment or decrement a void pointer?
Ans-- No


14. Friend functions have the following properties:

    1) Friend of the class can be member of some other class.
    2) Friend of one class can be friend of another class or all the classes in one program, such a friend is known as GLOBAL FRIEND.
    3) Friend can access the private or protected members of the class in which they are declared to be friend, but they can use the members for a specific object.
    4) Friends are non-members hence do not get “this” pointer.
    5) Friends, can be friend of more than one class, hence they can be used for message passing between the classes.
    6) Friend can be declared anywhere (in public, protected or private section) in the class.

15. Friend class is also possible.

16. RTTI( Run time type information)
untime Type Information (RTTI) is the concept of determining the type of any variable during execution (runtime.) The RTTI mechanism contains:

    The operator dynamic_cast
    The operator typeid
    The struct type_info

17. Types of Ploymorphism:
    a) Run Time ( dynamic  binding)   
    b) compile tiem ( static binding)


18. Data encapsulation led to the important OOP concept of data hiding.
19.  data abstraction is a mechanism of exposing only the interfaces and hiding the implementation details from the user


20. char *s = "Hello world";

will place Hello world in the read-only parts of the memory and making s a pointer to that, making any writing operation on this memory illegal. While doing:

char s[] = "Hello world";

puts the literal string in read-only memory and copies the string to newly allocated memory on the stack. Making

s[0] = 'J'; ( legal)


21.
When the processor wakes up after power on, it goes to a particular memory location. What is that memory location called? ??
Ans-processor goes to MBR (master boot record) then it takes the address of boot loader form thr and execute this boot loader program

22.
 Differentiate between a template class and class template.

Template class: A generic definition or a parameterized class not instantiated until the client provides the needed information. It’s jargon for plain templates. Class template: A class template specifies how individual classes can be constructed much like the way a class specifies how individual objects can be constructed. It’s jargon for plain classes.

23.
 What are proxy objects?

Objects that stand for other objects are called proxy objects or surrogates.
template <class t="">
class Array2D
{
public:
class Array1D
{
public:
T& operator[] (int index);
const T& operator[] (int index)const;
};

Array1D operator[] (int index);
const Array1D operator[] (int index) const;
};

The following then becomes legal:

Array2D<float>data(10,20);
cout<<data[3][6]; // fine

Here data[3] yields an Array1D object and the operator [] invocation on that object yields the float in position(3,6) of the original two dimensional array. Clients of the Array2D class need not be aware of the presence of the Array1D class. Objects of this latter class stand for one-dimensional array objects that, conceptually, do not exist for clients of Array2D. Such clients program as if they were using real, live, two-dimensional arrays. Each Array1D object stands for a one-dimensional array that is absent from a conceptual model used by the clients of Array2D. In the above example, Array1D is a proxy class. Its instances stand for one-dimensional arrays that, conceptually, do not exist.

24.
 Differences of C and C++
Could you write a small program that will compile in “C” but not in “C++”?

In C, if you can a const variable e.g.
const int i = 2;
you can use this variable in other module as follows
extern const int i;
C compiler will not complain.

But for C++ compiler u must write
extern const int i = 2;
else error would be generated.

25.
 What is the difference between Mutex and Binary semaphore?

semaphore is used to synchronize processes. where as mutex is used to provide synchronization between threads running in the same process

26.
 What problem does the namespace feature solve?

Multiple providers of libraries might use common global identifiers causing a name collision when an application tries to link with two or more such libraries. The namespace feature surrounds a library’s external declarations with a unique namespace that eliminates the potential for those collisions.
This solution assumes that two library vendors don’t use the same namespace identifier, of course.
27.
 Describe run-time type identification.

The ability to determine at run time the type of an object by using the typeid operator or the dynamic_cast operator.

28.
Amonog all the available IPCs, Shared Memory is the best and fastest one. We need to use Shared memory when more
than one proceses wish to communicate each other on a common read-only memory. It is fast because it does not
involve physical moment of data as the data is shared among them.

Mutex/Semaphore is the best when a resource(including memory) is non-shared

29.
What is the difference between dead-lock and live-lock

DEADLOCK Deadlock is a condition in which a task waits indefinitely for conditions that can never be satisfied - task claims exclusive control over shared resources - task holds resources while waiting for other resources to be released - tasks cannot be forced to relinguish resources - a circular waiting condition exists

LIVELOCK Livelock conditions can arise when two or more tasks depend on and use the some resource causing a circular dependency condition where those tasks continue running forever, thus blocking all lower priority level tasks from running (these lower priority tasks experience a condition called starvation).
    A livelock is similar to a deadlock, except that the states of the processes involved in the livelock constantly change with regard to one another, none progressing. Livelock is a special case of resource starvation; the general definition only states that a specific process is not progressing.
    A real-world example of livelock occurs when two people meet in a narrow corridor, and each tries to be polite by moving aside to let the other pass, but they end up swaying from side to side without making any progress because they both repeatedly move the same way at the same time.
    Livelock is a risk with some algorithms that detect and recover from deadlock. If more than one process takes action, the deadlock detection algorithm can be repeatedly triggered. This can be avoided by ensuring that only one process (chosen randomly or by priority) takes action.


30.
Synchronous Sockets--( Blocking )--
A read on a socket can't complete until some data has been send by the remote host. If there is no data waiting to be read, one of two things can happen:
Function can wait until somedata is written on the socket. or
ASynchronous Sockets-- ( Non Blocking) - It can return immediately with an error that indicate that there is no data to be read.

31. Livelock-- A livelock is similar to a deadlock, except that the states of the processess invlolved in the livelock constantly change with regards to one another, none progressing .
Necessary condition of Deadlock-

Mutual exclusion- At least one resource must be held in a non-sharable mode,ONly one precess can use the resource at any given instant of time.
Hold and wait- A precess is currently holding at least one resource and requesting additional resource whic are being held by other process
No preemption-The Operating system must not de-allocate resource once they have been allocated; they must be released by the holding precess voluntarily.
Circular wait- A process must be waiting for a resourse with is being held by another process, which is turn is waithing for the first prcess to release the resources

32. Difference between structure and union:
Ans--
Structure
A structure allocates memory for each field in the structure.
We can access all the members of structure at anytime
All members of structure can be initialized.
'struct' keyword is used to declare structure..

Union:
A union only allocates enough memory to hold the largest field in the union.
Only one member of union can be accessed at anytime.
Only the first member of a union can be initialized.
'union' keyword is used to declare union.

--------Dead lock handling

1. Dead lock detection
( process termitation, resource preemption)


There are three general cases where the copy constructor is called instead of the assignment operator:
1.When instantiating one object and initializing it with values from another object
2.When passing an object by value
3. When an object is returned from a function by value.


33. So, using templates, we can write programs that do computation at compile time, such programs are called template metaprograms.
Example
#include <iostream>
using namespace std;

template<int n> struct funStruct
{
    enum { val = 2*funStruct<n-1>::val };
};

template<> struct funStruct<0>
{
    enum { val = 1 };
};

int main()
{
    cout << funStruct<8>::val << endl;
    return 0;
}
Output:
256

34. What is vitural base class.
Ans-- When we use virtual base class, then we get only one single instance of common base class.

35. Parameter passing in overloading. (like arry, pointer, etc).

36. 'Is-a relationship'-- It use public inheritance. (Ex-- every operation applied on employee will be applied on Manager)

37. 'Has-a relationship' -- It use private inheritance. ( Ex. Car has Wheel) -- class car : private wheel

38.Solving the Diamond Problem with Virtual Inheritance.

Example:

class transmitter: public virtual storable
{
        public:
        void read();
        ...
}

class receiver: public virtual storable
{
        public:
        void read();
        ...
}

When we use virtual inheritance, we are guaranteed to get only a single instance of the common base class. In other words, the radio class will have only a single instance of the storable class, shared by both the transmitter and receiver classes. By having a single instance of storable, we've resolved the compiler's immediate issue, the ambiguity, and the code will compile fine.

Memory Layout in Virtual Inheritance
In order to keep track of the single instance of the storable object, the compiler will provide a virtual function table (vtable) for classes transmitter and receiver. When a radio object is constructed, it creates one storable instance, a transmitter instance and a receiver instance. The transmitter and receiver classes have a virtual pointer in their vtables that stores the offset to the storable class. When the transmitter class or the receiver class goes to access any fields of the storable, it uses the virtual pointer in its vtable to find the storable object and find the field in it. This tutorial offers a comprehensive explanation of the memory layout of virtual inheritance in GCC.
--------------------------
Question:

1. paging
3. parameter of ( send and recv)
4. file ( go to particular location)
5. why malloc will return void *
6. Dangling pointer

Deep copy:-
It's equivalent to B* b3 = b2. The pointers will point to the same location. When you do delete b2;, you're also freeing the memory pointed to by b3.

To do a deep copy, do:

 B* b3 = new B(*b2);

-------------------------------------------------
1. What is the output of printf("%d")
2. Difference between "C structure" and "C++ structure".
3. Difference between a "assignment operator" and a "copy constructor"
4. What is the difference between "overloading" and "overriding"?
5. Explain the need for "Virtual Destructor".
6. Can we have "Virtual Constructors"?
7. What are the different types of polymorphism?
8. What are Virtual Functions? How to implement virtual functions in "C"
9. What are the different types of Storage classes?
10. What is Namespace?
11. What are the types of STL containers?.
12. Difference between "vector" and "array"?
13. How to write a program such that it will delete itself after execution?
14. Can we generate a C++ source code from the binary file?
15. What are inline functions?
16. Talk something about profiling?
17. How many lines of code you have written for a single program?
18. What is "strstream" ?
19. How to write Multithreaded applications using C++?
20. Explain "passing by value", "passing by pointer" and "passing by reference"
21. Write any small program that will compile in "C" but not in "C++"
22. Have you heard of "mutable" keyword?
23. What is a "RTTI"?
24. Is there something that I can do in C and not in C++?
25. Why preincrement operator is faster than postincrement?
26. What is the difference between "calloc" and "malloc"?
27. What will happen if I allocate memory using "new" and free it using "free" or
allocate sing "calloc" and free it using "delete"?
28. What is Memory Alignment?
29. Explain working of printf.
30. Difference between "printf" and "sprintf".
31. What is "map" in STL?
32. When shall I use Multiple Inheritance?
33. What are the techniques you use for debugging?
34. How to reduce a final size of executable?
35. Give 2 examples of a code optimization.
-----------------------------------------------




Interview Question on Bluetooth

Question Asked in Qualcomm:

1. How to increase or decrease the priority of task in Bluedroid stack.

https://android.googlesource.com/platform/external/bluetooth/bluedroid/+/4128e36%5E!/

we are using the int setpriority(int which, int who, int prio); System call

The getpriority() call returns the highest priority (lowest numerical value) enjoyed by any of the specified processes. 

The setpriority() call sets the priorities of all of the specified processes to the specified value. Only the superuser may lower priorities.

A child created by fork(2) inherits its parent's nice value.


28typedef enum {
29    TASK_HIGH_MEDIA = 0,
30    TASK_HIGH_GKI_TIMER,
31    TASK_HIGH_BTU,
32    TASK_HIGH_HCI_WORKER,
33    TASK_HIGH_USERIAL_READ,
34    TASK_UIPC_READ,
35    TASK_JAVA_ALARM,
36    TASK_HIGH_MAX
37} tHIGH_PRIORITY_TASK;

/system/core/include/system/thread_defs.h
enum {
    /*
     * ***********************************************
     * ** Keep in sync with android.os.Process.java **
     * ***********************************************
     *
     * This maps directly to the "nice" priorities we use in Android.
     * A thread priority should be chosen inverse-proportionally to
     * the amount of work the thread is expected to do. The more work
     * a thread will do, the less favorable priority it should get so that
     * it doesn't starve the system. Threads not behaving properly might
     * be "punished" by the kernel.
     * Use the levels below when appropriate. Intermediate values are
     * acceptable, preferably use the {MORE|LESS}_FAVORABLE constants below.
     */
    ANDROID_PRIORITY_LOWEST         =  19,

    /* use for background tasks */
    ANDROID_PRIORITY_BACKGROUND     =  10,

    /* most threads run at normal priority */
    ANDROID_PRIORITY_NORMAL         =   0,

    /* threads currently running a UI that the user is interacting with */
    ANDROID_PRIORITY_FOREGROUND     =  -2,

    /* the main UI thread has a slightly more favorable priority */
    ANDROID_PRIORITY_DISPLAY        =  -4,

    /* ui service treads might want to run at a urgent display (uncommon) */
    ANDROID_PRIORITY_URGENT_DISPLAY =  HAL_PRIORITY_URGENT_DISPLAY,

    /* all normal audio threads */
    ANDROID_PRIORITY_AUDIO          = -16,

    /* service audio threads (uncommon) */
    ANDROID_PRIORITY_URGENT_AUDIO   = -19,

    /* should never be used in practice. regular process might not
     * be allowed to use this level */
    ANDROID_PRIORITY_HIGHEST        = -20,

    ANDROID_PRIORITY_DEFAULT        = ANDROID_PRIORITY_NORMAL,
    ANDROID_PRIORITY_MORE_FAVORABLE = -1,
    ANDROID_PRIORITY_LESS_FAVORABLE = +1,
};
2. Communication b/w task in Bluedroid stack.

Ans: we are using _senmsg(data) API, inside this we are using the Message QUEUE to communicate between (b/w) the task.

3. Why does Bluetooth only allow 7 simultaneous slaves?

Ans: In a piconet, one master can actively communicate with seven other devices
(limited by a 3 bit address), and up to 255 devices can be part of the piconet but inactive("parked").

In the piconet, one or more slaves are connected to a single master. To identify each slave separately, each
slave is assigned a temporary 3 bit address to be used withn it is active.

Packets exchanged between the master and the slave carry the active member address of slave.
in other words, the address of the slave is used in both master and slave packets and in slave to master packets.
Slave that are disconnnected or parked, give up their address and a new one must be assigned when they re-enter the piconet.

The number of device that can be paired is practically unlimited- as long as you have enough

storage for every device's MAC address and link key.



---others---
Imp links:
1. http://www.cnblogs.com/JCSU/articles/1290373.html
2. http://www.techinterviews.com/c-interview-questions-and-answers

*****************************************************************************

1.How does bluetooth turn on? Explain the steps?
2.Tell anyone API which has been used in the framework from the lower level of stack?
3.Explain the code flow of the OPP profile?
4.Tell the file name of HAL which is used as the interface for your profile?
5.Explain the code flow in of btif,bta,jv,dm layer in bluedroid? How they interact?
6.In which layer is the state machine of the OPP profile exist?
7.Where is the L2cap layer code in the bluedroid stack?
8.How do you change the debugging level in the code?
9.How do the SDP works?
10.Tell the function name which is being called from the bt_sock.c to the corresonding RFCOMM and L2CAP file?

C Questions:
1.Why do you use the Volatile keyword?
2.Explain the storage class in C? Explain them?
3.Write the optimized code to delete a node which is 5th from the end? 
4.If a link list data part should contain all three int,char,float. Then how do you declare the linked list?
5.What is quick sorting? What is its worst and best case?
6.Explain the memory map?
7.Where the static,global,auto varible stored in the memory mapping?
8.What is the difference between inline function and MACRO?


OS questions:
1.How the scheduler works? How many types? Which is the best?
2.What is PCB? What does it store?
3.If a process wake up from the sleep which state it goes and what is the flow?
4.WHat is semaphore, mutex, spin lock? Explain the usage of them?

Wednesday, March 8, 2017

State codes of l2cap channels

These state codes indicate the state of an l2cap channel


Defines

#define CH_NOT_ASSIGNED   0x00
#define CH_CLOSED   0x01
#define CH_W4_L2CAP_CONNECT_RSP   0x02
#define CH_W4_L2CA_CONNECT_RSP   0x03
#define CH_CONFIG   0x04
#define CH_OPEN   0x06
#define CH_W4_L2CAP_DISCONNECT_RSP   0x07
#define CH_W4_L2CA_DISCONNECT_RSP   0x08


Bluetooth errors


0x01 Unknown HCI Command.
0x02 No Connection.
0x03 Hardware Failure.
0x04 Page Timeout.
0x05 Authentication Failure.
0x06 Key Missing.
0x07 Memory Full.
0x08 Connection Timeout.
0x09 Max Number Of Connections.
0x0A Max Number Of SCO Connections To A Device.
0x0B ACL connection already exists.
0x0C Command Disallowed.
0x0D Host Rejected due to limited resources.
0x0E Host Rejected due to security reasons.
0x0F Host Rejected due to remote device is only a personal device.
0x10 Host Timeout.
0x11 Unsupported Feature or Parameter Value.
0x12 Invalid HCI Command Parameters.
0x13 Other End Terminated Connection: User Ended Connection.
0x14 Other End Terminated Connection: Low Resources.
0x15 Other End Terminated Connection: About to Power Off.
0x16 Connection Terminated by Local Host.
0x17 Repeated Attempts.
0x18 Pairing Not Allowed.
0x19 Unknown LMP PDU.
0x1A Unsupported Remote Feature.
0x1B SCO Offset Rejected.
0x1C SCO Interval Rejected.
0x1D SCO Air Mode Rejected.
0x1E Invalid LMP Parameters.
0x1F Unspecified Error.
0x20 Unsupported LMP Parameter Value.
0x21 Role Change Not Allowed
0x22 LMP Response Timeout
0x23 LMP Error Transaction Collision
0x24 LMP PDU Not Allowed
0x25 Encryption Mode Not Acceptable
0x26 Unit Key Used
0x27 QoS is Not Supported
0x28 Instant Passed
0x29 Pairing with Unit Key Not Supported
0x2A-0xFF Reserved for Future Use.

Reference: http://www.btnode.ethz.ch/static_docs/old/support/btn_api/group__l2cap__channel__state__codes.html 

Qualcomm Short Term

  113 is the SL. 1st Target by mid July.

Total Pageviews