This project is a Python script designed to generate entities on a TinyIoT server based on a JSON file created by the oneM2M Design Tool.
The script reads JSON files located in the /data/ folder and sends requests to a TinyIoT server to create entities such as AE (Application Entity) and CNT (Container) in the specified order.
- Python 3.x
requestslibrary (Install usingpip install requests)
- Clone this repository.
- Place your JSON files in the
/data/folder. - Install the
requestslibrary:
pip install requests
The server URL is set to http://127.0.0.1:3000/. You can change it in the resourceGenerator.py file:
SERVER_URL = 'http://127.0.0.1:3000/'Run the script with Python:
python resourceGenerator.py
You will see a prompt listing all the JSON files available in the /data/ folder. Enter the number corresponding to the file you want to use.
[0] testdata.json
[1] yourdata.json
Enter the number of the file you want to read: 0
AE 'myAE1' is ready.
AE 'myAE2' is ready.
CNT 'myCNT4' is ready under 'TinyIoT/myAE2'.
CNT 'myCNT1' is ready under 'TinyIoT/myAE1'.
CNT 'myCNT2' is ready under 'TinyIoT/myAE1'.
CNT 'myCNT3' is ready under 'TinyIoT/myAE1'.
CNT 'mySUBCNT1' is ready under 'TinyIoT/myAE1/myCNT1'.
CNT 'mySUBCNT2' is ready under 'TinyIoT/myAE1/myCNT1'.
CNT 'mySUBCNT3' is ready under 'TinyIoT/myAE1/myCNT1'.
The JSON files can be generated by the oneM2M Design Tool or you can make it yourself. Generated JSON files must be placed in the /data/ folder. The tool generates files that describe entities hierarchically.