Skip to content
Websocket Server for ESC/POS Printers
PHP Batchfile
Branch: master
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
dist
doc
src
.gitignore
LICENSE
README.md
box.json
composer.json
composer.lock
distmake.bat

README.md

RawBT: Websocket Server for ESC/POS Printers

RawBT requires PHP 5.4.0+ to run.
The utility is distributed as a Phar package.

Installing on user PC

For Windows

  • Run server (rawbt.bat - The application starts in a minimized window)

For Linux

  • php rawbt.phar

For Linux (run as daemon)

  • copy rawbt.service to /etc/systemd/system/rawbt.service
  • edit User, Group (don't run it as root), WorkingDirectory and ExecStart
  • sudo systemctl daemon-reload
  • sudo systemctl enable rawbt.service
  • sudo systemctl start rawbt.service

screenshot

  • Add bat file to startup

In the /doc directory you can find a useful utility (TrayIt) that can hide the window of a running server.

Front-end

https://rawbt.ru/mike42/example_rawbt/

function pc_print(data){
    var socket = new WebSocket("ws://127.0.0.1:40213/");
    socket.bufferType = "arraybuffer";
    socket.onerror = function(error) {
	  alert("Error");
    };			
	socket.onopen = function() {
		socket.send(data);
		socket.close(1000, "Work complete");
	};
}		
function android_print(data){
    window.location.href = data;  
}
function ajax_print(url, btn) {
    $.get(url, function (data) {
		var ua = navigator.userAgent.toLowerCase();
		var isAndroid = ua.indexOf("android") > -1; 
		if(isAndroid) {
		    android_print(data);
		}else{
		    pc_print(data);
		}
    });
}

Back-end demo

https://github.com/mike42/escpos-php/blob/development/example/rawbt-receipt.php

It is enough to specify the desired connector

    $connector = new RawbtPrintConnector();
You can’t perform that action at this time.