Archive for the ‘CodeProject’ Category.

Mobile Development: PingNG-the next generation ping

As I needed a tool to test the maximum MTU size for a network, I needed a ping tool where I can define the packet size and the DF (Do Not Fragment-Flag). As I did not find such a tool, I wrote PingNG.

main main2 options_df

It is a simple tool but the code had to avoid some pitfalls.

Continue reading ‘Mobile Development: PingNG-the next generation ping’ »

android: ipPrint4 print label/receipts to ip printer

ipPrint4

An android label/receipt printing app for TCP/IP connected printers

This app is based on my btPrint4 app. In contrast to btPrint4 this time we print on TCP/IP connected printers to port 9100.

As with btPrint4 we have a main activity and one to list available printers and one to list available demo files.

ipprint4_main pb31

The challenge with ipPrint4 was a replacement for the bluetooth device discovery. This time we have to scan TCP/IP address range for port 9100. This port is also called HP direct printing port and supported by many printers. It behaves similar to telnet and you can just send print commands to the interface.

The second main change to btPrint4 was the printing code. This time we do not have to use a bluetooth socket but a network TCP/IP socket.

A TCP/IP portscanner

If you scan a range of IP addresses in sequence and try to open a port with a timeout of, let’s say 200ms, the scan will take (200msx254, scan from 1 to 254) 50 seconds.

Port scan code Continue reading ‘android: ipPrint4 print label/receipts to ip printer’ »

Mobile Development: writing today screen plugins the easy way

today Plugins with compact framework

The following today or home screen plugins for Windows Mobile are based on a work of CrisText at codeplex.

The codeplex sources provide a framework to create home screen plugins very easily.

You just start a Form or UserControl and add the attribute “[TodayScreenItem(“a unique name”)]” before the class. Further on, the framework looks for such plugins dynamically and you can add or remove plugins by just adding or removing DLLs.

I did two plugins, one shows the Intermec device ID and the other enables you to have buttons on the home screen to directly launch applications.

Show some information

The first plugin is very simple. An user control that just shows some static text (see the lower info on the screen shot):

today_date_only today_with_apps_and_deviceID

Continue reading ‘Mobile Development: writing today screen plugins the easy way’ »

Android development: a Bluetooth label/receipt printing demo

BtPrint4

A Bluetooth Label printer demo

This is my first Android project and I had to learn how to get an Android activity working. I am a Windows Mobile C# developer and had to learn that you have to do many handwritten code in compare to what Visual Studio for SmartDevice development does automatically.

An Android activity consists of many, many files with references to each other. Fortunately an IDE helps you creating and finding all the files and references.

I started with Eclipse and ADT but went over to use Android Studio. Eclipse showed very strange behaving when designing the GUI of my activities.

functions

To print to a bluetooth printer we need several functions:

  • A reference to the printer, the BT MAC address
  • A socket to communicate with the printer
  • A set of demo data

Make the activity more user friendly

  • provide a list of Bluetooth devices nearby to be used as target
  • move the communication part to a background thread
  • a list with demo data

implementation

The UI has an EditText holding the BT MAC address and a TextView to hold the demo data reference. Buttons for BT discovery, Connect/Disconnect, Demo select and a Print button. There are two list activities (separate windows or forms): the BT device list and a demo data list. The BT MAC address is filled either manually or by selecting a BT device from the list.

btprint4_main

I always try to keep code re-useable and so I implemented some helper classes. Continue reading ‘Android development: a Bluetooth label/receipt printing demo’ »