jeudi 27 septembre 2012

HTML5 canvas

In thid post you can find some usefull code snipets on HTML5 Canvas.
You may need to include the following javascript files into your main HTML page:
  • Modernizr.js which is a JavaScript library that detects HTML5 and CSS3 features in the user’s browser.
  • jQuery.js which is Javascript library for rapid web development that simplifies many things like event handling, document traversing, etc.
First, check if the Canvas is supported in the browser:
if (!Modernizr.canvas) {
  return
} else {
  // do something
}
Declare the canvas in HTML
<canvas id="canvas" width="500" height="500">Your browser does not support HTML5</canvas>
Get the canvas element in Javascript
canvas = document.getElementById("canvas");
Get a drawing area for 2D arts
context = canvas.getContext("2d");

Draw a rectangle (only the border)
context.strokeStyle = "#000000";
context.strokeRect(0, 0, canvas.width, canvas.height);
Draw a circle filled in black
context.fillStyle = color;
context.arc(centerX,centerY,radius,0,2*Math.PI);
context.fill();
Type text on a given position x, y
context.fillStyle = color;
context.font = '30px_sans';
context.textBaseline = 'top';
context.fillText ("This is a text", x, y);
Draw a line from x1,y1 to x2,y2
context.beginPath();
context.moveTo(x1, y1);
context.lineTo(x2, y2);
context.stroke(); 

Listen for mouse events (down, move, up) on a Canvas element:
canvas.addEventListener('mousedown', mouseEventHandler, false);
canvas.addEventListener('mousemove', mouseEventHandler, false);
canvas.addEventListener('mouseup',   mouseEventHandler, false);

function mouseEventHandler(event) {
  if (event.type == "mousedown") {
     // Mouse Down
  } else if (event.type == "mousemove") {
     // Mouse Move
  } else if (event.type == "mouseup") {
     // Mouse Up
  }
}
Get the mouse coordinates x, y on the canvas.
// returns the coordinates (x, y) of a mouse after click event
function mouseCoordinates(event) {
  var x, y;
  // Get the mouse position relative to the canvas element
  if(event.layerX || event.layerX == 0) { //Firefox
    x = event.layerX;
    y = event.layerY;
  } else if (event.offsetX || event.offsetX == 0) { //Opera
    x = event.offsetX;
    y = event.offsetY;
  }
  return {x:x, y:y};
}
Here is sample project of HTML5-based paint that combine the different things exposed earlier: index.html, webpaint.js.

References

mercredi 26 septembre 2012

Getting started with NFC on Android

This posts introduces Near Field Communication (NFC), its Modes, the Android APIs that can be used to deal with NFC tags and the mysterious NDEF Format (NDEFMessages, NDEFRecord, RTC, TNF, etc.).

Not all Android-based smartphones support NFC, actually the list is limited to Nexus S, Galaxy S II, Xperia Acro, Lg LU6200, Acer Liquid express, Sony Nozomi, Nexus Prime, LG Gelato nfc, etc.

The NFC API was introduced with Android 2.3 (API 9, Dec. 2010) on Nexus S. A more complete API was released win Android 2.3.3 (API 10, Feb. 2011). This API provides tools for detecting TAGs, reading infromation stored on the tag and writing information, and also communicating with other NFC tags. These operations are also called modes:
  • Peer-to-Peer Mode: limited support on Android
  • Reader/Writer Mode: excellent support
  • Card Emulation Mode: no support
The Core classes of the NFC API are NFCAdapter, NFCManager, Tag Technology Classes.
Here is a typical manafest file for an application that want to use the Android NFC API:
Android Manifest
//NFC Permission 
<uses-permission android:name="android.permission.NFC" />
//API Level 
<uses-sdk android:minSdkVersion="10" />
//NFC Feature 
<uses-feature android:name="android.hardware.nfc" android:required="true" />

<application android:icon="@drawable/ic_launcher" android:label="@string/app_name" android:theme="@style/AppTheme" >
<activity android:name=".NfcRWActivity" android:label="NfcRWActivity">
  <intent-filter>
    <action android:name="android.nfc.action.NDEF_DISCOVERED" />
    <data android:mimeType="application/json" />
    <category android:name="android.intent.category.DEFAULT" />
  </intent-filter>
