smartx-rfid 1.0.0__tar.gz → 1.7.4__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (42) hide show
  1. smartx_rfid-1.7.4/PKG-INFO +344 -0
  2. smartx_rfid-1.7.4/README.md +310 -0
  3. {smartx_rfid-1.0.0 → smartx_rfid-1.7.4}/pyproject.toml +4 -1
  4. {smartx_rfid-1.0.0 → smartx_rfid-1.7.4}/src/smartx_rfid/__init__.py +1 -1
  5. smartx_rfid-1.7.4/src/smartx_rfid/clients/rchlo.py +9 -0
  6. smartx_rfid-1.7.4/src/smartx_rfid/db/__init__.py +1 -0
  7. smartx_rfid-1.7.4/src/smartx_rfid/db/_main.py +432 -0
  8. {smartx_rfid-1.0.0 → smartx_rfid-1.7.4}/src/smartx_rfid/devices/RFID/X714/on_receive.py +0 -3
  9. {smartx_rfid-1.0.0 → smartx_rfid-1.7.4}/src/smartx_rfid/devices/RFID/X714/rfid.py +2 -0
  10. smartx_rfid-1.7.4/src/smartx_rfid/parser/__init__.py +1 -0
  11. smartx_rfid-1.7.4/src/smartx_rfid/parser/main.py +27 -0
  12. smartx_rfid-1.7.4/src/smartx_rfid/parser/rfid_tag_parser/__init__.py +15 -0
  13. smartx_rfid-1.7.4/src/smartx_rfid/parser/rfid_tag_parser/exceptions.py +15 -0
  14. smartx_rfid-1.7.4/src/smartx_rfid/parser/rfid_tag_parser/tag_tid_parser.py +674 -0
  15. smartx_rfid-1.7.4/src/smartx_rfid/schemas/events.py +7 -0
  16. {smartx_rfid-1.0.0 → smartx_rfid-1.7.4}/src/smartx_rfid/schemas/tag.py +4 -4
  17. {smartx_rfid-1.0.0 → smartx_rfid-1.7.4}/src/smartx_rfid/utils/__init__.py +1 -0
  18. {smartx_rfid-1.0.0 → smartx_rfid-1.7.4}/src/smartx_rfid/utils/path.py +20 -13
  19. smartx_rfid-1.7.4/src/smartx_rfid/utils/regex.py +9 -0
  20. {smartx_rfid-1.0.0 → smartx_rfid-1.7.4}/src/smartx_rfid/utils/tag_list.py +77 -26
  21. smartx_rfid-1.7.4/src/smartx_rfid/webhook/__init__.py +2 -0
  22. smartx_rfid-1.7.4/src/smartx_rfid/webhook/_main.py +153 -0
  23. smartx_rfid-1.7.4/src/smartx_rfid/webhook/xtrack.py +30 -0
  24. smartx_rfid-1.0.0/PKG-INFO +0 -83
  25. smartx_rfid-1.0.0/README.md +0 -52
  26. {smartx_rfid-1.0.0 → smartx_rfid-1.7.4}/LICENSE +0 -0
  27. {smartx_rfid-1.0.0 → smartx_rfid-1.7.4}/src/smartx_rfid/devices/RFID/R700_IOT/_main.py +0 -0
  28. {smartx_rfid-1.0.0 → smartx_rfid-1.7.4}/src/smartx_rfid/devices/RFID/R700_IOT/on_event.py +0 -0
  29. {smartx_rfid-1.0.0 → smartx_rfid-1.7.4}/src/smartx_rfid/devices/RFID/R700_IOT/reader_config_example.py +0 -0
  30. {smartx_rfid-1.0.0 → smartx_rfid-1.7.4}/src/smartx_rfid/devices/RFID/R700_IOT/reader_helpers.py +0 -0
  31. {smartx_rfid-1.0.0 → smartx_rfid-1.7.4}/src/smartx_rfid/devices/RFID/R700_IOT/write_commands.py +0 -0
  32. {smartx_rfid-1.0.0 → smartx_rfid-1.7.4}/src/smartx_rfid/devices/RFID/X714/_main.py +0 -0
  33. {smartx_rfid-1.0.0 → smartx_rfid-1.7.4}/src/smartx_rfid/devices/RFID/X714/ble_protocol.py +0 -0
  34. {smartx_rfid-1.0.0 → smartx_rfid-1.7.4}/src/smartx_rfid/devices/RFID/X714/serial_protocol.py +0 -0
  35. {smartx_rfid-1.0.0 → smartx_rfid-1.7.4}/src/smartx_rfid/devices/RFID/X714/tcp_protocol.py +0 -0
  36. {smartx_rfid-1.0.0 → smartx_rfid-1.7.4}/src/smartx_rfid/devices/RFID/X714/write_commands.py +0 -0
  37. {smartx_rfid-1.0.0 → smartx_rfid-1.7.4}/src/smartx_rfid/devices/__init__.py +0 -0
  38. {smartx_rfid-1.0.0 → smartx_rfid-1.7.4}/src/smartx_rfid/devices/generic/SERIAL/_main.py +0 -0
  39. {smartx_rfid-1.0.0 → smartx_rfid-1.7.4}/src/smartx_rfid/devices/generic/TCP/_main.py +0 -0
  40. {smartx_rfid-1.0.0 → smartx_rfid-1.7.4}/src/smartx_rfid/devices/generic/TCP/helpers.py +0 -0
  41. {smartx_rfid-1.0.0 → smartx_rfid-1.7.4}/src/smartx_rfid/utils/event.py +0 -0
  42. {smartx_rfid-1.0.0 → smartx_rfid-1.7.4}/src/smartx_rfid/utils/logger_manager.py +0 -0
