Download the PHP package olorunda/laravel-aiface-websocket without Composer
On this page you can find all versions of the php package olorunda/laravel-aiface-websocket. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download olorunda/laravel-aiface-websocket
More information about olorunda/laravel-aiface-websocket
Files in olorunda/laravel-aiface-websocket
Package laravel-aiface-websocket
Short Description TimyTeco AiFace Biometric WebSocket / WSS Server & Full Command Interaction SDK for Laravel
License MIT
Informations about the package laravel-aiface-websocket
Laravel AiFace Biometric WebSocket Server & Device Command SDK
A high-performance, asynchronous pure-PHP RFC 6455 WebSocket / WSS Server and complete Command Interaction SDK for TimyTeco AiFace Biometric Terminals (Visible Light Facial Recognition, Fingerprint, Palm Vein, RFID Card, PIN, QR Code Access Control & Time Attendance).
โก Architecture Overview
In the TimyTeco AiFace BS communication protocol, the physical biometric device acts as a client that initiates an outbound persistent WebSocket connection to your Laravel server. This enables seamless Wide Area Network (WAN) and cloud deployment across network segments without requiring static public IPs or port forwarding on the device's local network.
๐ Quickstart Installation
1. Register Package in your Laravel Application
In your Laravel project composer.json, add this package:
(If testing locally in the same monorepo/workspace, add as a path repository):
2. Publish Configuration & Run Database Migrations
Daemon Logging Configuration (.env)
Fine-tune or isolate daemon logs to prevent log pollution on high-traffic servers:
3. Start the WebSocket Server Daemon
Output:
To run on a custom port or with TLS/WSS:
๐ฑ Hardware Device Configuration
On your physical AiFace device touchscreen:
- Tap [Menu / Settings] โ Comm. (Communication) โ Server Settings / Cloud Settings.
- Set Protocol Mode:
WebSocket(orBS / Cloud Server). - Set Server IP / Domain: Your server IP address (e.g.
192.168.1.100orcloud.yourdomain.com). - Set Server Port:
7788(or433for WSS). - Set Server Path:
/pub/chat(default path). - Save and restart network. The device will immediately connect and send the
regregistration handshake.
๐ป Laravel Facade Usage
Interact with any connected device using the AiFace facade:
๐ Realistic Real-World Workflow Example
Below is a complete, production-grade example illustrating how to manage employee lifecycles (enrolling and offboarding users) via a Controller and automatically track attendance punches using Event Listeners.
1. Employee Biometric Controller (Enrolling & Deleting Users)
Create a controller (app/Http/Controllers/BiometricEmployeeController.php):
2. Real-Time Attendance Event Listener
Create an event listener (app/Listeners/HandleBiometricAttendance.php) to automatically process punches when employees clock in or clock out:
3. Registering the Listener in Laravel
In your app/Providers/AppServiceProvider.php (Laravel 11 & 12) or EventServiceProvider.php (Laravel 9 & 10):
๐ ๏ธ Complete Command Reference (All 80+ Commands)
Every command defined in the TimyTeco AiFace specification is implemented with typed methods:
1. User Management (17 Commands)
| Method | Protocol Command | Description |
|---|---|---|
setUserInfo($enrollId, $name, ...) |
setuserinfo |
Set user profile, card, password, face, fingerprint |
setUserFacePhoto($id, $name, $jpg) |
setuserinfo (50) |
Quick enroll face image (base64 JPG) |
setUserPassword($id, $name, $pwd) |
setuserinfo (10) |
Quick enroll PIN/password |
setUserCard($id, $name, $card) |
setuserinfo (11) |
Quick enroll RFID card number |
setUserFingerprint($id, $name, $slot, $hex) |
setuserinfo (0-9) |
Quick enroll fingerprint with 0-compression |
deleteUser($enrollId, $backupNum = null, $delay = null) |
deleteuser |
Delete user immediately or schedule delayed deletion (int seconds or DateTime) |
delayedDeleteUser($enrollId, $delay, $backupNum = null) |
delayeddelete |
Schedule user/credential deletion after delay elapses (offline resilient) |
cancelDelayedDelete($enrollId) |
canceldelayeddelete |
Cancel pending delayed deletion for user |
getPendingDelayedDeletes() |
getpendingdelayeddeletes |
Retrieve list of all scheduled delayed delete tasks |
getPendingCommands() |
getpendingcommands |
Retrieve all pending queued commands (offline queue & scheduled tasks) |
cancelQueuedCommand($taskId) |
cancelqueuedcommand |
Cancel any pending queued command by task ID |
cleanUser() |
cleanuser |
Clear all users from hardware |
setUserName(array $users) |
setusername |
Batch set user names |
getUserName($enrollId) |
getusername |
Query user name by ID |
getUserList($page, $pageSize) |
getuserlist |
Paginated list of user IDs |
getUserIds() |
getuserids |
Query all enrolled user IDs |
getUnusedUserId() |
getunuserdid |
Get next available user ID |
checkUserId($enrollId) |
checkuserid |
Check if user ID exists |
getUserInfo($enrollId, $backupNum) |
getuserinfo |
Retrieve credential data |
getAllUsers($page, $pageSize) |
getallusers |
Batch retrieve user data |
addUser($enrollId, $backupNum, $admin) |
adduser |
Start on-device enrollment wizard |
checkRegStatus($enrollId, $backupNum) |
checkregstatus |
Check status of enrollment |
cancelAddUser($enrollId, $backupNum) |
canceladduser |
Cancel on-device enrollment |
enableUser($enrollId, $enable) |
enableuser |
Enable/disable user account |
getUserProfile($enrollId) |
getuserprofile |
Get custom profile JSON |
setUserProfile($enrollId, $profile) |
setuserprofile |
Set custom profile JSON |
2. Log Management (4 Commands)
| Method | Protocol Command | Description |
|---|---|---|
getNewLog() |
getnewlog |
Fetch unread attendance punch records |
getAllLog($page, $pageSize, $start, $end) |
getalllog |
Paginated search of attendance records |
cleanLog() |
cleanlog |
Clear all logs from hardware |
cleanLogPhoto() |
cleanlogphoto |
Clear snapshot photos from hardware |
3. Device Management (15 Commands)
| Method | Protocol Command | Description |
|---|---|---|
getDevInfo() |
getdevinfo |
Query hardware parameters |
setDevInfo(array $devInfo) |
setdevinfo |
Configure volume, timeout, etc. |
getDevCap() |
getdevcap |
Capacity and usage statistics |
getTime() |
gettime |
Get device RTC clock |
setTime($time) |
settime |
Set device clock |
syncTime() |
settime |
Synchronize with current server time |
initsys() |
initsys |
Factory reset system |
initMenu() |
initmenu |
Reset menu configurations |
cleanDatabase() |
cleandatebase |
Wipe database |
cleanAdmin() |
cleanadmin |
Demote all administrators to normal users |
cleanInactiveUser($days) |
cleaninactiveuser |
Delete users inactive for N days |
reboot() |
reboot |
Reboot device hardware |
disableDevice() |
disabledevice |
Disable recognition |
enableDevice() |
enabledevice |
Enable recognition |
checkLive() |
checklive |
Heartbeat ping from server |
getReg() |
getreg |
Read registration info |
4. Access Control (9 Commands)
| Method | Protocol Command | Description |
|---|---|---|
openDoor($doorNum) |
opendoor |
Remote unlock door relay |
lockCtrl($ctrl, $doorNum) |
lockctrl |
0=Normal, 1=Always Open, 2=Always Closed |
getDoorStatus($doorNum) |
getdoorstatus |
Query magnetic door sensor state |
setDevLock(array $lockParams) |
setdevlock |
Set relay delay, sensor mode, alarm |
getDevLock() |
getdevlock |
Read access lock parameters |
getUserLock($enrollId) |
getuserlock |
Get user timezone / door group |
setUserLock(array $records) |
setuserlock |
Batch set user access permissions |
deleteUserLock($enrollId) |
deleteuserlock |
Remove user access permissions |
cleanUserLock() |
cleanuserlock |
Clear all user permissions |
5. Attendance Management (6 Commands)
| Method | Protocol Command | Description |
|---|---|---|
getShift($shiftId) |
getshift |
Query shift schedule |
setShift($shiftId, array $records) |
setshift |
Set shift schedule |
getBellTime() |
getbelltime |
Query bell alarm schedule |
setBellTime(array $bells) |
setbelltime |
Set bell alarm schedule |
setHoliday(array $holidays) |
setholiday |
Set holiday dates |
getHoliday() |
getholiday |
Query holiday dates |
6. File Management (3 Commands)
| Method | Protocol Command | Description |
|---|---|---|
getDir($path) |
getdir |
List files in device directory |
getFile($filename, $index, $count) |
getfile |
Download file from device (base64) |
writeFile($filename, $base64, ...) |
writefile |
Upload file to device (base64) |
7. Other System Commands (15 Commands)
| Method | Protocol Command | Description |
|---|---|---|
upgrade($url, $md5) |
upgrade |
Firmware upgrade from server URL |
forceOta() |
forceota |
Force immediate OTA check |
setOtaServer($url) |
setotaserver |
Configure OTA update endpoint |
getOtaServer() |
getotaserver |
Query OTA update endpoint |
setScreensaver($base64Data) |
setscreensaver |
Set screensaver image/video |
setVoice($index, $base64Audio) |
setvoice |
Set custom voice audio prompts |
keypad($show) |
keypad |
Control on-screen keypad |
verify($enrollId, $mode) |
verify |
Remote biometric verification |
setDepartment(array $departments) |
setdepartment |
Configure department list |
getDepartment() |
getdepartment |
Query department list |
setCompanyName($name) |
setcompanyname |
Set company title on screen |
getCompanyName() |
getcompanyname |
Query company title |
setQuestionnaire(array $questions) |
setquestionnaire |
Configure survey questions |
getQuestionnaire() |
getquestionnaire |
Query questionnaires |
cleanQuestionnaire() |
cleanquestionnaire |
Clear questionnaires |
8. Video Intercom Commands (11 Commands)
| Method | Protocol Command | Description |
|---|---|---|
enableWebRtc(...) |
enablewebrtc |
Configure WebRTC, STUN, and TURN |
callAccept($sessionId, $accept) |
callaccept |
Accept or reject video call |
viewReady($sessionId) |
viewready |
Signal ready for stream |
answer($sessionId, $sdp) |
answer |
Send WebRTC answer SDP |
iceCandidate($sessionId, ...) |
icecandidate |
Send ICE candidate |
callCancel($sessionId) |
callcancel |
Terminate video call |
talkLock($sessionId, $doorNum) |
talklock |
Unlock door during active call |
monitorCall($sessionId) |
monitorcall |
Start video monitoring |
setViSelection(array $selections) |
setviselection |
Set visual selection menu |
๐ HTTP REST API & Webhooks
REST Endpoints
GET /api/aiface/devices: List all online and registered hardware.GET /api/aiface/devices/{sn}: Detailed parameters of a specific device.POST /api/aiface/devices/{sn}/command: Send arbitrary JSON command to device.POST /api/aiface/devices/{sn}/opendoor: Quick remote door unlock.POST /api/aiface/devices/{sn}/reboot: Hardware reboot.POST /api/aiface/devices/{sn}/users: Create / update user on terminal.DELETE /api/aiface/devices/{sn}/users/{enrollid}: Delete user immediately or schedule delayed deletion (?delay=3600).GET /api/aiface/devices/{sn}/delayed-deletes: List all scheduled delayed deletions for device.DELETE /api/aiface/devices/{sn}/delayed-deletes/{enrollid}: Cancel a scheduled delayed deletion.GET /api/aiface/devices/{sn}/queued-commands: List all pending queued & scheduled commands for device.DELETE /api/aiface/devices/{sn}/queued-commands/{taskId}: Cancel a pending queued command by task ID.GET /api/aiface/devices/{sn}/new-logs: Fetch unread logs.GET /api/aiface/logs: View stored attendance punches.GET /api/aiface/commands/catalog: Complete command schema catalog.
๐ก๏ธ Automatic Offline Command Queueing & Auto-Flush on Reconnect
In real-world deployments, biometric devices may temporarily lose Wi-Fi or go offline during maintenance. Rather than displaying errors or timing out waiting for a device response:
The server automatically intercepts offline or unresponsive states and queues the command:
- Persistent Backing: Commands are persisted in memory and in the
aiface_scheduled_commandsdatabase table. If the server daemon restarts, pending commands are recovered automatically. - Auto-Flush Upon Reconnect: The instant the physical device connects and registers with the WebSocket daemon (
cmd: reg), the daemon flushes and dispatches all pending queued commands in FIFO order! - Event & Webhook: Fires the
CommandQueuedevent (command.queuedwebhook).
Import postman_collection.json into Postman for ready-to-use requests.
Webhook & Laravel Event Listeners
The package routes all hardware events through Laravel's standard Event Dispatcher and a dedicated event listener (DispatchAiFaceWebhook):
1. Listening to Clock-In & Biometric Events in Laravel
You can attach listeners or subscribers in your own application:
2. External Webhook Event Forwarding
Configure external HTTP webhook endpoints in config/aiface.php:
Incoming webhook requests include HMAC SHA-256 signatures for tamper verification:
๐งช Testing with Mock Device Simulator
Run the included pure-PHP mock terminal simulator to test end-to-end communication without physical hardware:
The mock device maintains its own local SQLite database (tynyteko_{SN}.sqlite) simulating real hardware storage:
- Persistent Biometric Storage: Real CRUD for users, credentials (passwords, RFID cards, facial feature templates, fingerprints).
- Dynamic Command Handling: Responds to
setuserinfo,deleteuser,cleanuser,getusername,getuserlist,getuserids,getunuserdid,checkuserid,getuserinfo,getallusers,getdevcap,getdevinfo,settime, etc. - Realistic Attendance Simulation: Generates facial scan punch logs (
sendlog) for enrolled database users and processes server confirmations (mark: true).
Run the test suite:
๐ License
MIT License.
All versions of laravel-aiface-websocket with dependencies
illuminate/support Version ^9.0|^10.0|^11.0|^12.0|^13.0
illuminate/database Version ^9.0|^10.0|^11.0|^12.0|^13.0
illuminate/http Version ^9.0|^10.0|^11.0|^12.0|^13.0
illuminate/routing Version ^9.0|^10.0|^11.0|^12.0|^13.0
illuminate/events Version ^9.0|^10.0|^11.0|^12.0|^13.0
illuminate/console Version ^9.0|^10.0|^11.0|^12.0|^13.0