</activity>
</application>
NFCManager used to get the NFCAdapter the real thing that control Foreground Dispatch and P2P NDEF Push, check if NFC is turned on
NfcManager nfc_manager = (NfcManager) getSystemService(NFC_SERVICE);
NFCAdapter nfc_adapter = nfc_manager.getDefaultAdapter();

To read a tag it is easy: unlock phone, touch tag, most likely the intent chooser will open.

Foreground Dispatch System

Foreground Dispatch allows the declaration of the currently active application as prioritar for handling the tags read by user. Thus the Foreground Activity may redirect all intents related to tag, technology or NDEF discovery to itself.
nfcAdapter.enableForegroundDispatch(activity, pendingIntent, intentFiltersArray, techListsArray);

pi = PendingIntent.getActivity(activity, 0, new Intent(activity, activity.getClass()).addFlags(Intent.FLAG_ACTIVITY_SINGLE_TOP), 0);

IntentFilter ndef = new IntentFilter(NfcAdapter.ACTION_NDEF_DISCOVERED);
ndef.addDataType("*/*");
intentFiltersArray = new IntentFilter[] { ndef };
techListsArray = new String[][] {new String[] { NfcA.class.getName() } };
Don't forget to enable in onResume(), disable in onPause(). The tag can be read in onNewIntent().
@Override
protected void onResume() {
  super.onResume();
  nfcAdapter.enableForegroundDispatch(this, pi, intentFiltersArray, techListsArray);
}

@Override
protected void onPause() {
  super.onPause();
  nfcAdapter.disableForegroundDispatch(this);
}

@Override 
protected void onNewIntent(Intent intent) {
  super.onNewIntent(intent);
  Tag tag = intent.getParcelableExtra(NfcAdapter.EXTRA_TAG);
  tag.getId() //returns id as byte[]
  String techs[] = tag.getTechList();
  for (String tech: techs) {
   if (tech.equals("android.nfc.tech.Ndef")) {
    Ndef ndef = Ndef.get(tag);
    ndef.getType();
    ndef.getMaxSize();
    ndef.canMakeReadOnly();
    ndef.isWritable();
    NFCUtil.printNdefMessageDetails(ndef.getCachedNdefMessage());
   }
  }
}

Intent Dispatch System

Ndef discovered
For text or any other mime type:
<intent-filter>
  <action android:name="android.nfc.action.NDEF_DISCOVERED"/>
  <data android:mimeType="text/plain"/>
  <category android:name="android.intent.category.DEFAULT"/>
</intent-filter>
For url:
<intent-filter>
  <action android:name="android.nfc.action.NDEF_DISCOVERED"/>
  <data android:scheme="http" android:host="www.r0ly.fr"/>
  <category android:name="android.intent.category.DEFAULT"/>
</intent-filter>

Tech discovered
In the manifest
<intent-filter>
  <action android:name="android.nfc.action.TECH_DISCOVERED"/>
</intent-filter>

<meta-data android:name="android.nfc.action.TECH_DISCOVERED" android:resource="@xml/techlist"/>
In the xml/techlist.xml file:
<resources xmlns:xliff="urn:oasis:names:tc:xliff:document:1.2">
  <tech-list>
    <tech>android.nfc.tech.IsoDep</tech>
    <tech>android.nfc.tech.MifareClassic</tech>
  </tech-list>
</resources>

Tag Technologies maps to tech specifications or to pseudo-technologie or capabilities like NDEF or NDEFFormatable.
  • TagTechnology The interface that all tag technology classes must implement.
  • NfcA  Provides access to NFC-A (ISO 14443-3A) properties and I/O operations.
  • NfcB Provides access to NFC-B (ISO 14443-3B) properties and I/O operations.
  • NfcF Provides access to NFC-F (JIS 6319-4) properties and I/O operations.
  • NfcV Provides access to NFC-V (ISO 15693) properties and I/O operations.
  • IsoDep Provides access to ISO-DEP (ISO 14443-4) properties and I/O operations.
  • Ndef Provides access to NDEF data and operations on NFC tags that have been formatted as NDEF.
  • NdefFormatable Provides a format operations for tags that may be NDEF formattable.
  • MifareClassic Provides access to MIFARE Classic properties and I/O operations, if this Android device supports MIFARE.
  • MifareUltralight Provides access to MIFARE Ultralight properties and I/O operations, if this Android device supports MIFARE.
