How do I use the Linea-Pro SDK for IOS?

18,338

Solution 1

To provides access to Linea device series.

In order to use Linea in your program, several steps have to be performed. These steps are from 2011, and may have changed in 2017, but are shown here for historical purposes:

- Include LineaSDK.h and libdtdev.a in your project.
- Go to Frameworks and add ExternalAccessory framework
- Edit your program plist file, add new element and select 
  "Supported external accessory protocols" from the list, then add two items to it -
  ‘com.datecs.linea.pro.msr’ and ‘com.datecs.linea.pro.bar’
- Write code in MainViewController.m file to connect and retrieve barcode data.

1) Include “LineaSDK.h” and “libdtdev.a” in your project under Classes folder.

2017 update: Download latest DTDEVICES SDK from developer.ipcmobile.com . As of January 2017, latest version is v2.01, supporting devices up to the Linea Pro 7.

2) “Add existing frameworks” in your project.

  1. In the project navigator, select your project
  2. Select your target.
  3. Select the 'Build Phases' tab
  4. Open 'Link Binaries With Libraries' expander
  5. Click the '+' button
  6. Select 'External Accessory framework'
  7. Drag and drop the added framework to the 'Frameworks' group

3) Edit your project .plist file

<key>Supported external accessory protocols</key>
<value>
<array>
<string>com.datecs.linea.pro.msr</string>
<string>com.datecs.linea.pro.bar</string>
</array>
</value>

4) Write code in MainViewController.m file

// Important to init linea class and connect it

- (void)viewDidLoad
{
    // init linea class and connect it    
    linea =[Linea sharedDevice];
    [linea addDelegate:self];
    [linea connect];    

    [super viewDidLoad];
}

// It calls after successfuly reads barode data

-(void)barcodeData:(NSString *)barcode type:(int)type {    

     // You can use this data as you wish
     // Here I write barcode data into the console
     NSLog(@"Barcode Data: %@”, barcode);
}

Note: Import ‘LineaSDK.h’ into your MainViewController.h and declare

Linea* linea;

variable.

It works very well.

Solution 2

Import the .a and .h file

Add ExternalAccessory.framework

open your info.plist file as source code and add the following lines:

<key>UIBackgroundModes</key>
<array>
    <string>external-accessory</string>
</array>
<key>UISupportedExternalAccessoryProtocols</key>
<array>
    <string>com.datecs.linea.pro.msr</string>
    <string>com.datecs.linea.pro.bar</string>
    <string>com.datecs.printer.escpos</string>
    <string>com.datecs.iserial.communication</string>
    <string>com.datecs.pinpad</string>
</array>

Add <DTDeviceDelegate> to your interface like this:

@interface ViewController : UIViewController <DTDeviceDelegate>

In your .h file of your ViewController add the DTDevices object

@interface ViewController : UIViewController <DTDeviceDelegate>
{
    DTDevices *scanner;
}

In the ViewDidLoad function, add the connection code:

 scanner=[DTDevices sharedDevice];
[scanner addDelegate:self];
[scanner connect];

Get connection status by adding this method to your code:

-(void)connectionState:(int)state {
    switch (state) {
    case CONN_DISCONNECTED:
               //Disconnected
               break;
    case CONN_CONNECTING:
        //Connecting
        break;
    case CONN_CONNECTED:
                 //Connected
                 break;
      }
   }

Hope this helps.

Solution 3

I'm assuming that you are wanting to develop an application with their iPhone/iPod Touch sled. Your best bet will be to look at the sample Xcode project they include with their SDK. This will demonstrate how to connect with the sled, as well as set different options for interacting with the hardware, such as the barcode types it should look for (in cases where you're using a 2D scanner), any hardware sounds it should make, etc.

Their underlying assumption is that you're an experienced iOS developer and you're ready to start integrating with their SDK. It sounds like you're new to iOS development and I would encourage you to get experienced with that before doing something a little more advanced like interacting with hardware peripherals.

At a high level you'll need to:

  1. Create a new Xcode project and drop in their .a and .h files into your project.
  2. Import a couple of required frameworks, the only one I can remember off the top of my head is the ExternalAccessory.framework.
  3. Call the the shared instance to connect with and interact with the hardware.
Share:
18,338

Related videos on Youtube

Chris Pateman
Author by

Chris Pateman

As a Principal Developer I cover many areas of the web application landscape from inception to delivery. I do these with the vast knowledge I have of the technologies and business relationships gained over time. Primary a C# .Net Developer, I have worked with the .Net Framework and .Net Core for Web Applications, Console Apps and Web REST APIs. As well as back end I have also a wide experience with front end using CSS, HTML, JavaScript accompanied with SCSS, JQuery and other frameworks. More Information on LinkedIn: https://www.linkedin.com/in/christopherpateman/

Updated on August 17, 2022

Comments

  • Chris Pateman
    Chris Pateman almost 2 years

    Does anyone know of or have a manual on how to script in xcode with the linea-pro.

    I have hunted the web and asked Infinite Peripherals for help but no reply.

    I found a ".a" and ".h" file that look like they have all the delegations etc but i have no clue how to action some of the functions.

    If you need more information please ask.

    • Warren  P
      Warren P over 7 years
      Adding this five years later for the google visitors: The Linea Pro SDK is documented and supported at the Infinite Peripherals linea pro support website, in their developer area. You may have to sign up to get access to the docs which are in the "development portal" area under their Support. ipcmobile.com/support
  • AdvApp
    AdvApp about 10 years
    Have you found a way to debug? When I have the device connected via the USB cable to the Mac, the device won't connect to the iPhone. If I remove the cable, and run the app, the device immediately connects to the iPhone. How do you debug if you can't connect to the Mac when running the app? I really can't believe they expect us to go back to debugging messages in the app to display them on the iPhone.
  • Randika Vishman
    Randika Vishman about 10 years
    :) you guys at least have the device and iPhone and Mac! :) But I don't really have any! To debug, you should create a Log.txt file or something and add line by line for each LineaPro Device specific code/statements. Then I email that log.txt file as an attachment and try to analyze and get the work done! I have no any other choice with my current poor situation! Because I develop on VMWare installed Mac OS X Mavericks + Simulator!The real device + iPhone is only with the client! :) However I'm gonna upvote the above answer.
  • Sanju
    Sanju over 8 years
    -(void)barcodeData:(NSString *)barcode type:(int)type { } I did same like as above but this delegate method doesn't calls BUT below delegate method responds i cant do anything with that -(void)connectionState:(int)state { }
  • Vinod Kumar
    Vinod Kumar almost 8 years
    Hi Muthu, Though I have connected IPC sled to Iphone, it always says connecting and never says connected. Any suggestions please?
  • Tapas Pal
    Tapas Pal over 7 years
    @VinodKumar did you found any solution??
  • Warren  P
    Warren P over 7 years
    Get newer version of SDK. If that doesn't work, ask for help on the Linea Pro Forums at Infinite Peripherals website. (developer.ipcmobile.com)
  • Shashi Ranjan
    Shashi Ranjan over 5 years
    I am trying to implement the Magnetic card reader with an encryption technique. But you know what the provided encryption delegate is not getting called. Even i am enabling the encryption via emsrSetEncryption and still, I am unable to do that. So do you please help me with this.