StarMgsIO iOS SDK Ver 1.5.0

Overview

This package contains StarMgsIO iOS SDK Ver 1.5.0.
StarMgsIO.xcframework is a framework for supporting application development for Star scales.

  1. Contents
  2. Scope
  3. Installation
  4. Bridging-Header
  5. API
    1. STARDeviceManager
    2. STARDeviceManagerDelegate
    3. STARScale
    4. STARScaleDelegate
    5. STARScaleSetting
    6. STARScaleData
    7. STARUnit
    8. STARComparatorResult
    9. STARScaleType_ENUM
    10. STARScaleType
    11. STARDataType
    12. STARStatus
    13. STARErrorCode
  6. Copyright
  7. Release History
  1. Contents
  2. Scope
  3. Installation
  4. API
    1. STARDeviceManager
    2. STARDeviceManagerDelegate
    3. STARScale
    4. STARScaleSetting
    5. STARScaleData
    6. STARUnit
    7. STARComparatorResult
    8. STARScaleDelegate
    9. STARScaleType_ENUM
    10. STARScaleType
    11. STARDataType
    12. STARStatus
    13. STARErrorCode
  5. Copyright
  6. Release History

Contents


MG_series_Scale_StarMgsIO_iOS_SDK_V1_5_0/
├── Documents/
│   └── readme.url                      // Link to release Notes
├── SDK/
│   └── Star_MgsIO_SDK.xcodeproj        // Sample App(Ver.1.5.0)
├── StarMgsIO.xcframework               // StarMgsIO(Ver.1.5.0)
├── Package.swift
└── SoftwareLicenseAgreement_En.pdf     // Software License Agreement

    

Scope

Supported models :

Supported OS :

Supported Xcode :

Installation

StarMgsIO SDK library supports Swift Package Manager and Framework. Please link library that suits your application configuration.

Use Swift Package Manager

In order to integrate the StarMgsIO framework into your iOS application, Use Swift Package Manager.

  1. In Xcode, select File menu > Add Packages....
  2. Enter https://github.com/star-micronics/StarMgsIO-SDK-iOS-Swift in the URL input field.
  3. Select StarMgsIO-iOS-SDK and press Add Package button.
    For more information on how to integrate Swift Package, please refer to the following URL.

https://developer.apple.com/documentation/swift_packages/adding_package_dependencies_to_your_app

Use Framework

  1. Open the project file by Xcode.

  2. Select target from "TARGETS" in project setting view.

  3. Select "Build Phases" and click '+' button in "Link Binary with Libraries".

    setting

  4. Click "Add Other ..." button and select StarMgsIO.framework from the file dialog.

Add Objective-C Bridging Header

Development with Swift

StarMgsIO Framework is written in Objective-C. To use them in Swift, you need to add Objective-C Bridging-Header to your project.

  1. Select File – New – File… from Xcode menu.
  2. Select the Header File , and then click Next .
  3. Enter a name and click Create to create an empty header file. In the example shown below, the header file name is “Star_MgsIO_SDK-Bridging-Header.h”.
  4. Write the following import lines in the header file created.
    #import <StarMgsIO/StarMgsIO.h>
  5. Specify the path to the created header file at Objective-C Bridging Header of Build Settings.

API

STARDeviceManager

This class is used to manage a scale.

Shared accessory manager
open class func StarDeviceManager()
Public properties and methods
- void scanForScales()
Start scanning scales.
- void stopScan()
Stop scanning scales.
- void connectScale(STARScale scale)
Connect to a scale and set delegate to notify the communication result with it. The result will be notified to delegate object.
- void connectScaleWithIdentifier (String identifier)
Connect to a scale and set delegate to notify the communication result with it. The result will be notified to delegate object.
identifier: The UUID that can be obtained from the identifier property of the STARScale object.
- void disconnectScale(STARScale scale)
Disconnect a scale.
The result will be notified to delegate object.
- String versionString
Get StarMgsIO.framework version name.
- STARDeviceManagerDelegate delegate
Delegate object to receive the results of methods.

STARDeviceManagerDelegate