NDEF stands for NFC Data Exchange FormatRecords can be MIME-type media, URIs or RTDs (Record Type Definitions)
NdefRecord
Reading Tag Content
//r = NdefRecord
if (r.getTnf() == NdefRecord.TNF_ABSOLUTE_URI) {
  b.append(String.format("TNF_ABSOLUTE_URI: type(%1$s), id(%2$s), payload(%3$s)\n", new String(r.getType()), idBytes.toString(), new String(r.getPaylod())));

} else if (r.getTnf() == NdefRecord.TNF_MIME_MEDIA) {
  b.append(String.format("TNF_MIME_MEDIA: type(%1$s), id(%2$s), payload(%3$s)\n", new String(r.getType()), idBytes.toString(),new String(r.getPayload())));

}

What to listen for?

The following figure depicts how the precedent intent related to tag reading are dispatch, so if you want your application to:
  • receive a notification about a tag been read while your app is in foreground, then you should use for enableForegroundDispatch
  • receive a notification even if it is not the foreground app, then register for NDEF_DISCOVERED.
  • receive a notification when the tag is of a specific technology TECH_DISCOVERED.
  • otherwise you should register for TAG_DISCOVERED.
Tag dispatch
Direct Start
1. Write custom NDEF MIME-type media messages
2. Use custom IntentFilter to blind to your messages

Writing NDEF MIME
NdefMessage msg = NFCUtil.getNdefMimeMessage("application/json", "{\"key\":\"value\"}");
Intent i = new Intent(this, WriteActivity.class);
i.putExtra(WriteActivity.NDEF_MESSAGE, msg);
startActivity(i);
private static NdefRecord getMimeRecord(String mimeType, String content) {
  NdefRecord record = new NdefRecord(NdefRecord.TNF_MIME_MEDIA, mimeType.getBytes(), getRandomIdBytes(), content.getBytes());
  return record;
}
Ndef ndef = Ndef.get(tag);
if (ndef.isWritable() && ndef.getMaxSize() > this.msg.toByteArray().length) {
  ndef.connect();
  ndef.writeNdefMessage(this.msg);
  ndef.close();
} else {
  // do something
}
P2P: NDEF Push
Create NDEF Message which is pushed to another active device once the other device is close
NfcAdapter.enableForegroundNdefPush(activity, ndefmessage);
NfcAdapter.disableForegroundNdefPush(activity);

vendredi 21 septembre 2012

CCNA - Internetworking


Introduction to Internetwork

Breaking up a big network into a number of smaller is called network segmentation, we can do this by using devices like routers, switches, and bridges.
Each segment plugged to a switch is a separate collision domain, doing this increase bandwidth for users.
Hub didn't segment a network, just plugs network segment together. Their using can contribute to congestion on Ethernet network.
Routers create interwork (break up a broadcast domain -- the set of all devices on a segment that hear all the broadcasts sent on that segment).
Routers uses serial interface for WAN connections, V.35 physical interface on a Cisco router.
Routers main functions are packet switching, packet filtering, Internetwork communication, path selection.
Broadcast domain number is equal to the router's connection.
Collision domain number is the sum of all connection of the switches, (connection between switches are considered a collision domain).


Internetworking Models

The OSI Reference Manual

