RIFIDI SDK for handheld

Questions about developing the edge server core as well as applications

Moderators: Matt, kyle

karthik9891
Posts: 16
Joined: Tue Jun 14, 2016 2:02 am

RIFIDI SDK for handheld

Post by karthik9891 » Tue Jun 14, 2016 6:04 am

Hello All,

Can rifidi SDK be used for windows based and android handhelds ? If not, please suggest any alternatives to look out for

Thank you

bppause
Posts: 434
Joined: Sat Oct 03, 2009 12:30 am
Organization: Pramari

Re: RIFIDI SDK for handheld

Post by bppause » Tue Jun 14, 2016 8:56 pm

Yes rifidi can be used with handhelds such as windows and andriod ..this is what is used in the Transcends Inventory control solution

Leverage the generic reader adapter and use can be found in the user and developers guide

Thx

Bpp

karthik9891
Posts: 16
Joined: Tue Jun 14, 2016 2:02 am

Re: RIFIDI SDK for handheld

Post by karthik9891 » Wed Jun 15, 2016 9:07 am

Thank you.

I understand that. But how do we read tags in rifidi application once the handheld sends the tags using the server socket port? In my rifidi application, I'm getting an acknowledgement that the client has sent some data (attaching screen shot below). But how do I read the same in my rifidi application ?

Please advice,

Thank you
Attachments
RIFIDI_Socket.png
RIFIDI_Socket.png (8.16 KiB) Viewed 8980 times

bppause
Posts: 434
Joined: Sat Oct 03, 2009 12:30 am
Organization: Pramari

Re: RIFIDI SDK for handheld

Post by bppause » Wed Jun 15, 2016 3:08 pm

It should be the same way you read with any fixed reader/sensor adapter via the SDK using Rifidi apps - read zones, Rifidi services and/or custom events. (only using the generic adapter and associated reader id in a readzone - same way u would with a fixed reader etc..)

link to Rifidi app jumpstarts - http://wiki.rifidi.net/index.php?title= ... Jumpstarts

link to develop guides - http://wiki.rifidi.net/index.php?title= ... %27s_Guide

what have you tried so far?

BPP

karthik9891
Posts: 16
Joined: Tue Jun 14, 2016 2:02 am

Re: RIFIDI SDK for handheld

Post by karthik9891 » Thu Jun 16, 2016 12:03 pm

I've a rifidi application which subscribes to a custom RawTagSubscriber. Currently, I've this subscriber available to all the fixed readers and the handheld in my environment (ie:- by creating logical LLRP readers for my motorola fixed readers and a generic reader for handhelds in edge management web console). I've initiated sessions for both LLRP and generic readers. When I place any tag near to my fixed reader, I see the tag reads in the "tagArrived" method of custom RawTagSubscriber. But in case if a handheld (Windows CE) sends a tag read event through the opened socket (by creating generic reader and initiating a session) in the edge server, I see only a message "Accepted client at ipAddress:port" in my logs and OSGI console. But I don't see the tag read in my tagArrived method of custom RawTagSubscriber.

From handheld I'm reading a real tag and preparing a string in this format "ID:tagId|Antenna:antennaId|Timestamp:timestampInMillis" and converting to bytes and sending it to the opened socket port using tcp/ip. If my understanding is right, this should trigger the "tagArrived" method of the custom RawTagSubcriber. But it isn't getting invoked.

I'm I missing something ?

Thank you.

bppause
Posts: 434
Joined: Sat Oct 03, 2009 12:30 am
Organization: Pramari

Re: RIFIDI SDK for handheld

Post by bppause » Fri Jun 17, 2016 9:09 am

The handheld/generic adapter should work the same way from Rifidi perspective as any reader/sensor.

Have you tried using the readzone monitoring service as this is what is used with Transcends Inventory control solution (instead of raw tag reads though this should work as well I believe) and ensure to define a reader zone (use of read zones with services is described in developers guide and can be define via application in the dashboard interface)?


Here is a code snippet where Read zone monitoring service is used with a readzone named generic

// Create the subscriber list
this.subscriberList = new LinkedList<ReadZoneSubscriber>();
// Add the subscriber to the subscriber list
this.subscriberList.add(sub);

ReadZone zone = super.getReadZones().get("generic");
List<ReadZone> readzonelist = new LinkedList<ReadZone>();
readzonelist.add(zone);

