Skip to content

GitLab

  • Menu
Projects Groups Snippets
    • Loading...
  • Help
    • Help
    • Support
    • Community forum
    • Submit feedback
  • Sign in / Register
  • AnW_STA5_SmartLink AnW_STA5_SmartLink
  • Project information
    • Project information
    • Activity
    • Members
  • Packages & Registries
    • Packages & Registries
    • Infrastructure Registry
  • Wiki
    • Wiki
  • Activity
Collapse sidebar
  • Ervin Lan
  • AnW_STA5_SmartLinkAnW_STA5_SmartLink
  • Wiki
  • STA5 SmartLink command guidance

Last edited by delly chen Mar 22, 2023
Page history
This is an old version of this page. You can view the most recent version or browse the history.

STA5 SmartLink command guidance

STA5 SmartLink command guidance

Agenda

  • Requirement
  • APIs
  • SmartLink data format
  • SmartLink data base structure
  • Common Command
    • E_REQ_SUBSCRIBE
    • E_REQ_I_AM_TOP
    • E_REQ_I_AM_TOP for Android Auto
    • E_GET_UP
    • E_GET_DOWN
    • E_REQ_GET_WIFI_STATUS
    • E_RETURN_WIFI_STATUS_ON/E_RETURN_WIFI_STATUS_OFF
  • Device Manager Command
    • E_REQ_GET_DEVICE_INFO
    • E_RETURN_DEVICE_INFO
    • E_DEVICE_PHONE_LINK_ON
    • E_DEVICE_PHONE_LINK_OFF
    • E_UI_PHONE_LINK_BTN
    • E_BT_IAP2_CONNECTED
    • E_BT_IAP2_DISCONNECTED
    • E_UI_POP_WINDOW_PHONE_LINK_CONN
    • E_UI_WINDOW_MSG_BTN_YES/E_UI_WINDOW_MSG_BTN_NO/E_UI_WINDOW_MSG_BTN_CANCEL
    • E_DISCONNECT_IPHONE_BT
  • VIP Socket
    • Android Auto VIP Socket
    • CarPlay VIP Socket

Requirement

  • Platform: STA5

  • The version can be found in sml_def.h, please follow the latest version.

  • Please import below files to your project, they’re under SmartLink build folder:

export
  ├── include
  │   ├── libunixsocket.h
  │   ├── sml_def.h  
  │   └── sml_data_format.h  
  └── libsocket.so

APIs

  • To connect:
ret = sfd = create_unix_stream_socket(TMP_SOCKET_SML, 0);
if (ret < 0) {
    perror(0);
    exit(1);
}
  • Send message:
ret = write(sfd, &send_data, sizeof(send_data));
if (ret < 0) {
    perror(0);
    goto ERR_EXIT;
}
  • Receive message:
ret = bytes = read(sfd, buf, MAX_MESSAGE_READ);
if (ret < 0) {
    perror(0);
    exit(1);
}

SmartLink data format

Data member Date type Data length Description
version unsigned char 1 byte Set to SML_MAJOR_VERSION.
mode unsigned char 1 byte Refer to type REQ_MODE.
AppType unsigned char 1 byte Refer to type APP_TYPE.
state unsigned char 1 byte Refer to type SML_STATE_CODE.
AppClientID unsigned int 4 bytes Client ID.
srcAppName unsigned char[128] 128 bytes Source application name in string.
dstAppName unsigned char[128] 128 bytes Destination application name in string.
cmd unsigned int 4 bytes Refer to type SML_COMMAND.
len unsigned int 4 bytes Total length of message in bytes.

SmartLink data base structure

Data member Date type Data length Description
index int 4 bytes
DeviceName[32] char 32 bytes Phone Name.
usbSerialNumber[32] char 32 bytes USB serial number.
btMacAddress[32] char 32 bytes Bluetooth MAC address.
SupportedAPP int 4 bytess Refer to APP_TYPE.

Common Command

Subscribe

  • From APPs - Client
  • To subscribe the service from SmartLink. Send below message to SmartLink.
Data member Value
version SML_MAJOR_VERSION
mode E_DELEGATE
AppType Refer to type APP_TYPE.
state E_STATE_OK
AppClientID Client ID.
srcAppName Source application name in string.
dstAppName "SML"
cmd E_REQ_SUBSCRIBE
len Total length of message in bytes(288).
  • From SmartLink: No return message.

On Top Notification

  • From APPs - Client
  • Notify SmartLink when APP is on Projection mode. Send below message to SmartLink.
Data member Value
version SML_MAJOR_VERSION
mode E_DELEGATE
AppType Refer to type APP_TYPE.
state E_STATE_OK
AppClientID Client ID.
srcAppName Source application name in string.
dstAppName "SML"
cmd E_REQ_I_AM_TOP
len Total length of message in bytes(288).
  • From SmartLink: No return message.