The OSI has seven different layers, divided into two groups. The top three layers define how the applications within the end stations will communicate with each other and with the users. The bottom four defines how data is transmitted end to end.

  1. Application Layer: Application layer is acting as an interface between the actual application program (which isn't a part of the layered structure) and the next layer down, by providing ways for the application to send information down through the protocol stack. It's also responsible for identifying and establishing the availability of the intended communication partner and determining whether sufficient ressources for the intended communication exist.
  2. Presentation Layer: It present data to the Application layer, and is responsible for data translation and code formatting, data compression, decompression, encryption, and some multimedia operations.
  3. Session Layer: It is responsible for setting up, managing sessions between Presentation layer entities. It provides dialog control between devices, coordinate communication between systems and servers to organize their communication by offering different mode: simplex, half duplex, full duplex. 
  4. Transport Layer: It segments and reassembles data, provides end-to-end data transport services and can establish a logical connection on an internetwork. 
    1. Flow Control: It ensures data integrity, prevents from overflowing the buffers in the receiving host, employs a connection-oriented communications session between systems, and the protocols involved, ensure: 
      - The delivered segment is ack back.
      - Any segment not ack is retransmitted.
      - Segments are sequenced back into their proper order at destination.
      - Manageable data flow is maintained to avoid congestion, overloading, loss
    2. Connection-Oriented Communication: The transmitting device first establishes a connection-oriented session with its peer system, called call setup, three-way handshake. Then, data is transferred. Finally, a call termination tears down the virtual circuit.
      The steps of the three-way handshake are:
      - Request for Synchronization from the sender.
      - Acknowledge and connection parameters (rules) setting so that a bidirectional connection is formed.
      - Acknowledgment by the sender.
      But problems can occurs, the transport can issue a not ready indicator to the sender for avoiding dumping resources and allowing data to be lost. After processing the segments on memory, the receiver can send ready transport indicator.
      A service is considered connection-oriented if it uses:
       - Virtual circuit,
       - Sequencing,
       - Acknowledgments,
       - Flow control.
    3. Windowing: The quantity of data segments (in bytes) that the transmitting machine is allowed to send without receiving an acknowledgment for them is called a window.
    4. Acknowledgments: Positive acknowledgment with retransmission requires a receiver to send an acknowledgment message back to the sender when receiving data. When sending, the sender starts a timer and retransmits if it expires before getting ack.
  5. Network Layer: It manages device addressing, tracking the location of devices on the network, and determines the best way to move data. Routing services are provided by the router. When a router receives a packet, it check if not the IP address is his one, else he redirected to the appropriate entry, else it drop the packet when not able to find entry. Two types of packets are received by the router:
     - Data packets: used to transport user data. Protocols used to support data traffic are called routed protocols, like IP, IPv6.
     - Route update packets: Used to update neighbouring routers about the network connected to all routers within the internet work. Protocols that send update packet are called routing protocols, like RIP, RIPv2, EIGRP, and OSPF.
    1. Network address: Protocol-specific network address. A router must maintain a routing table for individual routing protocols because each one keeps track of network with a different addressing scheme (IP, IPv6, IPX).
    2. Interface: The exit interface token by a packet destinated to a specific network.
    3. Metric (e.g. The distance of the remote network): Some routing protocols (namely RIP) use hop count (number of router to pass through to the remote network), while others use bandwidth, delay of the line, ...
  6. Data Link layer: It provides the physical transmission of the data and handles error notification, network topology, and flow control. It formats the data into data frame. Routers are only concerned about finding the best way to reach network, it's the Data Link layer responsibility for the actual unique identification of each device residing on a local network.
    The packet itself isn't altered along the route; it's only encapsulated with the type of control information with the type of control information required for it to be properly passed on to the different media types.
    1. Data Link sub-layers: The IEEE Ethernet Data Link layer has two sub-layers.
       - Media Access Control (MAC) 802.3 : defines how packets are placed on the media. Media access is first come/first served everyone shares the same bandwidth. Physical addressing is defined here, as well as logical topology (the signal path through a physical topology).
       - Logical Link Control (LLC) 802.2 : responsible for identifying Network layer protocols and then encapsulating them with an LLC header. This one will tell the Data Link layer what to do with a packet once a frame is received.
    2. Switches and Bridges at the Data Link Layer: Layer 2 switching is based on hardware called application-specific integrated circuit (ASIC), which run up to gigabit speeds with very low latency.
      Latency is the time between the entry of the frame from a port to its exit from a port.
      Bridges and switches put the source hardware address in a filter table and keeps track of which port the frame was received. After building the filter table, if the address of the incoming frame is the same of the destination, the frame is blocked. If the destination is on a different segment, the frame is transmitted to only that segment. This is called transparent bridging. If the destination isn't found, the frame will be forwarded to every plugged segment, if the destination responds; the filter table will be updated by its location. If the frame has a broadcast address, then it'll be forwarded to each segment.
    3. Binary to Decimal and Hexadecimal Conversion: nibble is 4 bits, bytes is 8 bits.
  7. Physical Layer: This layer is where identifying the interface between Data Terminal Equipment (DTE) and Data Communication Equipment (DCE). DCE is located at the service provider, while DTE is the attached device. The services available to the DTE are most often accessed via a modem or channel service unit/data service unit (CSU/DSU).

Ethernet Networking

When a collision occurs on an Ethernet LAN, the following happens:

  • A jam signal informs all devices that a collision occurred.
  • The collision invokes a random back-off algorithm.
  • Each device stops transmitting until the timers expire.
  • All hosts have equal priority to transmit after the timers have expired.

Half- and Full-Duplex Ethernet

Half-duplex Ethernet is defined in the original 802.3 Ethernet; Cisco says it uses only one wire pair with a digital signal running in both directions on the wire. It uses CSMA/CD. If a hub is attached to a switch, it must operate in half-duplex mode because the end stations must be able to detect collisions.
Full-duplex Ethernet uses two pairs of wires, a point-to-point connection. Because the transmitted data is sent on a different set of wires than the received data, no collisions will occur. It supposes to offer 100 percent efficiency in both directions. For example, you can get 20Mbps with 10Mbps Ethernet running full duplex. It can be used with a connection:
  • From a switch to a host;
  • From a switch to a switch;
  • From a host to host using a crossover cable.

You can run a full-duplex with just about any device except a hub.
When a full-duplex Ethernet port is powered on, it first connects to the remote end and then negotiates with other end using auto-detect mechanism, which decides on the exchange capability (checks if it can run on 10 or 100Mbps, if it can run on full duplex).

Ethernet at the Data Link Layer


1. Ethernet Addressing

It uses the Media Access Control (MAC) address burned into each Ethernet network interface card (NIC). The MAC is 48-bits, the right 24-bits is assigned to the vendor, the left ones,

  • Begin by an Individual/Group (I/G) bit, when it is 0 (the MAC is a device address), when it is 1, the MAC represent a broadcast or multicast address in Ethernet, or broadcast or functional address in TR and FDDI.
  • The next bit global/local (G/L or U/L for Universal) when it is 0 represents a globally administrated address, when it's 1 it represent a locally governed and administrated address.
  • The lower bits: the Organizationally Unique Identifier (OUI) is assigned by the IEEE to an organization.

2. Ethernet Frames
Frames are used to encapsulate packets from Network layer.
The different field of the 802.3 and Ethernet frame are:
  • Preamble : 8-bytes, is a sequence of 0,1 bits. The last byte Start Frame Delimiter (SFD)/Synch is 10101011 to determine the data beginning. 
  • Destination Address (DA): 48-bits length.
  • Source Destination (SA) : 48-bits length.
  • Length or type: 802.3 use a Length field and can't identify the Network layer protocol (must be used in proprietary LAN, eg: IPX). Ethernet use Type field to identify the Network layer protocol.
  • Data: from 64 to 1500 bytes.
  • Frame Check Sequence (FCS) used to store CRC and detect errors.

3. Ethernet at the Physical Layer
The IEEE extended the 802.3 Committee (created from the DIX specification: Ethernet 10Mbps) to 802.3u (Fast Ethernet) and 802.3ab (Gigabit Ethernet on category 5), and finally 802.3ae (10Gbps over fibber and coax).
Here are the original IEEE 802.3 standards:
  • 10Base2: 10Mbps, baseband technology (signalling method for communication on the network), up to 185 meters in length, AUI (Attachment Unit Interface) connector.
  • 10Base5: 10Mbps, baseband technology, 500 meters, AUI connector.
  • 10BaseT: 10Mbps using category 3 UTP, each device must connect into a hub or switch, one host per segment. It uses RJ45 connector.
  • 100BaseTX (IEEE 802.3u): EIA/TIA category 5, 6 or 7 UTP two-pair wiring, one user per segment up to 100m, RJ45 connector, physical star topology.
  • 100BaseFX (IEEE 802.3u): fibber cabling 62.5/125 micron multimode fibber, point-to-point topology up to 412m. It uses ST or SC connector. 
  • 1000BaseCX (IEEE 802.3z): Copper twisted-pair called twinax (balanced coaxial pair), 25m.
  • 1000BaseT (IEEE 802.3ab)
  • 1000BaseSX (IEEE 802.3z)
  • 1000BaseLX (IEEE 802.3z)

Ethernet Cabling

Three types of Ethernet cables are available.

1. Straight-Through Cable

It’s used to connect a Host to switch or hub, Router to switch or hub.
Four wires are used in this cable, only the pins 1, 2, 3, and 6.
          1 ---------------- 1
          2 ---------------- 2
          3 ---------------- 3 
          6 ---------------- 6

2. Crossover Cable

It is used to connect Switch to switch, hub to hub, host to host, hub to switch, Router direct to host. The same wires are used in this cable.
          1 ---------------- 3
          2 ---------------- 6
          3 ---------------- 1
          6 ---------------- 2

3. Rolled Cable

This cable isn't used to connect Ethernet connections, but to connect a host to a router console serial communication (com) port. Eight wires are used in this cable to connect serial devices.
          1 ---------------- 8
          2 ---------------- 7
          3 ---------------- 6
          4 ---------------- 5
          5 ---------------- 4
          6 ---------------- 3
          7 ---------------- 2
          8 ---------------- 1

5. Data Encapsulation 

The Cisco Three-Layer Hierarchical Model

Hierarchy helps us discern where we should go to get what we need.
Cisco defines three layers (logical layers) of hierarchy:
  • The core layer: backbone.
  • The distribution layer: routing.
  • The access layer      : switching.

1. The Core layer

At the top of the hierarchy, it's responsible for transporting large amounts of traffic both reliably and quickly (as fast as possible).

2. The Distribution Layer

Referred to as the workgroup layer. Its primary function is to provide routing, filtering, and WAN access and to determine how packets can access the core, if needed. It's the place where to implement policies for the network.

3. The Access Layer

Referred as the desktop layer. It controls user and workgroup access to internet-work resources. The network resources most users need will be available locally. The distribution layer handles any traffic for remote services. Some functions are:
  • Continued (from distribution layer) use of access control and policies.
  • Creation of separate collision domains (segmentation).
  • Workgroup connectivity into the distribution layer.


dimanche 16 septembre 2012

Tweleve hours for developing a Windows 8 app

What would you do friday night? What's about developing an app, and for which platform, for Windows 8!BeMyApp organized a hack event on friday 14/09/2009 in a cool place called Milk (a nice place for game competitions) near Opéra (Paris).
During this hackathon developers were asked to build a Windows 8 app that a specific topic: image processing.
Sounds interesting but you have only tweleve hours to develop such an app then present it to a jury composed of Microsoft engineers. 
Unfortunately (as always) I had to find a team, I ended in a two members team with only another student while there were teams with dozen members! And yet I wasn't familiar whit microsoft technologies (i.e. windows 8 and visual studio).
Anyway, it was fun and I finished the hackhaton in time with a simple intuitive app for kids, it was working, no bugs :)
The app (the previous picture shows a snapshot of the result of 12h hacks) was a simple windows 8 drawing application based on HTML5 (mainly on canvas). With this app, kids can have fun coloring a black-and-white reference picture (chosen from the app images library).

