Documente Academic
Documente Profesional
Documente Cultură
SC14DECTIPBS
Web Application Interface (API)
Responsible
KZ
KZ
SC14DECTIPBS
Revision history:
Version
Released
V1.0
13-Dec-11
V1.1
10-Apr-12
Comments
Initial release
Updated commands to reflect latest API
Web API
page 2 of 13
The following string is a typical example of a JSON string used for the DECT IP BS:
[{"cmdType":0,"portId": 1,"packId": 12,"data":[0,1,2]}, {"cmdType":1,"portId":{},"param":[{"paramId":8,"paramValue":1}]
The string is an array (indicated by []) of commands (indicated by comma separated {}). All high level commands
contain the following common elements:
Parameter
cmdType
Description
Identifies command type
portId
Values
0 Data command
1 Configuration command
2 System command
3 User command
7 64
SC14DECTIPBS
1.4
Comments
Web API
page 3 of 13
SC14DECTIPBS
1.5
1.
Data commands are used for holding send and receive data for sensors.
They are issued in the following format:
Packet holding send data:
{ cmdType":"0","portId": "<portId>","EarlyBit":"< EarlyBit >",data:<data>}
Example:
[{"cmdType":0,"portId":1,"data":[49,69,0,1,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0]}]
Example with paging and earlybit set:
[{"cmdType":0,"portId":1," EarlyBit": 1,"data":[49,69,0,1,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0]}]
Packet holding received data:
{ cmdType":"0","portId": "<portId>"," packId":"< packId>"," TimeStmp":"< TimeStmp>", " SensorType":"<
SensorType>", " DataType":"< DataType>", " NextMess":"< NextMess>", data:<data>}
Example:
[{"cmdType":0,"portId":1, >"," packId":12," TimeStmp":2345, " SensorType":49, " DataType":29,
"NextMess":0, "data":[14,15,16,1,1,0,0,0,0,0,0]}]
Fields are numbers and data field is an array of decimal data values.
This command is used to send data to sensors.
Note: Refer to Appendix B for payload format.
Returns JSON string status:
{"cmdType":0,"portId":<portID>,errDesc": UleErrEnum }
UleErrEnum : ULE_Success for success or else refer to APPENDIX A for error type
Important: ULE_Success does not mean that the packet was transmitted successfully. Refer to Appendix C.
Parameter
PortId
PackId
Timestamp
SensorType
DataType
NextMessage
EarlyBit
Values
00-64
0 One message
1 Data continue in next message
0 Paging enabled and send EarlyBit =0
1 Paging enabled and send EarlyBit =1
2 Paging disabled (default value if
omitted)
1 to 56 decimal numbers
00 0xFFFFFFFF
00 0xFFFFFFFF
SENSOR_TYPE_GENERIC = 0x01
ACTUATOR_TYPE_GENERIC = 0x02
MMI_DATA_TYPE_KEEP_AWAKE=0x01
MMI_DATA_TYPE_HAL= 0x13
MMI_DATA_TYPE_WAKEUP_CFG=0x14
Web API
Data
Description
Identifies the portable part from which
the message is send from/to.
Identifies packet number. Used only
when receiving a packet. It is 32 bit
number unique for each sensor
received packet.
Identifies the time in seconds which
the packet got received
Identifies the type of sensor which
send the packet for example (button,
actuator, relay, etc)
Identifies the type of message
(wakeup, alarm, HAL, batterylow,etc)
page 4 of 13
SC14DECTIPBS
2.
Example:
{"cmdType":1,"portId": 1,"paramId":8,"paramValue":1}
Fields are numbers and Param field is an array of JSON paramId/Paramvalue structure.
For write command this command returns:
{"cmdType":1,"portId":<portID>,errDesc": UleErrEnum }
UleErrEnum : ULE_Success for success or else refer to APPENDIX A for error type
Description
Read
/Write
-
Comments
1 Node
status
paramValue:
2 offline
1 online
0 Not registered
2
Message
status
request
3 Tx
Abort
R/W
paramValue:
0)Tx_Buff_Empty
1)Tx_Buff_Empty_TxSuccess, Buffer
empty after last Tx transmition succedded
(RTS received)
2)Tx_Buff_Empty_TxRejected
Buffer empty after last Tx transmition
failed (Reject received)
3)Tx_Buff_Empty_TxAborted
Buffer empty after last Tx transmition
was aborted (Abort command send)
4)Tx_Buff_Full
paramValue: PortID
paramValue:
0x0000-0xFFFF
page 5 of 13
Web API
4 Data
packet
Port parameters
5 Node
communic
ation
timeout [s]
6 Return
data
7- Node
type
8- Node
attribute
9 Latest
event data
10 IPEI
read
R/W
paramValue:
0x0000-0xFFFF
paramValue:
0 Return all data
1 FF: return ALL data starting from
corresponding packId.
SC14DECTIPBS
timeout [s]
Examples:
For every sensor ID get its status value:
{"cmdType":1,"portId":{},"param":[{"paramId":1,"paramValue":{}}]}
For sensor ID=7 get its status value:
{"cmdType":1,"portId":7,"param":[{"paramId":1,"paramValue":{}}]}
For every sensor ID get its type:
{"cmdType":1,"portId": {},"param":[{"paramId":7,"paramValue":{}}]}
For every sensor ID get before how many seconds an activity was recorded:
Web API
{"cmdType":1,"portId": {},"param":[{"paramId":5,"paramValue":{}}]}
For sensor ID=8 set timeout value:
{"cmdType":1,"portId": 8,"param":[{"paramId":5,"paramValue":3600}]}
For sensor ID=8 read its attribute value 0:
{"cmdType":1,"portId": 8,"param":[{"paramId":8,"paramValue":0}]}
April 10, 2012 v1.1
page 6 of 13
SC14DECTIPBS
3.
Description
Read
/Write
Comments
03
Port parameters
0 Set registration
mode
R/W
R/W
2 Deregister
device
paramValue:
1 enable
other disable
paramValue:
0x0000-0xFFFF
paramValue:
0x00 0xFF: portId to
be deregistered.
6 Request SW
version
R
R
R
Web API
Examples:
Read registration mode:
{"cmdType":2,"portId": {},"sysParamType":0,"sysParamValue":{}}
Set registration mode:
April 10, 2012 v1.1
page 7 of 13
SC14DECTIPBS
{"cmdType":2,"portId": {},"sysParamType":0,"sysParamValue":1}
Read access code:
{"cmdType":2,"portId": {},"sysParamType":1,"sysParamValue":{}}
Read system time:
{"cmdType":2,"portId": {},"sysParamType":3,"sysParamValue":{}}
Degister device with ID =8
{"cmdType":2,"portId": {},"sysParamType":3,"sysParamValue":8}
User command (cmdType: 3):
User commands are issued in the following format:
{ cmdType":"3"," UserAppData:<user data json object>}
Example:
{ "cmdType":3," UserAppData ": {user_parameter1:123, user_parameter2:456, user_parameter3:789}}
This command is used as a link between the web and a user application running in IP base station. The UserAppData
field can contain any data in any format which the user defines to get interpreted in his application. On the IPS base
side the user in the main function during application Init registers the function he wants to execute when such
command is received by using the function ULE_UserWebReqHandler_CallBack. The result depends on the
processing made in this function, as the web application gets exactly the JSON object which is returned from this
function. A typical usage example of this command is the ability to control through the network different options and
parameters of the user application running in the IP base. For example, in the release demo this command is used to
pass the event-activities pairs that the user wants the IP base to run in the background.
Web API
page 8 of 13
SC14DECTIPBS
4.
Example:
{"cmdType":4,"portId": 1,"paramId":7,"paramValue":1}
Fields are numbers and Param field is an array of JSON paramId/Paramvalue structure.
For write command this command returns:
{"cmdType":4,"portId":<portID>,errDesc": UleErrEnum }
UleErrEnum : ULE_Success for success or else refer to APPENDIX A for error type
Description
1 Node
status
7- Node
type
8- Node
attribute
10 IPEI
read
Comments
paramValue:
1 online
0 Not registered
HANDSET_TYPE_NONE = 0x00
HANDSET_TYPE_GENERIC = 0x0A
HANDSET_TYPE_PENDANT = 0x0B
RW
Web API
11
Configure
Port parameters
Read
/Write
-
R/W
page 9 of 13
SC14DECTIPBS
pendant
direct call
number
12
Configure
ringing
melody
13
Configure
ringing
volume
14
Configure
vibration
mode
15
Configure
speech
volume
is pressed.
R/W
R/W
R/W
R/W
Web API
page 10 of 13
ErrDesc UleErrEnum is
0.
1.
2.
3.
4.
5.
6.
7.
8.
9.
10.
11.
12.
13.
14.
15.
16.
17.
18.
19.
20.
21.
22.
23.
24.
25.
26.
27.
28.
29.
30.
31.
32.
33.
34.
35.
36.
37.
38.
39.
40.
41.
42.
43.
44.
SC14DECTIPBS
APPENDIX A
Web API
page 11 of 13
Payload format
A typical payload from/to a sensor is consisted of a maximum of 20 bytes. As described in the
MmiUlePdu_common_t structure in the MmiFpPpCommon.h, it is consisted of the following bytes:
rsuint8
MmiDataType_t
Length;
PayloadType;
SC14DECTIPBS
APPENDIX B
MmiUleSensHdr_t SensorType;
rsuint8
NextMess;
rsuint8
Data[16];
Each of those data structures may contain the UleAction field, which defines whether to read or write
the corresponding attribute value of the payload. For example in a switch with the following payload
format:
MmiUleAction_t
rsuint8
rsuint8
Switch_Cmd_Action;
Switch_Cmd;
DummyData[14];
// 1 = On, 0 = Off
The Switch_Cmd byte is treated by the device as described by the first byte Switch_Cmd:
IGNORE= 0,
WRITE_ONCE= 1,
WRITE_TO_NVS=2,
READ= 3
page 12 of 13
Web API
Therefore the portable device can send a message to the fixed part to indicate its current status by
sending this payload:
[49,69,0,3,STATUS]
while the fixed part can set the value of an actuator ON/OFF by sending this payload to the portable
device:
[49,69,0,1,STATUS].
SC14DECTIPBS
Appendix C
Json command to IP base. The IP base replies back to the user with
[{"cmdType":0,"errDesc":0}]
indicating that the command was accepted (nothing was wrong with the parameters) and this message has
been scheduled to be send to the sensor. A positive reply back doesnt mean that the message was actually
send. The sensor may be sleeping at this time and may take minutes or even hours depending on the sleep
cycle configuration of the sensor to wake up and receive the message. Considering that only one message
per sensor can be send at a time, the user has to check the status of transmit buffer by sending Tx status
request for the sensor:
{"cmdType":1,"portId":7,"param":[{"paramId":2,"paramValue":{}}]}
At this point the TX buffer will remain full until the sensor wakes up and receives the message, or the
message gets rejected for some reason by the DECT radio or the user explicitly decides to abort the current
transmition and allow the sending of another higher priority payload:
{"cmdType":1,"portId":7,"param":[{"paramId":3,"paramValue":{}}]}
Now on the other way around, when a sensor sends a message back to IP BASE, the IP BASE will keep
placing the messages in a Receive cyclic buffer, one after the other, recording the timestamp in seconds and
assigning an incremental packetID to each packet. This buffer is 32 packets large.
Now the user has three options to read the data:
1)
By reading the Receive buffer through the JSON command (6 Return data)
{"cmdType":1,"portId":7,"param":[{"paramId":6,"paramValue":0}]}
User SW has to do the parsing regarding timestamps and packet IDs and every time send a new JSON
command with updated ParamValue=LatestPacketID to filter out messages already read.
This approach is encouraged to get used only if the user wants a history of the data, create graphs,
statistics, or do other data processing.
2)
{"cmdType":1,"portId": 8,"param":[{"paramId":8,"paramValue":0}]}
In IP base there is the user application which run and can act with minimum latency in any sensor event.
This application can do any processing and pass information to the network though the "attributes"
In this demo the SW software is simply written to pass the value of latest switch read to attribute 1.
This method relies on user SW running in IP BASE to pass proper data to attribute values.
3)
{"cmdType":1,"portId": 8,"param":[{"paramId":9,"paramValue":49}]}
page 13 of 13
Web API
In most cases the user usually is interested for the latest data coming from a sensor of a given data type.
Past values may be of no interest and likely there may be no attribute written by the user application to pass
latest data. In the switch example datatype MMI_DATA_TYPE_SWITCH_220=49 gives the switch status,
therefore the user can send the command above to get the latest packet of this data type received from the
sensor and avoid option1 which requires extra effort on user side to do the necessary parsing.