OKM Config API
At a regular interval (see pollingInterval below), OKMs send a request to the /config endpoint of the OKM Service.
The OKM Service will then:
- check if it knows this OKM;
- if so, update the last sync time, last IP, and firmware version of the OKM stored in the database;
- go through the URLs in the okm subscribe_urls.status array and send last sync time, last IP, and firmware version;
- then compare the value of each parameter in the request to what is configured for this OKM;
- If the OKM device isn't found in the system, it gets added to the database. After inserting, it sends a 204 No Content response.
- The resolver compares the data received from the OKM with the data stored in the system.
- If there is a difference, the resolver informs the OKM by sending the updated data, allowing the OKM to update itself.
- If the data matches, no action is taken, and the process moves to the next resolver.
- Resolvers operate sequentially, handling one comparison at a time before proceeding to next resolver
Verb and URL
The URL for the config endpoint that the OKM calls is configurable, though it is hard-coded in the OKM as embeddedv1/kas/config
. Because of this, it is the first URL the OKM will call. At this endpoint, the OKM Service will check what is the configured endpoint for config and return that to the OKM. From then on, the OKM will call this configured endpoint.
By default, the configured endpoint is /api/v1/config .
GET /config/{serialNumber}?kasFirmware={okmFirmwareVersion}&kasDateTime={okmDateTime}&retailCfg={retailConfigType}&configUrl={configURL}&auditUrl={auditURL}&assetList={assetListDigest}&usersAssets={userAssetsDigest}&batchKeyFirmware={batchKeyFirmwareVersion}&wirelessKeyFirmware={loRaKeyFirmwareVersion}&keyCheckoutWindowTime={keyCheckoutWindowTime}&keyCheckoutWindowContact={keyCheckoutWindowContact}&installCode={installerCode}&cacheMode={cacheMode}&pollingInterval={pollingInterval}
Parameters and Query Parameters
Param / Query Param | Type | Description | Action |
---|---|---|---|
serialNumber | InVue Serial Number | Serial number of the OKM making the call. This is used to retrieve the OKM’s info from the database. | None |
kasFirmware | Version Number | Version of the f/w of the calling OKM. If the latest version of the f/w known is more recent than this value, return a URL to fetch the most recent firmware. | Check if the latest firmware is more recent that this value, if it is, a URL is returned to the OKM where it can fetch the latest f/w version. |
kasDateTime | Timestamp | OKM time as a timestamp in millis to synch with the service. | If time in OKM is 5 minutes behind last_sync_time, the service replies with the current time. |
retailCfg | Number | Retail Config Type supported by the OKM. 2 = retailCfg_IR3ZonePlusAudit_e | N/A |
configURL | URL | The URL that the OKM calls for this endpoint. | Currently always returns api/v1/config if the configURL value is different. |
auditURL | URL | The URL that the OKM calls to send audit messages. | Currently always returns api/v1/audit if the auditURL value is different. |
assetList | SHA256 Hash | Hash of the asset list of this OKM. If it doesn’t match what the service has, the service replies with its asset list. | Compare the value received with the value in the database, and if different, return the value in the database. |
usersAssets | SHA256 Hash | Hash of the user asset list of this OKM. If it doesn’t match what the service has, the service replies with its user asset list. | Compare the value received with the value in the database, and if different, return the value in the database. |
batchKeyFirmware | Version Number | Version number of the batch key f/w this OKM contains. If the latest version of the f/w known is more recent than this value, returns a URL to fetch the most recent firmware. | Check if the latest firmware is more recent that this value, if it is, a URL is returned to the OKM where it can fetch the latest f/w version. |
wirelessKeyFirmware | Version Number | Version number of the LoRA key f/w this OKM contains. If the latest version of the f/w known is more recent than this value, returns a URL to fetch the most recent firmware. | Check if the latest firmware is more recent that this value, if it is, a URL is returned to the OKM where it can fetch the latest f/w version. |
keyCheckoutWindowTime | Number | Number of seconds someone has to check out a key. | If it’s different than what’s been configured for this OKM, the new value is returned. |
keyCheckoutWindowContact | String | Type of contact: ”open” = normally open ”closed” = normally closed | If it’s different than what’s been configured for this OKM, the new value is returned. |
installerCode | Number | Installer code of the OKM. Number between 5 and 20 digits. | Not used by the service yet. |
cacheMode | Number | Tell LA the currently configured cacheMode of this OKM. 0 : unknown 1 : disabled 2 : enabled | If it’s different than what’s been configured for this OKM, the new value is returned. |
pollingInterval | Number | Number of seconds between OKM /config calls or idle communications with the OKM Service. Minimum value is 5, and maximum value is 3600. The default is 150. | If it’s different than what’s been configured for this OKM, the new value is returned. |
Details of the /config Endpoint Parsing
When the service receives a config requests from an OKM, it parses the request using a stack of “resolvers”. Each resolver is responsible for evaluating 1 parameter.
The resolvers do not directly change or update anything on the OKM. Their only job is to compare the data sent by the OKM with the data stored in the system.
- If the data matches, the resolver does nothing and moves on to the next resolver.
- If the data doesn't match, the resolver replies to the OKM with the updated data so the OKM can update itself.
The current stack is as follows:
1. OKM Existence Check
- Purpose: Verifies if the OKM exists in the database.
- Operation:
- If the OKM device isn't found in the system, it gets added to the database. After inserting, it sends a
204 No Content response
. - Updates the
last_sync_time
and firmware version in the database.
- If the OKM device isn't found in the system, it gets added to the database. After inserting, it sends a
2. Buffered Message Check
- Purpose: Handles and sends buffered (saved) messages to the OKM if they differ from what is stored in the database.
- Operation:
- Checks if there’s a buffered (saved) message in DB (delete assets message for example).
- If messages exist, send message to the OKM.
3. Firmware Resolver
- Purpose: The firmware resolver is the first step in the resolution process. It ensures the OKM operates on the latest firmware version.
- Operation:
- Checks if the OKM has the most recent firmware version available.
- If there is, returns the URL to the firmware file.
4. Date-Time Resolver
- Purpose: Synchronizes the OKM's date and time with the service by updating it if there is a difference of more than 5 minutes.
- Operation:
- Check if the OKM date and time is synchronized with the service
- If there’s more than a 5 minute difference, returns the current server time.
5. Cache Mode Resolver
- Purpose: Aligns the OKM's cache mode with the configured setting by updating it if there is a difference.
- Operation:
- Compares the OKM cache mode with the one configured.
- If different or unknown, send the currently configured value back to the OKM.
- If
cacheMode
is not supported, then disabled is returned to the OKM.
6. Key Checkout Window Resolver
- Purpose: Synchronizes the OKM's configuration for checkout window time and contact type by updating them if they differ.
- Operation:
- Compares OKM configuration with the settings stored in the database for both check-out window time and contact type.
- If different, send settings to OKM.
7. Retail Config Resolver
- Purpose: Compares the OKM retail configuration with the service and updates the configuration if there is a difference.
- Operation:
- Compares the OKM retail configuration with the service.
- If auditing is enabled, returns
retailCfg_IR3ZonePlusAudit_e
to the OKM.
8. Asset List Resolver
- Purpose: Compares the OKM's asset list with the service's version.
- Operation:
- Compares the received asset list digest with the service version.
- If mismatched, return the new asset list to the OKM.
9. User Assets Resolver
- Purpose: Verifies the OKM's user-specific asset list against the service's version.
- Operation:
- Compares the user asset list digest received with the one from the service.
- If different, return the new user asset list to the OKM.
10. Audit URL Resolver
- Purpose: Checks the auditUrl and updates it if it is missing or incorrect.
- Operation:
- If
auditUrl
is missing or incorrect or it is not/api/v1/audit
, return/api/v1/audit
. - While this resolver doesn’t seem to do anything useful because the return value is pre-defined for now, it allows us to return a different audit URL if needed.
- If
11. Polling Interval Resolver
- Purpose: Checks if the OKM's polling interval matches the service's setting.
- Operation:
- Compares the OKM's polling interval with the one configured.
- If different or unknown, send currently configured value back to the OKM.
12. Batch Key Firmware Resolver
- Purpose: Checks for differences in batch key firmware versions.
- Operation:
- Checks if there is a more recent batch key firmware version.
- If available, returns the firmware file URL.
13. Wireless Key Firmware Resolver
- Purpose: Validates the wireless key firmware version on the OKM.
- Operation:
- Checks if the most recent wireless key firmware version available.
- If available, returns the firmware file URL.