This protocol is used to receive the result of processes done in the STARDeviceManager class.

Public methods
func manager(_ manager: STARDeviceManager, didDiscover scale: STARScale?, error: Error?)
Notify the execution result of scanForScales method of STARDeviceManager class.
func manager(_ manager: STARDeviceManager, didConnect scale: STARScale?, error: Error?)
Notify the execution result of connectScale: method of STARDeviceManager class.
func manager(_ manager: STARDeviceManager, didDisconnectScale scale: STARScale?, error: Error?)
Notify the execution result of disconnectScale: method of STARDeviceManager class or physical disconnection.

STARScale

This class is used to communicate with a scale.

Public properties and methods
String name?
The name of the scale.
String identifier?
The identifier(UUID) of the scale.
ScaleType scaleType?
The model of the scale.
STARScaleDelegate delegate?
Delegate object to receive the results of methods.
- void updateSetting:(STARScaleSetting setting)
Change scale settings.
The result will be notified to delegate object.

STARScaleDelegate

This protocol is used to receive the result of processes done in the STARScale class.

Public methods
-func scale(_ scale: STARScale!, didRead scaleData: STARScaleData!, error: Error!)
Notify that weight data is received from a scale.
-func scale(_ scale: STARScale!, didUpdate setting: STARScaleSetting, error: Error!)
Notify execution result of updateSetting method.

STARScaleSetting

This enum is used to specity the scale setting.

Constants
STARScaleSettingZeroPointAdjustment
Zero Point Adjustment

STARScaleData

This class manages weight data received from a scale.

Public properties and methods
Double weight
Weight
STARUnit unit
Unit of weight
STARComparatorResult comparatorResult
Result of comparator function
STARDataType dataType
Type of the data
STARStatus status
Scale status
Int numberOfDecimalPlaces
Number of decimal places of weight
String rawString
Raw string

STARUnit

This enum is used to specify the unit of weight.

Constants
invalid
Invalid value
MG
Milligram
G
Gram
CT
Carat
MOM
Momme
OZ
Ounce
LB
Pound
OZT
Troy ounce
DWT
Penny weight
GN
Grain
TLH
Hong Kong tael
TLS
Singapore tael
TLT
Taiwan tael
TO
Tola
MSG
Mesghal
BAT
Baht
PCS
Parts counting
percent
Percentage weighing
coefficient
Multiplied by Coefficient

STARComparatorResult

This enum is used to specify the result of comparator function.

Constants
invalid
Invalid value
shortage
Shortage
proper
Proper
over
Over

STARScaleType_ENUM

This enum is used to specify the scale type.

Constants
Invalid
Invalid value
MGS
MG-S322,MG-S1501,MG-S8200,MG-S322 USCA, MG-S1501 USCA MG-S8200 USCA
MGTS
MG-T12,MG-T30,MG-T60,MG-T12 UDB,MG-T30 UDB,MG-T60 UDB

STARScaleType

This class is used to determine the scale type.

Public methods
STARScaleType_ENUM getEnum(name:String)
Get the ScaleType of Enum type from the String name (MGS or MGTS).

STARDataType

This enum is used to specify the type of the data.

Constants
invalid
Invalid value
netNotTared
Net weight (not tared)
net
Net weight (tared)
tare
Tare weight
presetTare
Preset tare weight
total
Total value
unit
Unit weight
gross
Gross

STARStatus

This enum is used to specify the status of weight data.

Constants
invalid
Invalid value
stable
Data stable
unstable
Data unstable
error
Data error

STARErrorCode

This enum represents the type of error.

Constants
notAvailableError
The host device does not have the function to connect to a scale.
alreadyConnectedError
Attempt to connect to a scale even though already connected to it.
timeoutError
Operation timed out.
notSupportedError
Attempt to connect to not supported device.
unexpectedError
Operation is failed due to unexpected error.
unexpectedDisconnectionError
Scale is disconnected unexpextedly.
notConnectedError
Attempt to operate a scale even though not connected to it.
requestRejectedError
Change scale settings operation is failed due to request is rejected.

Installation

