RawBT requires PHP 5.4.0+ to run.
The utility is distributed as a Phar package.
- Install PHP (if not installed yet)
- Download last release from https://github.com/402d/rawbt_ws_server/releases
- Unpack
- Copy files from dist folder
- Rename one from examples config
- Edit connect params
- Run server (rawbt.bat - The application starts in a minimized window)
- php rawbt.phar
- 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
- 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.
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);
}
});
}
https://github.com/mike42/escpos-php/blob/development/example/rawbt-receipt.php
It is enough to specify the desired connector
$connector = new RawbtPrintConnector();