Search code examples
ioscocoa-touchprintingbonjour

LPD network printer on iPhone


I need to connect one of the thermal network receipts to iPhone/iPad. The printer doesn't support AirPrint feature. Now it is currently connected to the router and has an IP address. It looks like when I am trying to find it in the current domain using Bonjour (listen to service types _printer._tcp, _printer._udp, _ldp._tcp/_udp, _ndd._tcp/_udp) it is not showing up.

If I go to Printer Settings on my Mac and trying to find that printer from Defaults (which I assume uses Bonjour too), it is not there too. The only way for me to add the printer to the Mac computer is by entering the IP manually (which is not what I want). Plus, if I re-share the printer added manually from Mac, then I can search it on iPhone/iPad using Bonjour and listening for the service "_ipp. _tcp".

Another thing I tried is to use something like "dns-sd -P "Thermal Printer" _printer._tcp. local 515 thermal.local 196.168.0.3 " using the IP I already know. It looks like it is working too.

But, what I need is to be able to find the printer from iPhone/iPad automatically, like the Square app does. I am not sure if it is possible using Bonjour (what service I need to search for), or I need to use sockets and listen to a particular port.

Any advice would be appreciated.


Solution

  • I ended up sending an icmp request to broadcast address to get all ips from the network and then by using StarIO IOS Kit check if the address belongs to printer. Then I display all printers in a list for user to choose.

    to find a broadcast: NICInfo for icmp request: SimplePing to communicate to the TSP100 - STARIO IOS Raster printing.