Rental, release and return
The protocol separates selection, payment, physical release, return detection and server acknowledgement. Do not collapse them into one success state.
Shared rental result fields
Device selection/release responses carry:
result,slotId,powerBankId,battery,lockState,fastCharge
result | Meaning |
|---|---|
0 | No eligible power bank / selection failed |
1 | Selection or release succeeded for the current command stage |
2 | Lock is open; waiting for user pickup |
100 | User did not remove the power bank before timeout; lock closed |
110 | Unlock failed; slot is placed at lowest rental priority until restart |
fastCharge: 0 normal, 1 22 W, 2 unknown, 3 45 W, 4 65 W.
The cabinet caches the most recent result by order ID. A retry of the same command with the same order ID must return the cached result instead of creating a second release.
BW: prepare a rental
Use BW before payment to ask the cabinet to select an eligible power bank without releasing it.
Downlink: {BW,messageId,orderId,<rentalProfile>,crc}
Uplink without rentalProfile: {BW,sameMessageId,orderId,result,slotId,powerBankId,battery,lockState,fastCharge,crc}
Uplink with rentalProfile on the v1.51 source profile: {KW,sameMessageId,orderId,result,slotId,powerBankId,battery,lockState,fastCharge,crc}
Downlink acknowledgement: {BR,newMessageId,orderId,crc}
rentalProfile may be omitted; 0 requests a normal power bank and 1 requests a fast-charge power bank.
The v1.51 source profile names the reply KW when the optional rental profile is present, but BW when it is absent. Implementers should accept both reply names for the same order ID and record the selected device profile. Do not silently change the emitted device behavior before UAT.
After preparation, the server must send BR with a new message ID within 30 seconds. This confirms the prepared result; it does not prove physical release. If the window expires, use FB after payment to trigger release.
KW: prepare a fast-charge rental
Downlink: {KW,messageId,orderId,rentalProfile,crc}
Uplink selection: {KW,sameMessageId,orderId,result,slotId,powerBankId,battery,lockState,fastCharge,crc}
Downlink selection acknowledgement: {BR,newMessageId,orderId,crc}
Uplink after physical release: {FB,sameMessageId,orderId,result,slotId,powerBankId,battery,lockState,fastCharge,crc}
Downlink release acknowledgement: {BR,newMessageId,orderId,crc}
rentalProfile=0 requests normal and 1 requests fast charge. The final physical outcome is still reported with FB.
FB: release a power bank
Downlink: {FB,messageId,orderId,slotId,crc}
Uplink: {FB,sameMessageId,orderId,result,slotId,powerBankId,battery,lockState,fastCharge,crc}
Downlink acknowledgement: {BR,newMessageId,orderId,crc}
Use a positive slotId to release that slot. The v1.51 source wording for slotId=0 is ambiguous; treat it as automatic selection only after the exact cabinet profile passes UAT. Production servers should prefer the positive slot selected by BW or KW.
Inventory is updated after the FB physical outcome, not after payment and not after preparation.
BR: rental acknowledgement
{BR,newMessageId,orderId,crc}
BR acknowledges either the prepared selection or the final FB result, depending on the current order stage. Requirements:
- Use the same order ID.
- Use a new monotonically increasing message ID.
- Persist which stage is being acknowledged.
- Acknowledge duplicate device results idempotently.
- Do not mark a rental active until an accepted physical release result exists.
Recommended payment-safe flow
- Create one order ID.
- Send
BWorKW. - Validate and store the selection response.
- Send
BRwith a new message ID within 30 seconds. - Present payment only after an eligible selection exists.
- When payment is accepted, send
FBwith the selected positive slot. - Store the
FBphysical result and send anotherBR. - Mark the rental active only for an accepted release result.
- If payment succeeded but release did not, enter the configured refund/reconciliation path.
If no preparation reply arrives within five seconds, the UI may offer a retry using the same order ID. If the user abandons the flow, cancel that order ID. Never generate a fresh order ID for a blind retry.
RS: return report
Although the v1.51 format line omits deviceId, its examples and field definitions include it. The interoperable normalized form is:
Uplink: {RS,lastMessageId,deviceId,result,slotId,powerBankId,battery,lockState,fastCharge,crc}
Downlink acknowledgement: {RS,newMessageId,slotNumber,confirmCode,crc}
result | Meaning |
|---|---|
0 | Return failed |
1 | Return detected successfully |
2 | Return occurred while the cabinet was offline |
| Acknowledgement field | Meaning |
|---|---|
slotNumber>0 | Confirm one slot |
slotNumber=0 | Batch confirmation mode |
confirmCode=1 | Server accepts the return |
confirmCode=0 | Server marks the return abnormal |
confirmCode=totalSlots with slot 0 | Confirm all slots in the batch |
Before acknowledgement, AC.returnState remains 0. The return is not fully reconciled until the server has accepted it and billing state agrees.
FR: abnormal return report
The normalized form also includes the device ID:
Uplink: {FR,lastMessageId,deviceId,result,slotId,powerBankId,battery,lockState,cableState,crc}
Downlink acknowledgement: {RS,newMessageId,slotNumber,confirmCode,crc}
result | Meaning |
|---|---|
2 | Lock is not fully seated |
4 | Power-bank ID prefix does not match the configured brand |
FR is acknowledged with RS, not FR. Preserve the abnormal reason even after acknowledgement; acknowledgement means “received and classified,” not “hardware is healthy.”