Serving content with Python SimpleHTTPServer

You just need to go to the directory you want to share its content, then type 
        $ python -m SimpleHTTPServer
        Serving HTTP on 0.0.0.0 port 8000 ...
The directory is now accessible on http://localhost:8000.

Port 8000 is default port used by python http server, however you can change it:
        $ python -m SimpleHTTPServer 5555
        Serving HTTP on 0.0.0.0 port 5555 ...

if you get python.exe: No module named SimpleHTTPServer, you're probably trying with python3.x as python modules are renamed. You should try:
$ python -m http.server

Installing Windows 8 with a Virtual Hard Disk (VHD)

Here are the steps to follow for installing Windows 8 in a dual boot with Windows 7:
First you need to download Windows 8 RTM version, here is a direct link.

Then use this  Power Shell script to create a VHD (Virtual Hard Disk) instance from an ISO image of Windows 8. Don't forget to check what Power Shell version you have because this script runs on version 3.

Then, Launh Powershell with administrator permissions:
.\Convert-WindowsImage.ps1 -SourcePath path_to_win8.iso -Edition Professional
Hint: you can also create a VHD image with VirtualBox.

After, with right click on your Personal Computer icon (in the windows desktop) choose manage, then disk management. From the Action menu choose Attach a virtual disk and point to the already created vhd file.