// This listens for all readers for 5 seconds
this.rzms.subscribe(sub, readzonelist, 1.0f, TimeUnit.SECONDS, true);

Note: The readzone for your custom app can be defined in Dashboard but here is what the resulting file looks like - resulting file name is - readzone-generic.properties

#The ID of the reader
readerID=Generic_1

#The antennas from the reader
antennas

#If we want to filter based on a regular expression, use this property
#tagPattern=(60)(.)*

#If set to true, only use tags that match the above pattern. If set to false, filter out tags
# that match the above patter.
#matchPattern=true

karthik9891
Posts: 16
Joined: Tue Jun 14, 2016 2:02 am

Re: RIFIDI SDK for handheld

Post by karthik9891 » Fri Jun 17, 2016 11:20 am

I tried exactly the same which you mentioned but for rawTagSubscriber. Now, I even tried using ReadZoneMonitoring and placed the readzone properties file under
\Rifidi-SDK\RifidiHome\applications\intel\readzones\readzone-generic.properties. But still didn't work :roll:

Is there a better way to trace what is happening to the data submitted from the handheld in edge server? I don't see anything useful apart from this mentioned below

20:39:49,884 INFO org.rifidi.edge.sensors.sessions.AbstractServerSocketSensorSession:142 - Accepted client at /10.193.50.78

This happens only when the handheld submits a tag to opened socket port of the generic adapter. Looks like the edge server is able to accept the incoming connection.

Any thoughts?

Thank you

bppause
Posts: 434
Joined: Sat Oct 03, 2009 12:30 am
Organization: Pramari

Re: RIFIDI SDK for handheld

Post by bppause » Sat Jun 18, 2016 9:30 pm

Here is a code snippet we use from Windows CE to send message to Rifidi

NetworkStream ns = null;
TcpClient server = null;

try
{
String message = convertItemList(items);

server = new TcpClient(ip, port);

ns = server.GetStream();
ns.Write(Encoding.ASCII.GetBytes(message), 0, message.Length);
ns.Flush();
Console.WriteLine("Done sending a message!");

and here is how the message in constructed in windows CE

public Item(string epc, string location, string item_num, string timestamp, string description)
{
this._epc = epc;
this._location = location;
this._timestamp = timestamp;
this._item_num = item_num;
this._description = description;
}

public override string ToString()
{
return "Item: " + epc + ", " + location + ", " + item_num + ", " + timestamp + ", " +
description;
}
}


private string convertItemList(List<Item> items)
{
string retval = "";

//TODO: Deal with timestamp in millis
foreach (Item i in items)
{
string item_num = "";
string description = "";
if (i.item_num != null) { item_num = i.item_num.Replace(':', ';').Replace('|', '!'); }
if (i.description != null) { description = i.description.Replace(':', ';').Replace('|', '!'); }
retval += ("ID:" + i.epc + "|DateTime:" + i.timestamp.Replace(":", ";") +
"|Antenna:1" + "|location:" + i.location);
if (description != "")
{
retval += ("|description:" + description);
}
if (item_num != "")
{
retval += ("|item_num:"
+ item_num);
}
retval += "\n";
}

return retval;
}

Here is link to the Rifidi generic reader adapter source - https://transcends.svn.cloudforge.com/r ... r.generic/

TagHandler class - where u can see how the incoming tag is handled/payload/validation etc.. https://transcends.svn.cloudforge.com/r ... ndler.java

other options:

U can put debug output in your app to see what's starting ..r readzones being loaded ..events triggering etc..

Also rifidi uses log 4 j so u can configure log 4j described on wiki to turn on additional logling and or console output - http://wiki.rifidi.net/index.php?title= ... di.logging

U could post the app directory structure and code snippet screen shots from eclipse to see how it's setup as well

Plus could u post an example payload ur sending to rifidi from mc9090.

We also offer a commercial production ready inventory control solution integrating the mc9090 handheld with rifidi edge described on http://transcends.co/inventory-control-tool/ along with pricing

karthik9891
Posts: 16
Joined: Tue Jun 14, 2016 2:02 am

Re: RIFIDI SDK for handheld

Post by karthik9891 » Sun Jun 19, 2016 12:27 pm

Thanks for your inputs buddy.

Tried a few stuffs based on your suggestion