StarMgsIO SDK library supports Framework. Please link library that suits your application configuration.

Use Framework

  1. Open the project file by Xcode.

  2. Select target from "TARGETS" in project setting view.

  3. Select "Build Phases" and click '+' button in "Link Binary with Libraries".

    setting

  4. Click "Add Other ..." button and select StarMgsIO.framework from the file dialog.

  5. At the beginning of the source code, import the header file as follows.

    #import <StarMgsIO/StarMgsIO.h>

API

STARDeviceManager

This class is used to manage a scale.

Shared accessory manager
+ (STARDeviceManager *)sharedManager;
Return the shared STARDeviceManager object.
Public properties and methods
- (void)scanForScales;
Start scanning scales.
[STARDeviceManager.sharedManager scanForScales];
- (void)stopScan;
Stop scanning scales.
[STARDeviceManager.sharedManager stopScan];
- (void)connectScale:(nonnull STARScale *)scale;
Connect to a scale and set delegate to notify the communication result with it. The result will be notified to delegate object.
[STARDeviceManager.sharedManager connectScale:selectedScale];
- (void)connectScaleWithIdentifier:(nonnull NSString *)identifier;
Connect to a scale and set delegate to notify the communication result with it. The result will be notified to delegate object.
identifier: The UUID that can be obtained from the identifier property of the STARScale object.
[STARDeviceManager.sharedManager connectScaleWithIdentifier:selectedScale.identifier];
- (void)disconnectScale:(nonnull STARScale *)scale;
Disconnect a scale.
The result will be notified to delegate object.
[STARDeviceManager.sharedManager disconnectScale:_scale];
@property(nonatomic, readonly) NSString *versionString;
Get StarMgsIO.xcframework version name.
@property(nonatomic, weak) id<STARDeviceManagerDelegate> delegate;
Delegate object to receive the results of methods.

STARDeviceManagerDelegate

This protocol is used to receive the result of processes done in the STARDeviceManager class.

Public methods
- (void)manager:(nonnull STARDeviceManager *)manager didDiscoverScale:(STARScale *)scale error:(NSError *)error;
Captures the result of the scanForScales() method.
- (void)manager:(STARDeviceManager *)manager didDiscoverScale:(STARScale *)scale error:(NSError *)error {… }
- (void)manager:(nonnull STARDeviceManager *)managerr> didConnectScale:(STARScale *)scale error:(NSError *)error;
Captures the result of the connectScale() method when connecting to a STARScale object.
- (void)manager:(STARDeviceManager *)manager didConnectScale:(STARScale *)scale error:(NSError *)error {… }
- (void)manager:(nonnull STARDeviceManager *)manager didDisconnectScale:(STARScale *)scale error:(NSError *)error;
Delegate method is notified when a STARScale object is disconnected using disconnectScale() method or when BLE connection is lost.
- (void)manager:(STARDeviceManager *)manager didDisconnectScale:(STARScale *)scale error:(NSError *)error {
if (error) {
NSLog(@"%@", error.localizedDescription);
}

if (_disconnectionHandler != nil) {
_disconnectionHandler();
}
}

STARScale

This class is used to communicate with a scale.

Public properties and methods
@property(nonatomic, readonly) NSString * _Nullable name;
The name of the scale.
@property(nonatomic, readonly) NSString * _Nullable identifier;
The identifier(UUID) of the scale.
@property(nonatomic, readonly) STARScaleType_ENUM scaleType;
The model of the scale.
@property(nonatomic, weak) id<STARScaleDelegate> _Nullable delegate;
Delegate object to receive the results of methods.
- (void)updateSetting:(STARScaleSetting)setting;
Change scale settings.
The result will be notified to delegate object.

STARScaleDelegate

This protocol is used to receive the result of processes done in the STARScale class.

Public methods
- (void)scale:(STARScale *)scale didReadScaleData:(STARScaleData *)scaleData error:(NSError *)error;
Notify that weight data is received from a scale.
- (void)scale:(STARScale *)scale didUpdateSetting:(STARScaleSetting)setting error:(NSError *)error;
Notify execution result of updateSetting method.