Finally, type this command line to add the attached disk as a bootable one:
bcdboot F:\Windows

Here is an interesting post for more details about dual booting win7 and win8.

samedi 15 septembre 2012

Deploying a Microsoft UCMA 3.0 application

Here are the main step needed for deploying needed infrastructure to get started with developping UCMA 3.0 (Unified Communication Managed API) applications:
  1. Create a Trusted Application Pool
  2. Assign a certificate to your application server
  3. Create a Trusted Application
  4. Create a Trusted Application Endpoint

Trusted Application Pool creation

The first thing to do is to create a pool for hosting UCMA applications that should be hosted in a different machine than the one used for hosting Microsoft Lync Server.
Open a Lync management shell and type following command:
New-CsTrustedApplicationPool -Identity -Registrar
Example:

New-CsTrustedApplicationPool –Identity ucma_3_app_server_fqdn_address -Registrar lync_server_fqdn_address -Site 1 -ComputerFqdn ucma_3_app_server_fqdn_address


Then run: Run Get-CsSite to get Site ID of current machine.
Certify the application with a certificate autority for a secure exchange between Lync Server and Application Server. Example:

Request-CsCertificate -New -Type Default -FriendlyName "MyUCMAApp_SERVER_FQDN_ADDRESS" -CA active_directory_server_fqdn_address\certificate_autority_name -ComputerFqdn ucma_server_fqdn_address -DomainName "ucma_server_fqdn_address"