1) Replaced timestamp with datetime and tried advancing positions of datetime but that didn't help either. Here is code snippet I'm using in the handheld to send the tag information. Each and every "message" combination was tried,

//String message = "ID:E2004137440E0196189052D5|Antenna:1|Timestamp:1466180037000";
//String message = "ID:E2004137440E0196189052D5|DateTime:" + DateTime.UtcNow + "|Antenna:1";
//String message = "ID:E2004137440E0196189052D5|Timestamp:1466180037000|Antenna:1";
String message = "ID:E3014137440E0196189052D5|Antenna:1|DateTime:2016-06-19T13:00:00.000";

//TcpClient server = new TcpClient("172.20.10.5", 4567);
TcpClient server = new TcpClient("192.168.1.5", 4567);

NetworkStream ns = server.GetStream();
//ns.Write(Encoding.UTF8.GetBytes(message), 0, message.Length);
ns.Write(Encoding.ASCII.GetBytes(message), 0, message.Length);
ns. Flush();
server.Close();

2) Tried turning on the logs in debug and info mode and noticed a few rmi exceptions. Not sure if this is a concern. I did see my readzone properties file being loaded. How do I check if events are getting initialized?

Attaching my sample code base, info,eclipse set up and debug screenshots

Looking forward to your response

Thank you.
Attachments
edgeLog.zip
(85.28 KiB) Downloaded 252 times
Eclipse_Dir_Structure.png
Eclipse_Dir_Structure.png (160.9 KiB) Viewed 8927 times
org.rifidi.app.rfidintel.zip
(10.56 KiB) Downloaded 266 times

bppause
Posts: 434
Joined: Sat Oct 03, 2009 12:30 am
Organization: Pramari

Re: RIFIDI SDK for handheld

Post by bppause » Sun Jun 19, 2016 3:52 pm

Can you try with a older version of rifidi - start with 3.4 and work backwards to 3.0.0 (you should be able to use the same app with older releases)

Also, could you also provide the rifidi.xml - this is the reader/command config after you save the config via dashboard/rest or osgi commandline


Note: attached is a Rifidi Mobile app example using generic (edgemobile) - including rifidi.xml in EdgeMobile folder as reference

Full Windows CE Message sender class

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading;

using System.Net.Sockets;


namespace EdgeMobile
{
class MessageSender
{

private string ip;
private int port;

public MessageSender(string ip, int port)
{
this.ip = ip;
this.port = port;
}


// Sends a message. Since messages are rare and time spent away from
// any network connection is long we will connect and disconnect for every
// message that needs to be sent.
public Boolean sendMessage(List<Item> items)
{
//ConnectionFactory connection = new ConnectionFactory(uri);
//NmsTemplate template = new NmsTemplate(connection);
//template.ConvertAndSend(destination, convertItemList(items));
if (items.Count > 0)
{
NetworkStream ns = null;
TcpClient server = null;

try
{
String message = convertItemList(items);

server = new TcpClient(ip, port);

ns = server.GetStream();
ns.Write(Encoding.ASCII.GetBytes(message), 0, message.Length);
ns.Flush();
Console.WriteLine("Done sending a message!");
}
catch (SocketException)
{
Console.WriteLine("Could not connect to the edge server");
throw new MessageSenderException("Could not connect to the edge server");
}
finally
{
Console.WriteLine("Disconnecting from Server");
if (ns != null)
{
ns.Close();
}
if (server != null)
{
server.Close();
}
}
}
return true;
}

private string convertItemList(List<Item> items)
{
string retval = "";

//TODO: Deal with timestamp in millis
foreach (Item i in items)
{
string item_num = "";
string description = "";
if (i.item_num != null) { item_num = i.item_num.Replace(':', ';').Replace('|', '!'); }
if (i.description != null) { description = i.description.Replace(':', ';').Replace('|', '!'); }
retval += ("ID:" + i.epc + "|DateTime:" + i.timestamp.Replace(":", ";") +
"|Antenna:1" + "|location:" + i.location);
if (description != "")
{
retval += ("|description:" + description);
}
if (item_num != "")
{
retval += ("|item_num:"
+ item_num);
}
retval += "\n";
}

return retval;
}

[Serializable]
public class MessageSenderException : Exception
{
public MessageSenderException() { }
public MessageSenderException(string message) : base(message) { }
}

}
}

Post Reply

Who is online

Users browsing this forum: No registered users and 5 guests