STARScaleSetting

This enum is used to specity the scale setting.

Constants
STARScaleSettingZeroPointAdjustment
Zero Point Adjustment

STARScaleData

This class manages weight data received from a scale.

Public properties and methods
@property(nonatomic, readonly) double weight;
Weight
@property(nonatomic, readonly) STARUnit unit;
Unit of weight
@property(nonatomic, readonly) STARComparatorResult comparatorResult;
Result of comparator function
@property(nonatomic, readonly) STARDataType dataType;
Type of the data
@property(nonatomic, readonly) STARStatus status;
Scale status
@property(nonatomic, readonly) NSInteger numberOfDecimalPlaces;
Number of decimal places of weight
@property(nonatomic, readonly) NSString *rawString;
Raw string

STARUnit

This enum is used to specify the unit of weight.

Constants
STARUnitInvalid
Invalid value
STARUnitMG
Milligram
STARUnitG
Gram
STARUnitKG
Kilogram
STARUnitCT
Carat
STARUnitMOM
Momme
STARUnitOZ
Ounce
STARUnitLB
Pound
STARUnitOZT
Troy ounce
STARUnitDWT
Penny weight
STARUnitGN
Grain
STARUnitTLH
Hong Kong tael
STARUnitTLS
Singapore tael
STARUnitTLT
Taiwan tael
STARUnitTO
Tola
STARUnitMSG
Mesghal
STARUnitBAT
Baht
STARUnitPCS
Parts counting
STARUnitPercent
Percentage weighing
STARUnitCoefficient
Multiplied by Coefficient

STARComparatorResult

This enum is used to specify the result of comparator function.

Constants
STARComparatorResultInvalid
Invalid value
STARComparatorResultShortage
Shortage
STARComparatorResultProper
Proper
STARComparatorResultOver
Over

STARScaleType_ENUM

This enum is used to specify the scale type.

Constants
Invalid
Invalid value
MGS
MG-S322,MG-S1501,MG-S8200,MG-S322 USCA, MG-S1501 USCA MG-S8200 USCA
MGTS
MG-T12,MG-T30,MG-T60,MG-T12 UDB,MG-T30 UDB,MG-T60 UDB

STARScaleType

This class is used to determine the scale type.

Public methods
+(STARScaleType_ENUM) getEnum:(NSString *)name
Get the ScaleType of Enum type from the String name (MGS or MGTS).

STARDataType

This enum is used to specify the type of the data.

Constants
STARDataTypeInvalid
Invalid value
STARDataTypeNetNotTared
Net weight (not tared)
STARDataTypeNet
Net weight (tared)
STARDataTypeTare
Tare weight
STARDataTypePresetTare
Preset tare weight
STARDataTypeTotal
Total value
STARDataTypeUnit
Unit weight
STARDataTypeGross
Gross

STARStatus

This enum is used to specify the status of weight data.

Constants
STARStatusInvalid
Invalid value
STARStatusStable
Data stable
STARStatusUnstable
Data unstable
STARStatusError
Data error

STARErrorCode

This enum represents the type of error and is used for the code property of the NSError object.

Constants
STARNotAvailableError
The host device does not have the function to connect to a scale.
STARAlreadyConnectedError
Attempt to connect to a scale even though already connected to it.
STARTimeoutError
Operation timed out.
STARNotSupportedError
Attempt to connect to not supported device.
STARUnexpectedError
Operation is failed due to unexpected error.
STARUnexpectedDisconnectionError
Scale is disconnected unexpextedly.
STARNotConnectedError
Attempt to operate a scale even though not connected to it.
STARRequestRejectedError
Change scale settings operation is failed due to request is rejected.

Copyright 2019 - 2023 Star Micronics Co., Ltd. All rights reserved.

Release History

Ver.1.5.0(US market only)
2023/10/31

Ver.1.3.0(US market only)
2021/12/20

Ver.1.2.0 (US market only)
2019/12/25


Ver.1.0.1 (US market only)
2019/10/11


Ver.1.0.0 (US market only)
2018/06/29