On Top Notification for Android Auto

  • From AA - Client
  • Notify SmartLink when APP is on Projection mode. Send below message to SmartLink.
Data member Value
version SML_MAJOR_VERSION
mode E_DELEGATE
AppType Refer to type APP_TYPE.
state E_STATE_OK
AppClientID Client ID.
srcAppName "AA"
dstAppName "SML"
cmd E_REQ_I_AM_TOP
len Total length of message in bytes(288+64).
---Outside of 288 bytes---
UsbSerialNumber[32] 32 bytes, the USB serial number of MD.
BtMacAddress[32] 32 bytes, the BT MAC address of MD.
  • From SmartLink: No return message.

Get Up

  • From SmartLink - Server
  • Notify APP to enter Projection mode.
Data member Value
version SML_MAJOR_VERSION
mode E_DELEGATE
AppType Refer to type APP_TYPE.
state E_STATE_OK
AppClientID Client ID.
srcAppName "SML"
dstAppName Received Application name.
cmd E_GET_UP
len Total length of message in bytes(288).

Get Down

  • From SmartLink - Server
  • Notify APP to hide to background.
Data member Value
version SML_MAJOR_VERSION
mode E_DELEGATE
AppType Refer to type APP_TYPE.
state E_STATE_OK
AppClientID Client ID.
srcAppName "SML"
dstAppName Received Application name.
cmd E_GET_DOWN
len Total length of message in bytes(288).

Get WiFi status

  • From APPs - Client
  • To get the Wi-Fi AP status from SmartLink. Send below message to SmartLink.
Data member Value
version SML_MAJOR_VERSION
mode E_DELEGATE
AppType Refer to type APP_TYPE.
state E_STATE_OK
AppClientID Client ID.
srcAppName Source application name in string.
dstAppName "SML"
cmd E_REQ_GET_WIFI_STATUS
len Total length of message in bytes(288).
  • From SmartLink: Returned message, refer next section(Return WiFi status).

Return WiFi status

  • From SmartLink - Server
  • Wi-Fi AP status returned from SmartLink:
    • E_RETURN_WIFI_STATUS_ON means Wi-Fi AP is on and ready.
    • E_RETURN_WIFI_STATUS_OFF means Wi-Fi AP is off and not ready.
Data member Value
version SML_MAJOR_VERSION
mode E_DELEGATE
AppType Refer to type APP_TYPE.
state E_STATE_OK
AppClientID Client ID.
srcAppName "SML"
dstAppName Received Application name.
cmd E_RETURN_WIFI_STATUS_ON/E_RETURN_WIFI_STATUS_OFF
len Total length of message in bytes(288).

Device Manager Command

Get device information

  • From APPs - Client
  • To get the device info from SmartLink. Send below message to SmartLink.
Data member Value
version SML_MAJOR_VERSION
mode E_DELEGATE
AppType Refer to type APP_TYPE.
state E_STATE_OK
AppClientID Client ID.
srcAppName Source application name in string.
dstAppName "SML"
cmd E_REQ_GET_DEVICE_INFO
len Total length of message in bytes(288+6).
---Outside of 288 bytes---
BtMacAddress[6] 6 bytes, the BT MAC address of MD.
  • From SmartLink: Returned message, refer next page(Return device information).

Return device information

  • From SmartLink - Server
  • The device info returned from SmartLink.
Data member Value
version SML_MAJOR_VERSION
mode E_DELEGATE
AppType Refer to type APP_TYPE.
state E_STATE_OK
AppClientID Client ID.
srcAppName "SML"
dstAppName Received Application name
cmd E_RETURN_DEVICE_INFO
len Total length of message in bytes(288+10).
---Outside of 288 bytes---
BtMacAddress[6] 6 bytes, the BT MAC address from E_REQ_GET_DEVICE_INFO command.
SupportedAPP 4 bytes, refer to APP_TYPE.

Device Phone Link ON

  • From SmartLink - Server
  • The device Phone Link status is ON.
Data member Value
version SML_MAJOR_VERSION
mode E_DELEGATE
AppType Refer to type APP_TYPE.
state E_STATE_OK
AppClientID Client ID.
srcAppName "SML"
dstAppName Received Application name
cmd E_DEVICE_PHONE_LINK_ON
len Total length of message in bytes(288+10).
---Outside of 288 bytes---
BtMacAddress[6] 6 bytes, the BT MAC address of MD.
SupportedAPP 4 bytes, refer to APP_TYPE.

Device Phone Link OFF

  • From SmartLink - Server
  • The device Phone Link status is OFF.
Data member Value
version SML_MAJOR_VERSION
mode E_DELEGATE
AppType Refer to type APP_TYPE.
state E_STATE_OK
AppClientID Client ID.
srcAppName "SML"
dstAppName Received Application name
cmd E_DEVICE_PHONE_LINK_OFF
len Total length of message in bytes(288+10).
---Outside of 288 bytes---
BtMacAddress[6] 6 bytes, the BT MAC address of MD.
SupportedAPP 4 bytes, refer to APP_TYPE.