@@ -0,0 +1,344 @@
1
+ Metadata-Version: 2.4
2
+ Name: smartx-rfid
3
+ Version: 1.7.4
4
+ Summary: SmartX RFID library
5
+ License: MIT
6
+ License-File: LICENSE
7
+ Keywords: python,library,RFID,smartx,packaging
8
+ Author: Gabriel Henrique Pascon
9
+ Author-email: gh.pascon@gmail.com
10
+ Requires-Python: >=3.11,<4.0
11
+ Classifier: Intended Audience :: Developers
12
+ Classifier: License :: OSI Approved :: MIT License
13
+ Classifier: Operating System :: OS Independent
14
+ Classifier: Programming Language :: Python :: 3
15
+ Classifier: Programming Language :: Python :: 3.11
16
+ Classifier: Programming Language :: Python :: 3.12
17
+ Classifier: Programming Language :: Python :: 3.13
18
+ Classifier: Programming Language :: Python :: 3.14
19
+ Classifier: Topic :: Software Development :: Libraries :: Python Modules
20
+ Requires-Dist: bleak (>=1.1.1,<2.0.0)
21
+ Requires-Dist: httpx (==0.28.1)
22
+ Requires-Dist: psycopg2 (>=2.9.11,<3.0.0)
23
+ Requires-Dist: pydantic (>=2.12.5,<3.0.0)
24
+ Requires-Dist: pyepc (==0.5.0)
25
+ Requires-Dist: pymysql (==1.1.1)
26
+ Requires-Dist: pyserial (==3.5)
27
+ Requires-Dist: pyserial-asyncio (==0.6)
28
+ Requires-Dist: sqlalchemy (==2.0.29)
29
+ Project-URL: Documentation, https://github.com/ghpascon/smartx_rfid#readme
30
+ Project-URL: Homepage, https://github.com/ghpascon/smartx_rfid
31
+ Project-URL: Repository, https://github.com/ghpascon/smartx_rfid
32
+ Description-Content-Type: text/markdown
33
+
34
+ # SmartX RFID
35
+
36
+ ![Python Version](https://img.shields.io/badge/python-3.11+-blue.svg)
37
+ ![Version](https://img.shields.io/badge/version-1.5.0-green.svg)
38
+ ![License](https://img.shields.io/badge/license-MIT-blue.svg)
39
+
40
+ Python library for RFID device integration and data management.
41
+
42
+ ## Installation
43
+
44
+ ```bash
45
+ pip install smartx-rfid
46
+ ```
47
+
48
+ ## Quick Start
49
+
50
+ ```python
51
+ from smartx_rfid.devices import X714
52
+ import asyncio
53
+
54
+ async def on_tag_read(name: str, tag_data: dict):
55
+ print(f"Tag: {tag_data['epc']} | RSSI: {tag_data['rssi']}dBm")
56
+
57
+ async def main():
58
+ reader = X714(name="RFID Reader", start_reading=True)
59
+ reader.on_event = lambda name, event_type, data: (
60
+ asyncio.create_task(on_tag_read(name, data))
61
+ if event_type == "tag" else None
62
+ )
63
+
64
+ await reader.connect()
65
+
66
+ while True:
67
+ await asyncio.sleep(1)
68
+
69
+ asyncio.run(main())
70
+ ```
71
+
72
+ ## Features
73
+
74
+ ### Supported Devices
75
+ - **X714 RFID Reader** - Serial, TCP, Bluetooth LE connections
76
+ - **R700 IOT** - HTTP REST API integration
77
+ - **Generic Serial/TCP** - Custom protocol support
78
+
79
+ ### Core Components
80
+ - **Device Management** - Async communication with auto-reconnection
81
+ - **Database Integration** - SQLAlchemy with multiple database support
82
+ - **Webhook System** - HTTP notifications with retry logic
83
+ - **Tag Management** - Thread-safe tag list with deduplication
84
+
85
+ ## Device Examples
86
+
87
+ ### X714 RFID Reader
88
+
89
+ ```python
90
+ from smartx_rfid.devices import X714
91
+
92
+ # Serial connection (auto-detect)
93
+ reader = X714(name="X714-Serial")
94
+
95
+ # TCP connection
96
+ reader = X714(
97
+ name="X714-TCP",
98
+ connection_type="TCP",
99
+ ip="192.168.1.100"
100
+ )
101
+
102
+ # Bluetooth LE
103
+ reader = X714(
104
+ name="X714-BLE",
105
+ connection_type="BLE"
106
+ )
107
+
108
+ def on_event(name: str, event_type: str, data: dict):
109
+ if event_type == "tag":
110
+ print(f"EPC: {data['epc']}, Antenna: {data['ant']}")
111
+
112
+ reader.on_event = on_event
113
+ await reader.connect()
114
+ ```
115
+
116
+ ### R700 IOT Reader
117
+
118
+ ```python
119
+ from smartx_rfid.devices import R700_IOT, R700_IOT_config_example
120
+
121
+ reader = R700_IOT(
122
+ name="R700-Reader",
123
+ ip="192.168.1.200",
124
+ config=R700_IOT_config_example
125
+ )
126
+
127
+ reader.on_event = on_event
128
+ await reader.connect()
129
+ ```
130
+
131
+ ## Database Integration
132
+
133
+ ```python
134
+ from smartx_rfid.db import DatabaseManager
135
+ from sqlalchemy import Column, String, Float, Integer, DateTime
136
+ from sqlalchemy.orm import DeclarativeBase
137
+ from datetime import datetime
138
+
139
+ class Base(DeclarativeBase):
140
+ pass
141
+
142
+ class TagModel(Base):
143
+ __tablename__ = 'rfid_tags'
144
+
145
+ id = Column(Integer, primary_key=True)
146
+ epc = Column(String(50), unique=True, nullable=False)
147
+ tid = Column(String(50))
148
+ ant = Column(Integer)
149
+ rssi = Column(Float)
150
+ created_at = Column(DateTime, default=datetime.utcnow)
151
+
152
+ # Initialize database
153
+ db = DatabaseManager("sqlite:///rfid_tags.db")
154
+ db.register_models(TagModel)
155
+ db.create_tables()
156
+
157
+ # Use with sessions
158
+ with db.get_session() as session:
159
+ tag = TagModel(epc="E200001175000001", ant=1, rssi=-45.2)
160
+ session.add(tag)
161
+
162
+ # Raw SQL queries
163
+ results = db.execute_query_fetchall(
164
+ "SELECT * FROM rfid_tags WHERE rssi > :threshold",
165
+ params={"threshold": -50}
166
+ )
167
+ ```
168
+
169
+ ### Supported Databases
170
+ - PostgreSQL: `postgresql://user:pass@localhost/db`
171
+ - MySQL: `mysql+pymysql://user:pass@localhost/db`
172
+ - SQLite: `sqlite:///path/to/database.db`
173
+
174
+ ## Webhook Integration
175
+
176
+ ```python
177
+ from smartx_rfid.webhook import WebhookManager
178
+
179
+ webhook = WebhookManager("https://api.example.com/rfid-events")
180
+
181
+ # Send tag data
182
+ success = await webhook.post("device_01", "tag_read", {
183
+ "epc": "E200001175000001",
184
+ "rssi": -45.2,
185
+ "antenna": 1,
186
+ "timestamp": "2026-01-15T10:30:00Z"
187
+ })
188
+
189
+ if success:
190
+ print("Webhook sent successfully")
191
+ ```
192
+
193
+ ## Tag Management
194
+
195
+ ```python
196
+ from smartx_rfid.utils import TagList
197
+
198
+ # Create thread-safe tag list
199
+ tags = TagList(unique_identifier="epc")
200
+
201
+ def on_tag(device: str, tag_data: dict):
202
+ new_tag, tag = tags.add(tag_data, device=device)
203
+
204
+ if new_tag:
205
+ print(f"New tag: {tag['epc']}")
206
+ # Add custom data
207
+ tag['product_name'] = "Widget ABC"
208
+ else:
209
+ print(f"Existing tag: {tag['epc']}")
210
+
211
+ # Use with device events
212
+ reader.on_event = lambda name, event_type, data: (
213
+ on_tag(name, data) if event_type == "tag" else None
214
+ )
215
+ ```
216
+
217
+ ## Complete Integration Example
218
+
219
+ ```python
220
+ import asyncio
221
+ from smartx_rfid.devices import X714
222
+ from smartx_rfid.db import DatabaseManager
223
+ from smartx_rfid.webhook import WebhookManager
224
+ from smartx_rfid.utils import TagList
225
+
226
+ async def rfid_system():
227
+ # Initialize components
228
+ reader = X714(name="Production-Scanner", start_reading=True)
229
+ db = DatabaseManager("postgresql://localhost/rfid_production")
230
+ webhook = WebhookManager("https://api.internal.com/rfid")
231
+ tags = TagList()
232
+
233
+ async def process_tag(name: str, tag_data: dict):
234
+ # Check if new tag
235
+ new_tag, tag = tags.add(tag_data, device=name)
236
+
237
+ if new_tag:
238
+ # Save to database
239
+ with db.get_session() as session:
240
+ session.add(TagModel(**tag_data))
241
+
242
+ # Send notification
243
+ await webhook.post(name, "new_tag", tag_data)
244
+ print(f"New tag processed: {tag_data['epc']}")
245
+
246
+ reader.on_event = lambda n, t, d: (
247
+ asyncio.create_task(process_tag(n, d)) if t == "tag" else None
248
+ )
249
+
250
+ await reader.connect()
251
+
252
+ asyncio.run(rfid_system())
253
+ ```
254
+
255
+ ## Configuration
256
+
257
+ ### Device Configuration
258
+ ```python
259
+ # High-performance settings
260
+ reader = X714(
261
+ name="FastScanner",
262
+ read_power=30, # Max power
263
+ session=2, # Session config
264
+ read_interval=100 # Fast scanning
265
+ )
266
+
267
+ # Database with connection pooling
268
+ db = DatabaseManager(
269
+ database_url="postgresql://user:pass@localhost/db",
270
+ pool_size=10,
271
+ max_overflow=20,
272
+ echo=True # Enable SQL logging
273
+ )
274
+ ```
275
+
276
+ ### Logging Setup
277
+ ```python
278
+ import logging
279
+
280
+ logging.basicConfig(
281
+ level=logging.INFO,
282
+ format="%(asctime)s - %(name)s - %(levelname)s - %(message)s"
283
+ )
284
+ ```
285
+
286
+ ## API Reference
287
+
288
+ ### Core Modules
289
+ - `smartx_rfid.devices` - Device communication classes
290
+ - `smartx_rfid.db` - Database management
291
+ - `smartx_rfid.webhook` - HTTP notification system
292
+ - `smartx_rfid.utils` - Utility classes and helpers
293
+
294
+ ### Event System
295
+ All devices use a consistent event callback system:
296
+
297
+ ```python
298
+ def on_event(device_name: str, event_type: str, event_data: dict):
299
+ """
300
+ Event types:
301
+ - "connected": Device connected successfully
302
+ - "disconnected": Device disconnected
303
+ - "tag": RFID tag detected
304
+ - "error": Error occurred
305
+ """
306
+ pass
307
+
308
+ device.on_event = on_event
309
+ ```
310
+
311
+ ## Examples
312
+
313
+ The `examples/` directory contains working examples for all supported devices and features:
314
+
315
+ ```
316
+ examples/
317
+ ├── devices/
318
+ │ ├── RFID/ # X714, R700_IOT examples
319
+ │ └── generic/ # Serial, TCP examples
320
+ ├── db/ # Database integration examples
321
+ └── utils/ # Tag management examples
322
+ ```
323
+
324
+ Run examples:
325
+ ```bash
326
+ python examples/devices/RFID/X714_SERIAL.py
327
+ python examples/db/showcase.py
328
+ ```
329
+
330
+ ## Requirements
331
+
332
+ - Python 3.11+
333
+ - Dependencies automatically installed with pip
334
+
335
+ ## License
336
+
337
+ MIT License
338
+
339
+ ## Support
340
+
341
+ - **Repository**: [https://github.com/ghpascon/smartx_rfid](https://github.com/ghpascon/smartx_rfid)
342
+ - **Issues**: [GitHub Issues](https://github.com/ghpascon/smartx_rfid/issues)
343
+ - **Email**: [gh.pascon@gmail.com](mailto:gh.pascon@gmail.com)
344
+
@@ -0,0 +1,310 @@
1
+ # SmartX RFID
2
+
3
+ ![Python Version](https://img.shields.io/badge/python-3.11+-blue.svg)
4
+ ![Version](https://img.shields.io/badge/version-1.5.0-green.svg)
5
+ ![License](https://img.shields.io/badge/license-MIT-blue.svg)
6
+
7
+ Python library for RFID device integration and data management.
8
+
9
+ ## Installation
10
+
11
+ ```bash
12
+ pip install smartx-rfid
13
+ ```
14
+
15
+ ## Quick Start
16
+
17
+ ```python
18
+ from smartx_rfid.devices import X714
19
+ import asyncio
20
+
21
+ async def on_tag_read(name: str, tag_data: dict):
22
+ print(f"Tag: {tag_data['epc']} | RSSI: {tag_data['rssi']}dBm")
23
+
24
+ async def main():
25
+ reader = X714(name="RFID Reader", start_reading=True)
26
+ reader.on_event = lambda name, event_type, data: (
27
+ asyncio.create_task(on_tag_read(name, data))
28
+ if event_type == "tag" else None
29
+ )
30
+
31
+ await reader.connect()
32
+
33
+ while True:
34
+ await asyncio.sleep(1)
35
+
36
+ asyncio.run(main())
37
+ ```
38
+
39
+ ## Features
40
+
41
+ ### Supported Devices
42
+ - **X714 RFID Reader** - Serial, TCP, Bluetooth LE connections
43
+ - **R700 IOT** - HTTP REST API integration
44
+ - **Generic Serial/TCP** - Custom protocol support
45
+
46
+ ### Core Components
47
+ - **Device Management** - Async communication with auto-reconnection
48
+ - **Database Integration** - SQLAlchemy with multiple database support
49
+ - **Webhook System** - HTTP notifications with retry logic
50
+ - **Tag Management** - Thread-safe tag list with deduplication
51
+
52
+ ## Device Examples
53
+
54
+ ### X714 RFID Reader
55
+
56
+ ```python
57
+ from smartx_rfid.devices import X714
58
+
59
+ # Serial connection (auto-detect)
60
+ reader = X714(name="X714-Serial")
61
+
62
+ # TCP connection
63
+ reader = X714(
64
+ name="X714-TCP",
65
+ connection_type="TCP",
66
+ ip="192.168.1.100"
67
+ )
68
+
69
+ # Bluetooth LE
70
+ reader = X714(
71
+ name="X714-BLE",
72
+ connection_type="BLE"
73
+ )
74
+
75
+ def on_event(name: str, event_type: str, data: dict):
76
+ if event_type == "tag":
77
+ print(f"EPC: {data['epc']}, Antenna: {data['ant']}")
78
+
79
+ reader.on_event = on_event
80
+ await reader.connect()
81
+ ```
82
+
83
+ ### R700 IOT Reader
84
+
85
+ ```python
86
+ from smartx_rfid.devices import R700_IOT, R700_IOT_config_example
87
+
88
+ reader = R700_IOT(
89
+ name="R700-Reader",
90
+ ip="192.168.1.200",
91
+ config=R700_IOT_config_example
92
+ )
93
+
94
+ reader.on_event = on_event
95
+ await reader.connect()
96
+ ```
97
+
98
+ ## Database Integration
99
+
100
+ ```python
101
+ from smartx_rfid.db import DatabaseManager
102
+ from sqlalchemy import Column, String, Float, Integer, DateTime
103
+ from sqlalchemy.orm import DeclarativeBase
104
+ from datetime import datetime
105
+
106
+ class Base(DeclarativeBase):
107
+ pass
108
+
109
+ class TagModel(Base):
110
+ __tablename__ = 'rfid_tags'
111
+
112
+ id = Column(Integer, primary_key=True)
113
+ epc = Column(String(50), unique=True, nullable=False)
114
+ tid = Column(String(50))
115
+ ant = Column(Integer)
116
+ rssi = Column(Float)
117
+ created_at = Column(DateTime, default=datetime.utcnow)
118
+
119
+ # Initialize database
120
+ db = DatabaseManager("sqlite:///rfid_tags.db")
121
+ db.register_models(TagModel)
122
+ db.create_tables()
123
+
124
+ # Use with sessions
125
+ with db.get_session() as session:
126
+ tag = TagModel(epc="E200001175000001", ant=1, rssi=-45.2)
127
+ session.add(tag)
128
+
129
+ # Raw SQL queries
130
+ results = db.execute_query_fetchall(
131
+ "SELECT * FROM rfid_tags WHERE rssi > :threshold",
132
+ params={"threshold": -50}
133
+ )
134
+ ```
135
+
136
+ ### Supported Databases
137
+ - PostgreSQL: `postgresql://user:pass@localhost/db`
138
+ - MySQL: `mysql+pymysql://user:pass@localhost/db`
139
+ - SQLite: `sqlite:///path/to/database.db`
140
+
141
+ ## Webhook Integration
142
+
143
+ ```python
144
+ from smartx_rfid.webhook import WebhookManager
145
+
146
+ webhook = WebhookManager("https://api.example.com/rfid-events")
147
+
148
+ # Send tag data
149
+ success = await webhook.post("device_01", "tag_read", {
150
+ "epc": "E200001175000001",
151
+ "rssi": -45.2,
152
+ "antenna": 1,
153
+ "timestamp": "2026-01-15T10:30:00Z"
154
+ })
155
+
156
+ if success:
157
+ print("Webhook sent successfully")
158
+ ```
159
+
160
+ ## Tag Management
161
+
162
+ ```python
163
+ from smartx_rfid.utils import TagList
164
+
165
+ # Create thread-safe tag list
166
+ tags = TagList(unique_identifier="epc")
167
+
168
+ def on_tag(device: str, tag_data: dict):
169
+ new_tag, tag = tags.add(tag_data, device=device)
170
+
171
+ if new_tag:
172
+ print(f"New tag: {tag['epc']}")
173
+ # Add custom data
174
+ tag['product_name'] = "Widget ABC"
175
+ else:
176
+ print(f"Existing tag: {tag['epc']}")
177
+
178
+ # Use with device events
179
+ reader.on_event = lambda name, event_type, data: (
180
+ on_tag(name, data) if event_type == "tag" else None
181
+ )
182
+ ```
183
+
184
+ ## Complete Integration Example
185
+
186
+ ```python
187
+ import asyncio
188
+ from smartx_rfid.devices import X714
189
+ from smartx_rfid.db import DatabaseManager
190
+ from smartx_rfid.webhook import WebhookManager
191
+ from smartx_rfid.utils import TagList
192
+
193
+ async def rfid_system():
194
+ # Initialize components
195
+ reader = X714(name="Production-Scanner", start_reading=True)
196
+ db = DatabaseManager("postgresql://localhost/rfid_production")
197
+ webhook = WebhookManager("https://api.internal.com/rfid")
198
+ tags = TagList()
199
+
200
+ async def process_tag(name: str, tag_data: dict):
201
+ # Check if new tag
202
+ new_tag, tag = tags.add(tag_data, device=name)
203
+
204
+ if new_tag:
205
+ # Save to database
206
+ with db.get_session() as session:
207
+ session.add(TagModel(**tag_data))
208
+
209
+ # Send notification
210
+ await webhook.post(name, "new_tag", tag_data)
211
+ print(f"New tag processed: {tag_data['epc']}")
212
+
213
+ reader.on_event = lambda n, t, d: (
214
+ asyncio.create_task(process_tag(n, d)) if t == "tag" else None
215
+ )
216
+
217
+ await reader.connect()
218
+
219
+ asyncio.run(rfid_system())
220
+ ```
221
+
222
+ ## Configuration
223
+
224
+ ### Device Configuration
225
+ ```python
226
+ # High-performance settings
227
+ reader = X714(
228
+ name="FastScanner",
229
+ read_power=30, # Max power
230
+ session=2, # Session config
231
+ read_interval=100 # Fast scanning
232
+ )
233
+
234
+ # Database with connection pooling
235
+ db = DatabaseManager(
236
+ database_url="postgresql://user:pass@localhost/db",
237
+ pool_size=10,
238
+ max_overflow=20,
239
+ echo=True # Enable SQL logging
240
+ )
241
+ ```
242
+
243
+ ### Logging Setup
244
+ ```python
245
+ import logging
246
+
247
+ logging.basicConfig(
248
+ level=logging.INFO,
249
+ format="%(asctime)s - %(name)s - %(levelname)s - %(message)s"
250
+ )
251
+ ```
252
+
253
+ ## API Reference
254
+
255
+ ### Core Modules
256
+ - `smartx_rfid.devices` - Device communication classes
257
+ - `smartx_rfid.db` - Database management
258
+ - `smartx_rfid.webhook` - HTTP notification system
259
+ - `smartx_rfid.utils` - Utility classes and helpers
260
+
261
+ ### Event System
262
+ All devices use a consistent event callback system:
263
+
264
+ ```python
265
+ def on_event(device_name: str, event_type: str, event_data: dict):
266
+ """
267
+ Event types:
268
+ - "connected": Device connected successfully
269
+ - "disconnected": Device disconnected
270
+ - "tag": RFID tag detected
271
+ - "error": Error occurred
272
+ """
273
+ pass
274
+
275
+ device.on_event = on_event
276
+ ```
277
+
278
+ ## Examples
279
+
280
+ The `examples/` directory contains working examples for all supported devices and features:
281
+
282
+ ```
283
+ examples/
284
+ ├── devices/
285
+ │ ├── RFID/ # X714, R700_IOT examples
286
+ │ └── generic/ # Serial, TCP examples
287
+ ├── db/ # Database integration examples
288
+ └── utils/ # Tag management examples
289
+ ```
290
+
291
+ Run examples:
292
+ ```bash
293
+ python examples/devices/RFID/X714_SERIAL.py
294
+ python examples/db/showcase.py
295
+ ```
296
+
297
+ ## Requirements
298
+
299
+ - Python 3.11+
300
+ - Dependencies automatically installed with pip
301
+
302
+ ## License
303
+
304
+ MIT License
305
+
306
+ ## Support
307
+
308
+ - **Repository**: [https://github.com/ghpascon/smartx_rfid](https://github.com/ghpascon/smartx_rfid)
309
+ - **Issues**: [GitHub Issues](https://github.com/ghpascon/smartx_rfid/issues)
310
+ - **Email**: [gh.pascon@gmail.com](mailto:gh.pascon@gmail.com)
@@ -1,6 +1,6 @@
1
1
  [tool.poetry]
2
2
  name = "smartx-rfid"
3
- version = "1.0.0"
3
+ version = "1.7.4"
4
4
  description = "SmartX RFID library"
5
5
  authors = ["Gabriel Henrique Pascon <gh.pascon@gmail.com>"]
6
6
  license = "MIT"
@@ -26,6 +26,9 @@ pyepc = "0.5.0"
26
26
  httpx = "0.28.1"
27
27
  bleak = "^1.1.1"
28
28
  pydantic = "^2.12.5"
29
+ sqlalchemy = "2.0.29"
30
+ pymysql = "1.1.1"
31
+ psycopg2 = "^2.9.11"
29
32
 
30
33
  [tool.poetry.group.dev.dependencies]
31
34
  pytest = "^7.4.0"
@@ -3,7 +3,7 @@
3
3
  from importlib.metadata import version
4
4
 
5
5
  try:
6
- __version__ = version("publish-lib-example")
6
+ __version__ = version("smartx_rfid")
7
7
  except Exception:
8
8
  # Fallback for development environments
9
9
  __version__ = "0.0.0-dev"
@@ -0,0 +1,9 @@
1
+ from smartx_rfid.utils import regex_hex
2
+ import logging
3
+
4
+
5
+ def rchlo_get_sku_from_epc(epc: str):
6
+ if not regex_hex(epc, 24):
7
+ logging.warning(f"Invalid EPC format: {epc}")
8
+ return None
9
+ return epc[3:14]
@@ -0,0 +1 @@
1
+ from ._main import DatabaseManager