The CertiScan Mobile SDK provides functions to communicate with Med-ic or eCAP. Each function is a command that launches an NFC reader session.
About NFC Reader Sessions
Calling any CertiScan SDK function will start an NFC reader session to detect a Med-ic or eCAP tag.
During the session, the function will perform a specific command on the tag and return JSON. This JSON output contains the command result and the information of the scanned tag.
If the session does not detect a tag within 1 minute, it will time out and return JSON output with error_code: 4003
.
Example A:
NFC Reader session timeout
Output:
{
"command_code" : 1,
"success" : false,
"error_code":4003,
"error_desc":"NFC Reader session timeout."
}
getTagMessage
Retrieve the data from Med-ic or eCAP.
- Swift
- Objective-C
- Kotlin
- Java
import CertiScanSDK
func runGetTagMessageCommand() {
NFCAPIManager.getTagMessage
{ responseJsonString in
if let output = responseJsonString {
print("output = \(output)")
}
}
}
#import <CertiScanSDK/CertiScanSDK-Swift.h>
-(void) runGetTagMessageCommand{
[NFCAPIManager getTagMessageWithCompletionHandler:
^(NSString * _Nullable responseJsonString) {
NSLog(@"output=%@", responseJsonString);
}];
}
import CertiScanSDK.NFCAPIManager;
import CertiScanSDK.NFCReaderStatus;
void runGetTagMessageCommand(){
NFCAPIManager.getTagMessage(MainActivity.this,
new NFCAPIManager.Callback()
{
@Override
public void OnComplete(String output) {
Log.i("CertiScan", "output=" + output);
}
@Override
public void onNFCReaderStatusChanged(NFCReaderStatus status) {
// check the status of NFC reader
}
});
}
import CertiScanSDK.NFCAPIManager
import CertiScanSDK.NFCReaderStatus
fun runGetTagMessageCommand() {
val callback = object : NFCAPIManager.Callback {
override fun OnComplete(responseJsonString: String?) {
Log.i("CertiScan", "output=$responseJsonString")
}
override fun onNFCReaderStatusChanged(status: NFCReaderStatus?) {
// check the status of NFC reader
}
}
NFCAPIManager.getTagMessage(MainActivity.this, callback)
}
output={
"tag_message" : {
"package_id" : "My Package ID",
"patient_id" : "Patient_1",
"tag_events" : [
{
"timestamp" : 1623862993,
"type" : 1
},
{
"timestamp" : 1623862993,
"type" : 2
},
{
"timestamp" : 1623862993,
"type" : 6
}
],
"tag_id" : "500465364-PR2",
"event_count" : 3,
"custom_data_1" : "My Custom Data A",
"scan_time" : 1626789791,
"versioning" : {
"hardware_version" : "1.0.1",
"firmware_version" : "1.1.1.0.0.4.1",
"model" : "Med-ic"
},
"started" : true,
"clock_coefficient_correction" : true
},
"command_code" : 1,
"success" : true
}
start
Start a smart package w/wo grid check, medic configuration, and dynamic buffer uploads.
Parameters | Description |
---|---|
ignoreGridTest | Boolean value to determine if grid check should be ignored. |
gridLineCount | Grid line count for Medic package. Set null for eCAP package or for a Medic package that has already been configured. |
enabledGridLines | An array of the enabled grid line IDs for the Medic package. Set null for eCAP package or for a Medic package that has already been configured. |
packageID | Package ID (Dynamic Buffer) of the smart package. Set to null to prevent modification. |
patientID | Patient ID (Dynamic Buffer) of the smart package. Set to null to prevent modification. |
customData1 | Custom data (Dynamic Buffer) of the smart package. Set to null to prevent modification. |
- Swift
- Objective-C
- Kotlin
- Java
import CertiScanSDK
func runStartCommand() {
// start a Medic package with 23 enabled dose
var enabledGridLineArray = [Int]()
for lineID in 1..<24 {
enabledGridLineArray.append(lineID)
}
NFCAPIManager.start(ignoreGridTest: false,
gridLineCount: 23,
enabledGridLines: enabledGridLineArray,
packageID: "100000001",
patientID: "10001",
customData1: "medic")
{ responseJsonString in
if let output = responseJsonString {
print("output = \(output)")
}
}
}
#import <CertiScanSDK/CertiScanSDK-Swift.h>
-(void) runStartCommand{
// start a Medic package with 23 enabled dose
NSMutableArray *enabledGridLineArray = [NSMutableArray array];
for (int lineID = 1; lineID<24; lineID++){
[enabledGridLineArray addObject:[NSNumber numberWithInt:lineID]];
}
[NFCAPIManager startWithIgnoreGridTest:false
gridLineCount:23
enabledGridLines:enabledGridLineArray
packageID:@"100000001"
patientID:@"10001"
customData1:@"medic"
completionHandler:
^(NSString * _Nullable responseJsonString) {
NSLog(@"output=%@", responseJsonString);
}];
}
import CertiScanSDK.NFCAPIManager;
import CertiScanSDK.NFCReaderStatus;
void runStartCommand(){
// start a Medic package with 23 enabled dose
int[] enabledGridLineArray = new int[23];
for (int i = 0; i < 23; i++) {
enabledGridLineArray[i] = i + 1;
}
NFCAPIManager.start(MainActivity.this,
false,
23,
enabledGridLineArray,
"100000001",
"10001",
"medic",
new NFCAPIManager.Callback() {
@Override
public void OnComplete(String output) {
Log.i("CertiScan", "output=" + output);
}
@Override
public void onNFCReaderStatusChanged(NFCReaderStatus status) {
// check the status of NFC reader
}
});
}
import CertiScanSDK.NFCAPIManager
import CertiScanSDK.NFCReaderStatus
fun runStartCommand() {
val callback = object : NFCAPIManager.Callback {
override fun OnComplete(responseJsonString: String?) {
Log.i("CertiScan", "output=$responseJsonString")
}
override fun onNFCReaderStatusChanged(status: NFCReaderStatus?) {
// check the status of NFC reader
}
}
// start a Medic package with 23 enabled dose
val enabledGridLineArray = IntArray(23)
for (i in 0..22) {
enabledGridLineArray[i] = i + 1
}
NFCAPIManager.start(this,
false,
23,
enabledGridLineArray,
"100000001",
"10001",
"medic",
callback)
}
output={
"tag_message" : {
"package_id" : "100000001",
"custom_data_1" : "medic",
"clock_coefficient_correction" : false,
"patient_id" : "10001",
"event_count" : 0,
"versioning" : {
"hardware_version" : "1.0.1",
"firmware_version" : "1.1.1.0.0.4.1",
"model" : "Med-ic"
},
"started" : true,
"scan_time" : 1628088202,
"tag_id" : "500465357-PR4"
},
"command_code" : 2,
"success" : true
}
stop
Stop a smart package with or without setting a dynamic buffer.
Parameters | Description |
---|---|
packageID | Package ID (Dynamic Buffer) of the smart package. Set to null to prevent modification. |
patientID | Patient ID (Dynamic Buffer) of the smart package. Set to null to prevent modification. |
customData1 | Custom data (Dynamic Buffer) of the smart package. Set to null to prevent modification. |
- Swift
- Objective-C
- Kotlin
- Java
import CertiScanSDK
func runStopCommand() {
// stop
NFCAPIManager.stop(packageID: "100000002",
patientID: "10002",
customData1: "CertiScan")
{ responseJsonString in
if let output = responseJsonString {
print("output = \(output)")
}
}
}
#import <CertiScanSDK/CertiScanSDK-Swift.h>
-(void) runStopCommand{
// stop
[NFCAPIManager stopWithPackageID:@"100000002"
patientID:@"10002"
customData1:@"CertiScan"
completionHandler:
^(NSString * _Nullable responseJsonString) {
NSLog(@"output=%@", responseJsonString);
}];
}
import CertiScanSDK.NFCAPIManager;
import CertiScanSDK.NFCReaderStatus;
void runStopCommand(){
//stop
NFCAPIManager.stop(MainActivity.this,
"100000002",
"10002",
"CertiScan",
new NFCAPIManager.Callback() {
@Override
public void OnComplete(String output) {
Log.i("CertiScan", "output=" + output);
}
@Override
public void onNFCReaderStatusChanged(NFCReaderStatus status) {
// check the status of NFC reader
}
});
}
import CertiScanSDK.NFCAPIManager
import CertiScanSDK.NFCReaderStatus
fun runStopCommand() {
val callback = object : NFCAPIManager.Callback {
override fun OnComplete(responseJsonString: String?) {
Log.i("CertiScan", "output=$responseJsonString")
}
override fun onNFCReaderStatusChanged(status: NFCReaderStatus?) {
// check the status of NFC reader
}
}
//stop
NFCAPIManager.stop(
this,
"100000002",
"10002",
"CertiScan",
callback)
}
output={
"tag_message" : {
"custom_data_1" : "CertiScan",
"event_count" : 0,
"patient_id" : "10002",
"clock_coefficient_correction" : false,
"package_id" : "100000002",
"scan_time" : 1628100362,
"tag_id" : "500465364-PR4",
"versioning" : {
"hardware_version" : "1.0.1",
"firmware_version" : "1.1.1.0.0.4.1",
"model" : "Med-ic"
},
"started" : false
},
"command_code" : 3,
"success" : true
}
setDynamicBuffers
Set Dynamic Buffer(s) of a smart package. The value of each dynamic buffer cannot be an empty string (“”) if multiple Dynamic Buffers are set simultaneously. Use Clear Dynamic Buffers to remove the value of Dynamic Buffer.
Parameters | Description |
---|---|
packageID | Package ID of the smart package. Set to null to prevent modification. |
patientID | Patient ID of the smart package. Set to null to prevent modification. |
customData1 | Custom data of the smart package. Set to null to prevent modification. |
- Swift
- Objective-C
- Kotlin
- Java
import CertiScanSDK
func setDynamicBuffers() {
// set dynamic buffers
NFCAPIManager.setDynamicBuffers(packageID: "100000003",
patientID: "10003",
customData1: nil)
{ responseJsonString in
if let output = responseJsonString {
print("output = \(output)")
}
}
}
#import <CertiScanSDK/CertiScanSDK-Swift.h>
-(void) setDynamicBuffers{
// set dynamic buffers
[NFCAPIManager setDynamicBuffersWithPackageID:@"100000003"
patientID:@"10003"
customData1:NULL
completionHandler:
^(NSString * _Nullable responseJsonString) {
NSLog(@"output=%@", responseJsonString);
}];
}
import CertiScanSDK.NFCAPIManager;
import CertiScanSDK.NFCReaderStatus;
void setDynamicBuffers(){
// set dynamic buffers
NFCAPIManager.setDynamicBuffers(MainActivity.this,
"100000003",
"10003",
null,
new NFCAPIManager.Callback() {
@Override
public void OnComplete(String output) {
Log.i("CertiScan", "output=" + output);
}
@Override
public void onNFCReaderStatusChanged(NFCReaderStatus status) {
// check the status of NFC reader
}
});
}
import CertiScanSDK.NFCAPIManager
import CertiScanSDK.NFCReaderStatus
fun setDynamicBuffers() {
val callback = object : NFCAPIManager.Callback {
override fun OnComplete(responseJsonString: String?) {
Log.i("CertiScan", "output=$responseJsonString")
}
override fun onNFCReaderStatusChanged(status: NFCReaderStatus?) {
// check the status of NFC reader
}
}
// set dynamic buffers
NFCAPIManager.setDynamicBuffers(
this,
"100000003",
"10003",
null,
callback)
}
output={
"tag_message" : {
"tag_id" : "500465364-PR8",
"clock_coefficient_correction" : false,
"package_id" : "100000003",
"versioning" : {
"hardware_version" : "1.0.1",
"firmware_version" : "1.1.1.0.0.4.1",
"model" : "Med-ic"
},
"started" : true,
"event_count" : 0,
"custom_data_1" : "",
"patient_id" : "10003",
"scan_time" : 1628102490
}
"command_code" : 4,
"success" : true
}
clearDynamicBuffers
Clear a Dynamic Buffer for the smart package. Passing the key of Dynamic Buffer to this function will clear the value of the buffer. The keys are list below:
Key | Description |
---|---|
package_id | Package ID of the smart package. |
patient_id | Patient ID of the smart package. |
custom_data_1 | Custom data of the smart package. |
- Swift
- Objective-C
- Kotlin
- Java
import CertiScanSDK
func clearDynamicBuffers() {
// clear dynamic buffers
NFCAPIManager.clearDynamicBuffer("package_id")
{ responseJsonString in
if let output = responseJsonString {
print("output = \(output)")
}
}
}
#import <CertiScanSDK/CertiScanSDK-Swift.h>
-(void) clearDynamicBuffers{
// clear dynamic buffers
[NFCAPIManager clearDynamicBuffer:@"package_id"
completionHandler:
^(NSString * _Nullable responseJsonString) {
NSLog(@"output=%@", responseJsonString);
}];
}
import CertiScanSDK.NFCAPIManager;
import CertiScanSDK.NFCReaderStatus;
void clearDynamicBuffers(){
// clear dynamic buffers
NFCAPIManager.clearDynamicBuffer(MainActivity.this,
"package_id",
new NFCAPIManager.Callback() {
@Override
public void OnComplete(String output) {
Log.i("CertiScan", "output=" + output);
}
@Override
public void onNFCReaderStatusChanged(NFCReaderStatus status) {
// check the status of NFC reader
}
});
}
import CertiScanSDK.NFCAPIManager
import CertiScanSDK.NFCReaderStatus
fun clearDynamicBuffers() {
val callback = object : NFCAPIManager.Callback {
override fun OnComplete(responseJsonString: String?) {
Log.i("CertiScan", "output=$responseJsonString")
}
override fun onNFCReaderStatusChanged(status: NFCReaderStatus?) {
// check the status of NFC reader
}
}
// clear dynamic buffers
NFCAPIManager.clearDynamicBuffer(this,
"package_id",
callback)
}
output={
"tag_message" : {
"tag_id" : "500465364-PR8",
"patient_id" : "10003",
"package_id" : "",
"scan_time" : 1628104567,
"event_count" : 0,
"clock_coefficient_correction" : false,
"versioning" : {
"hardware_version" : "1.0.1",
"firmware_version" : "1.1.1.0.0.4.1",
"model" : "Med-ic"
},
"started" : true,
"custom_data_1" : ""
},
"command_code" : 5,
"success" : true
}