UI Phone Link software button

  • From UI - Client
  • The Phone Link software button pressed, need to notify SmartLink.
Data member Value
version SML_MAJOR_VERSION
mode E_DELEGATE
AppType Refer to type APP_TYPE.
state E_STATE_OK
AppClientID Client ID.
srcAppName Source application name in string.
dstAppName "SML"
cmd E_UI_PHONE_LINK_BTN
len Total length of message in bytes(288+6).
---Outside of 288 bytes---
BtMacAddress[6] 6 bytes, the BT MAC address of MD.
  • From SmartLink: No return message.

iAP2 connected

  • From BTSRV - Client
  • When iAP2 connected, need to notify SmartLink.
Data member Value
version SML_MAJOR_VERSION
mode E_DELEGATE
AppType Refer to type APP_TYPE.
state E_STATE_OK
AppClientID Client ID.
srcAppName Source application name in string.
dstAppName "SML"
cmd E_BT_IAP2_CONNECTED
len Total length of message in bytes(288+10).
---Outside of 288 bytes---
BtMacAddress[6] 6 bytes, the BT MAC address of MD.
iAP2SessionHandle 4 bytes int. Represents a handle of iAP2 Session over bluetooth.
  • From SmartLink: No return message.

iAP2 disconnected

  • From BTSRV - Client
  • When iAP2 disconnected, need to notify SmartLink.
Data member Value
version SML_MAJOR_VERSION
mode E_DELEGATE
AppType Refer to type APP_TYPE.
state E_STATE_OK
AppClientID Client ID.
srcAppName Source application name in string.
dstAppName "SML"
cmd E_BT_IAP2_DISCONNECTED
len Total length of message in bytes(288+10).
---Outside of 288 bytes---
BtMacAddress[6] 6 bytes, the BT MAC address of MD.
iAP2SessionHandle 4 bytes int. Represents a handle of iAP2 Session over bluetooth.
  • From SmartLink: No return message.

Pop a window for Phone Link

  • From SmartLink - Server
  • Call UI to pop a window for user confirm if Phone Link connection is allowed or not.
Data member Value
version SML_MAJOR_VERSION
mode E_DELEGATE
AppType Refer to type APP_TYPE.
state E_STATE_OK
AppClientID Client ID.
srcAppName "SML"
dstAppName Received Application name
cmd E_UI_POP_WINDOW_PHONE_LINK_CONN
len Total length of message in bytes(288+10).
---Outside of 288 bytes---
BtMacAddress[6] 6 bytes, the BT MAC address of MD.
SupportedAPP 4 bytes, refer to APP_TYPE.

Pop up window return

  • From UI - Client
  • To return the result of pop up window to SmartLink.
Data member Value
version SML_MAJOR_VERSION
mode E_DELEGATE
AppType Refer to type APP_TYPE.
state E_STATE_OK
AppClientID Client ID.
srcAppName Source application name in string.
dstAppName "SML"
cmd E_UI_WINDOW_MSG_BTN_YES/E_UI_WINDOW_MSG_BTN_NO/E_UI_WINDOW_MSG_BTN_CANCEL
len Total length of message in bytes(288).

Disconnect BT connection with iPhone

  • From SmartLink - Server
  • Call BTSRV to disconnect BT connection with iPhone.
Data member Value
version SML_MAJOR_VERSION
mode E_DELEGATE
AppType Refer to type APP_TYPE.
state E_STATE_OK
AppClientID Client ID.
srcAppName "SML"
dstAppName Received Application name
cmd E_DISCONNECT_IPHONE_BT
len Total length of message in bytes(288+6).
---Outside of 288 bytes---
BtMacAddress[6] 6 bytes, the BT MAC address of MD.

VIP Socket

Android Auto VIP Socket

  • Purpose: For Android Auto resource manager data transfer between Android Auto and SmartLink.
  • The Data type and Data are defined in header file: aa_rsc_mgr.h.
Object Description
Socket Path(defined in sml_def.h) #define TMP_SOCKET_AA_VIP "/tmp/socket_aa_vip"
Message format(From SmartLink) “Ez”+(Total Length of Message)+(Data type)+(Data)+”RCM”
  • Total length of message: 16 bit.
  • Data type: 8 bit.

CarPlay VIP Socket

  • Purpose: For CarPlay resource manager data transfer between CarPlay and SmartLink.
  • The ResourceID and Data are defined in header file: cp_rsc_mgr.h.
Object Description
Socket Path(defined in sml_def.h) #define TMP_SOCKET_CP_VIP "/tmp/socket_cp_vip"
Message format(From SmartLink) (ResourceID)+(Length of Data)+(Data)
  • ResourceID: 32 bit.
  • Length of data: 32 bit.
  • Data: Length of data.
Clone repository
  • APIs
  • STA5 SmartLink command guidance
  • Home