Then keep the thumbprint number displayed after issuing the previous comdlet, and type:
Set-CsCertificate -Type Default -Thumbprint

Then, you can register the UCMA application:
New-CsTrustedApplication -ApplicationId -TrustedApplicationPoolFqdn -Port
Example:
New-CsTrustedApplication –AppIicationId MyUCMAApp –TrustedApplcationPoolFqdn ucma_server_fqdn_address -Port 6000

Finally, we need to inform the rest of servers about these changes this way:
Enable-CsTopology

Registering the Application Endpoit

To register an endpoint on the local server that will be used by the application to connect to Lync, use the following command:
New-CsTrustedApplicationEndpoint -ApplicationId -DisplayName -SipAddress -TrustedApplicationPoolFqdn
Example of usage:
New-CsTrustedApplicationEndpoint –ApplictionId MyUCMAApp -DisplayName “my UCMA App” -SipAddress sip:myucmaapp@ucma_server_fqdn_address -TrustedApplicationPoolFqdn ucma_server_fqdn_address

Here is some projects based on Microsoft Lync and UCMA API.

Additional resources:

dimanche 2 septembre 2012

La Poste: a cloud-based mobile application for mail customers

Lastly, I had participate to Le Mobile 2012 Hackathon 1st edition organized by WIP Connector (Wireless Industry Partnership) as part of Le Mobile'2012 annual conference. The event was about building innovative mobile applications for the French Post Office and Auchan. As part of a three member team, we made a project for helping customers of French Post to track their mails and improving their experience.

After the event, we have been invited to the French Post headquarter to give a talk about our idea to a community of high managers from the IT and R&D departments. Here is the presentation (french):

 The idea behind this project is to allow users to track their sent and received postal mail with an application running on their smartphone.
We also imagined a new kind of postal stamp that contains a code bar and can be printed. First, sender scan the stamp code bar then fill a form that contains information about receiver.
Second, when he sends the letter he can notify the receiver through the system so that he/she get ready to receive the letter.
When post office receive the letter they update its state after each operation so that both sender and receiver get notified and updated with the new letter status.
Receiver can notify Post office, at anytime, about changes that must be considered for the delevery of the letter. For example, he may ask to change the address from its home to work address.
Finally, when letter is received and delivered to receiver, the sender is notified automatically.

We deveopped this idea during the two days of the event and the result consists of the following elements:

  • An Android client application for users, an old version was developed with jQuery Mobile.
  • An Android client application for Post employee.
  • An Arduino + IOIO + CodeBar Scanner prototype is developed to make a smartphone barcode reader with high accuracy.
  • A web application for the server side built on top of Google App Engine (J2EE).

The project code source can be found at GitHub.