Given a Bar code message with a P2P DI:
(25P)QCELMIAQ7B4 (S)400D02 (34L)HTTP://ELMICRON.DE/P2P/?S=
(from the sample code sheet: p2p_samples.pdf)
The intelligent bar code scanner will translate this to the PSP URL by appending the code data to the URL, separated by ASCII GS:
The server will analyse the appended code data, extract the product code and serial number and start the process related to this object. Klick on the URL for a sample status query.
The decoding algorithm on the server side is implemented by the following code:
// Check if Code data given if (is_string($_GET["S"])) { // Code data given // Separate on gs $Fields = explode("\x1d", $_GET["S"]); // Loop over fields foreach ($Fields as $FieldData) { // Separate DI and data // Note: data character set is quite restrictive here // which might be different for other applications if (preg_match('#^([0-9]{0,4}[A-Z])([A-Za-z0-9_/.-]*)$#',$FieldData,$DIValue)) { // Set in associative array $DIData[$DIValue[1]] = $DIValue[2]; } } } // Check if product and serial number found if (isset($DIData["25P"]) && isset($DIData["S"]) ) { ... do something with the product code and serial number }
Code snippet may be used freely. It was written by Harald Oehlmann on 2015-02-20, PHP7 correction on 2017-08-21.
To demo this with a PC and a bar code scanner, one may use the application Elmi-Scanlink Demo, available on the web page www.elmicron.de.
The open-source barcode reader zxing was extended by general URL extraction functionality:
One must activate "Extract URL" in the options to get the P2P URL as output.The upper patched version was written by Christian Werner from the TCL sketch skript (which might be tried with Androwish on Android). It succeeds all tests on the test page.
Service by Elmicron GmbH. See Imprint.