import h5py
import numpy as np


def getData(cfileName):
    """
    Given a name of a *.cfile, this function extracts the interleaved
    Inphase-Quadrature data samples and convert it into a numpy array of complex
    data elements. *.cfile format has interleaved I and Q samples where each sample
    is a float32 type. GNURadio Companion (GRC) scripts output data into a file
    though a file sink block in this format.
    Read more in SDR data types: https://github.com/miek/inspectrum
    """

    # Read the *.cfile which has each element in float32 format.
    data = np.fromfile(cfileName, dtype="float32")

    # Take each consecutive interleaved I sample and Q sample to create a single complex element.
    data = data[0::2] + 1j*data[1::2]
    #print("data type=", type(data))
    # Return the complex numpy array.
    return data


dataset_folder = "/home/asanka/Desktop/EM-Dataset"


# creating the HDF5 file
hf = h5py.File('em-dataset.h5', 'w')
# setting the file attributes
hf.attrs[u'dataset_version'] = u'1'
hf.attrs[u'dataset_creater'] = u'Asanka P. Sayakkara <asa@ucsc.cmb.ac.lk>'
hf.attrs[u'dataset_date'] = u'2021-03-01'

#########################################################################
#########################################################################
# creating smartphone group 
smartphones = hf.create_group('smartphones')
# setting smartphone group attributes
smartphones.attrs[u'description'] = u'The EM radiation data of smartphones'

#------------------------------------------------------------------------
# creating iPhone 4S group 
iphone4s = smartphones.create_group('iphone4s')
# setting iPhone 4S attributes 
iphone4s.attrs[u'device_name'] = u'iPhone 4S'
iphone4s.attrs[u'sampling_frequency'] = u'20MHz'
iphone4s.attrs[u'centre_frequency'] = u'1.01GHz'

# creating datasets with their attributes
iqdata = getData(dataset_folder + "/smartphone-EM-dataset-2020-11-23/apple-iphone-4s/calandar-app.cfile")
dataset = iphone4s.create_dataset('calendar-app', data=iqdata)
dataset.attrs[u'dataset_description'] = u'iPhone 4S running the calendar app'
del iqdata

iqdata = getData(dataset_folder + "/smartphone-EM-dataset-2020-11-23/apple-iphone-4s/camera-photo.cfile")
dataset = iphone4s.create_dataset('camera-photo', data=iqdata)
dataset.attrs[u'dataset_description'] = u'iPhone 4S running the camera photo app'
del iqdata

iqdata = getData(dataset_folder + "/smartphone-EM-dataset-2020-11-23/apple-iphone-4s/camera-video.cfile")
dataset = iphone4s.create_dataset('camera-video', data=iqdata)
dataset.attrs[u'dataset_description'] = u'iPhone 4S running the camera video app'
del iqdata

iqdata = getData(dataset_folder + "/smartphone-EM-dataset-2020-11-23/apple-iphone-4s/email-app.cfile")
dataset = iphone4s.create_dataset('email-app', data=iqdata)
dataset.attrs[u'dataset_description'] = u'iPhone 4S running the email app'
del iqdata

iqdata = getData(dataset_folder + "/smartphone-EM-dataset-2020-11-23/apple-iphone-4s/gallary-app.cfile")
dataset = iphone4s.create_dataset('gallary-app', data=iqdata)
dataset.attrs[u'dataset_description'] = u'iPhone 4S running the gallary app'
del iqdata

iqdata = getData(dataset_folder + "/smartphone-EM-dataset-2020-11-23/apple-iphone-4s/home-screen.cfile")
dataset = iphone4s.create_dataset('home-screen', data=iqdata)
dataset.attrs[u'dataset_description'] = u'iPhone 4S showing the home screen'
del iqdata

iqdata = getData(dataset_folder + "/smartphone-EM-dataset-2020-11-23/apple-iphone-4s/idle.cfile")
dataset = iphone4s.create_dataset('idle', data=iqdata)
dataset.attrs[u'dataset_description'] = u'iPhone 4S idle'
del iqdata

iqdata = getData(dataset_folder + "/smartphone-EM-dataset-2020-11-23/apple-iphone-4s/phone-app.cfile")
dataset = iphone4s.create_dataset('phone-app', data=iqdata)
dataset.attrs[u'dataset_description'] = u'iPhone 4S running the phone app'
del iqdata

iqdata = getData(dataset_folder + "/smartphone-EM-dataset-2020-11-23/apple-iphone-4s/sms-app.cfile")
dataset = iphone4s.create_dataset('sms-app', data=iqdata)
dataset.attrs[u'dataset_description'] = u'iPhone 4S running the sms app'
del iqdata

iqdata = getData(dataset_folder + "/smartphone-EM-dataset-2020-11-23/apple-iphone-4s/web-browser-app.cfile")
dataset = iphone4s.create_dataset('web-browser-app', data=iqdata)
dataset.attrs[u'dataset_description'] = u'iPhone 4S running the web browser app'
del iqdata


#------------------------------------------------------------------------
# creating Nokia 4.2 group 
nokia42 = smartphones.create_group('nokia42')
# setting Nokia 4.2 attributes 
nokia42.attrs[u'device_name'] = u'Nokia 4.2'
nokia42.attrs[u'sampling_frequency'] = u'20MHz'
nokia42.attrs[u'centre_frequency'] = u'1.53GHz'


# creating datasets with their attributes
iqdata = getData(dataset_folder + "/smartphone-EM-dataset-2020-11-23/nokia-4-2/calandar-app.cfile")
dataset = nokia42.create_dataset('calendar-app', data=iqdata)
dataset.attrs[u'dataset_description'] = u'Nokia 4.2 is running the calendar app'
del iqdata

iqdata = getData(dataset_folder + "/smartphone-EM-dataset-2020-11-23/nokia-4-2/camera-photo.cfile")
dataset = nokia42.create_dataset('camera-photo', data=iqdata)
dataset.attrs[u'dataset_description'] = u'Nokia 4.2 is running the camera photo app'
del iqdata

iqdata = getData(dataset_folder + "/smartphone-EM-dataset-2020-11-23/nokia-4-2/camera-video.cfile")
dataset = nokia42.create_dataset('camera-video', data=iqdata)
dataset.attrs[u'dataset_description'] = u'Nokia 4.2 is running the camera video app'
del iqdata

iqdata = getData(dataset_folder + "/smartphone-EM-dataset-2020-11-23/nokia-4-2/email-app.cfile")
dataset = nokia42.create_dataset('email-app', data=iqdata)
dataset.attrs[u'dataset_description'] = u'Nokia 4.2 is running the email app'
del iqdata

iqdata = getData(dataset_folder + "/smartphone-EM-dataset-2020-11-23/nokia-4-2/gallary-app.cfile")
dataset = nokia42.create_dataset('gallary-app', data=iqdata)
dataset.attrs[u'dataset_description'] = u'Nokia 4.2 is running the gallary app'
del iqdata

iqdata = getData(dataset_folder + "/smartphone-EM-dataset-2020-11-23/nokia-4-2/home-screen.cfile")
dataset = nokia42.create_dataset('home-screen', data=iqdata)
dataset.attrs[u'dataset_description'] = u'Nokia 4.2 is showing the home screen'
del iqdata

iqdata = getData(dataset_folder + "/smartphone-EM-dataset-2020-11-23/nokia-4-2/idle.cfile")
dataset = nokia42.create_dataset('idle', data=iqdata)
dataset.attrs[u'dataset_description'] = u'Nokia 4.2 is idle'
del iqdata

iqdata = getData(dataset_folder + "/smartphone-EM-dataset-2020-11-23/nokia-4-2/phone-app.cfile")
dataset = nokia42.create_dataset('phone-app', data=iqdata)
dataset.attrs[u'dataset_description'] = u'Nokia 4.2 is running the phone app'
del iqdata

iqdata = getData(dataset_folder + "/smartphone-EM-dataset-2020-11-23/nokia-4-2/sms-app.cfile")
dataset = nokia42.create_dataset('sms-app', data=iqdata)
dataset.attrs[u'dataset_description'] = u'Nokia 4.2 is running the sms app'
del iqdata

iqdata = getData(dataset_folder + "/smartphone-EM-dataset-2020-11-23/nokia-4-2/web-browser-app.cfile")
dataset = nokia42.create_dataset('web-browser-app', data=iqdata)
dataset.attrs[u'dataset_description'] = u'Nokia 4.2 is running the web browser app'
del iqdata

#------------------------------------------------------------------------
# creating Sony Xperia group 
sonyxperia = smartphones.create_group('sonyxperia')
# setting Sony Xperia attributes 
sonyxperia.attrs[u'device_name'] = u'Sony Xperia'
sonyxperia.attrs[u'sampling_frequency'] = u'20MHz'
sonyxperia.attrs[u'centre_frequency'] = u'1.5GHz'


# creating datasets with their attributes
iqdata = getData(dataset_folder + "/smartphone-EM-dataset-2020-11-23/sony-xperia/calandar-app.cfile")
dataset = sonyxperia.create_dataset('calendar-app', data=iqdata)
dataset.attrs[u'dataset_description'] = u'Sony Xperia is running the calendar app'
del iqdata

iqdata = getData(dataset_folder + "/smartphone-EM-dataset-2020-11-23/sony-xperia/camera-photo.cfile")
dataset = sonyxperia.create_dataset('camera-photo', data=iqdata)
dataset.attrs[u'dataset_description'] = u'Sony Xperia is running the camera photo app'
del iqdata

iqdata = getData(dataset_folder + "/smartphone-EM-dataset-2020-11-23/sony-xperia/camera-video.cfile")
dataset = sonyxperia.create_dataset('camera-video', data=iqdata)
dataset.attrs[u'dataset_description'] = u'Sony Xperia is running the camera video app'
del iqdata

iqdata = getData(dataset_folder + "/smartphone-EM-dataset-2020-11-23/sony-xperia/email-app.cfile")
dataset = sonyxperia.create_dataset('email-app', data=iqdata)
dataset.attrs[u'dataset_description'] = u'Sony Xperia is running the email app'
del iqdata

iqdata = getData(dataset_folder + "/smartphone-EM-dataset-2020-11-23/sony-xperia/gallary-app.cfile")
dataset = sonyxperia.create_dataset('gallary-app', data=iqdata)
dataset.attrs[u'dataset_description'] = u'Sony Xperia is running the gallary app'
del iqdata

iqdata = getData(dataset_folder + "/smartphone-EM-dataset-2020-11-23/sony-xperia/home-screen.cfile")
dataset = sonyxperia.create_dataset('home-screen', data=iqdata)
dataset.attrs[u'dataset_description'] = u'Sony Xperia is showing the home screen'
del iqdata

iqdata = getData(dataset_folder + "/smartphone-EM-dataset-2020-11-23/sony-xperia/idle.cfile")
dataset = sonyxperia.create_dataset('idle', data=iqdata)
dataset.attrs[u'dataset_description'] = u'Sony Xperia is idle'
del iqdata

iqdata = getData(dataset_folder + "/smartphone-EM-dataset-2020-11-23/sony-xperia/phone-app.cfile")
dataset = sonyxperia.create_dataset('phone-app', data=iqdata)
dataset.attrs[u'dataset_description'] = u'Sony Xperia is running the phone app'
del iqdata

iqdata = getData(dataset_folder + "/smartphone-EM-dataset-2020-11-23/sony-xperia/sms-app.cfile")
dataset = sonyxperia.create_dataset('sms-app', data=iqdata)
dataset.attrs[u'dataset_description'] = u'Sony Xperia is running the sms app'
del iqdata

iqdata = getData(dataset_folder + "/smartphone-EM-dataset-2020-11-23/sony-xperia/web-browser-app.cfile")
dataset = sonyxperia.create_dataset('web-browser-app', data=iqdata)
dataset.attrs[u'dataset_description'] = u'Sony Xperia is running the web browser app'
del iqdata

#------------------------------------------------------------------------
# creating Galaxy Grand Prime group 
galaxyprime = smartphones.create_group('galaxyprime')
# setting Galaxy Grand Prime attributes 
galaxyprime.attrs[u'device_name'] = u'Samsung Galaxy Grand Prime'
galaxyprime.attrs[u'sampling_frequency'] = u'20MHz'
galaxyprime.attrs[u'centre_frequency'] = u'1.23GHz'


# creating datasets with their attributes
iqdata = getData(dataset_folder + "/smartphone-EM-dataset-2020-11-23/galaxy-grand-prime/audio-recording.cfile")
dataset = galaxyprime.create_dataset('audio-recording', data=iqdata)
dataset.attrs[u'dataset_description'] = u'Galaxy Grand Prime is running audio recording app'
del iqdata

iqdata = getData(dataset_folder + "/smartphone-EM-dataset-2020-11-23/galaxy-grand-prime/camera-photo.cfile")
dataset = galaxyprime.create_dataset('camera-photo', data=iqdata)
dataset.attrs[u'dataset_description'] = u'Galaxy Grand Prime is running the camera photo app'
del iqdata

iqdata = getData(dataset_folder + "/smartphone-EM-dataset-2020-11-23/galaxy-grand-prime/camera-video.cfile")
dataset = galaxyprime.create_dataset('camera-video', data=iqdata)
dataset.attrs[u'dataset_description'] = u'Galaxy Grand Prime is running the camera video app'
del iqdata

iqdata = getData(dataset_folder + "/smartphone-EM-dataset-2020-11-23/galaxy-grand-prime/email-app.cfile")
dataset = galaxyprime.create_dataset('email-app', data=iqdata)
dataset.attrs[u'dataset_description'] = u'Galaxy Grand Prime is running the email app'
del iqdata

iqdata = getData(dataset_folder + "/smartphone-EM-dataset-2020-11-23/galaxy-grand-prime/gallary-app.cfile")
dataset = galaxyprime.create_dataset('gallary-app', data=iqdata)
dataset.attrs[u'dataset_description'] = u'Galaxy Grand Prime is running the gallary app'
del iqdata

iqdata = getData(dataset_folder + "/smartphone-EM-dataset-2020-11-23/galaxy-grand-prime/home-screen.cfile")
dataset = galaxyprime.create_dataset('home-screen', data=iqdata)
dataset.attrs[u'dataset_description'] = u'Galaxy Grand Prime is showing the home screen'
del iqdata

iqdata = getData(dataset_folder + "/smartphone-EM-dataset-2020-11-23/galaxy-grand-prime/idle.cfile")
dataset = galaxyprime.create_dataset('idle', data=iqdata)
dataset.attrs[u'dataset_description'] = u'Galaxy Grand Prime is idle'
del iqdata

iqdata = getData(dataset_folder + "/smartphone-EM-dataset-2020-11-23/galaxy-grand-prime/phone-app.cfile")
dataset = galaxyprime.create_dataset('phone-app', data=iqdata)
dataset.attrs[u'dataset_description'] = u'Galaxy Grand Prime is running the phone app'
del iqdata

iqdata = getData(dataset_folder + "/smartphone-EM-dataset-2020-11-23/galaxy-grand-prime/sms-app.cfile")
dataset = galaxyprime.create_dataset('sms-app', data=iqdata)
dataset.attrs[u'dataset_description'] = u'Galaxy Grand Prime is running the sms app'
del iqdata

iqdata = getData(dataset_folder + "/smartphone-EM-dataset-2020-11-23/galaxy-grand-prime/web-browser-app.cfile")
dataset = galaxyprime.create_dataset('web-browser-app', data=iqdata)
dataset.attrs[u'dataset_description'] = u'Galaxy Grand Prime is running the web browser app'
del iqdata




#########################################################################
#########################################################################
# creating internet of things group
iot = hf.create_group('internet-of-things')
# setting iot group attributes
iot.attrs[u'description'] = u'The EM radiation data of Internet of Things'

#------------------------------------------------------------------------
# creating Amazon Echo Dot group 
echodot = iot.create_group('amazon-echo-dot')
# setting Amazon Echo Dot attributes 
echodot.attrs[u'device_name'] = u'Amazon Echo Dot'
echodot.attrs[u'sampling_frequency'] = u'20MHz'
echodot.attrs[u'centre_frequency'] = u'1.3GHz'


# creating datasets with their attributes
iqdata = getData(dataset_folder + "/iot-device-EM-dataset-2021-01-19/Amazon-Echo-Dot/asking-a-definition.cfile")
dataset = echodot.create_dataset('asking-a-definition', data=iqdata)
dataset.attrs[u'dataset_description'] = u'Amazon Echo Dot was asked to provide a definition'
del iqdata

iqdata = getData(dataset_folder + "/iot-device-EM-dataset-2021-01-19/Amazon-Echo-Dot/asking-for-time.cfile")
dataset = echodot.create_dataset('asking-for-time', data=iqdata)
dataset.attrs[u'dataset_description'] = u'Amazon Echo Dot was asked for time'
del iqdata

iqdata = getData(dataset_folder + "/iot-device-EM-dataset-2021-01-19/Amazon-Echo-Dot/asking-to-play-radio.cfile")
dataset = echodot.create_dataset('asking-to-play-radio', data=iqdata)
dataset.attrs[u'dataset_description'] = u'Amazon Echo Dot was asked to play the radio'
del iqdata

iqdata = getData(dataset_folder + "/iot-device-EM-dataset-2021-01-19/Amazon-Echo-Dot/controlling-lightbulb.cfile")
dataset = echodot.create_dataset('controlling-lightbulb', data=iqdata)
dataset.attrs[u'dataset_description'] = u'Amazon Echo Dot was asked to control a smart lightbulb'
del iqdata

iqdata = getData(dataset_folder + "/iot-device-EM-dataset-2021-01-19/Amazon-Echo-Dot/device-idle.cfile")
dataset = echodot.create_dataset('device-idle', data=iqdata)
dataset.attrs[u'dataset_description'] = u'Amazon Echo Dot was idle'
del iqdata

iqdata = getData(dataset_folder + "/iot-device-EM-dataset-2021-01-19/Amazon-Echo-Dot/device-muted.cfile")
dataset = echodot.create_dataset('device-muted', data=iqdata)
dataset.attrs[u'dataset_description'] = u'Amazon Echo Dot was muted'
del iqdata

iqdata = getData(dataset_folder + "/iot-device-EM-dataset-2021-01-19/Amazon-Echo-Dot/device-resetting.cfile")
dataset = echodot.create_dataset('device-resetting', data=iqdata)
dataset.attrs[u'dataset_description'] = u'Amazon Echo Dot was being reset'
del iqdata

iqdata = getData(dataset_folder + "/iot-device-EM-dataset-2021-01-19/Amazon-Echo-Dot/just-wakeup-word.cfile")
dataset = echodot.create_dataset('just-wakeup-word', data=iqdata)
dataset.attrs[u'dataset_description'] = u'Amazon Echo Dot was just awaken through the wakeup word'
del iqdata

iqdata = getData(dataset_folder + "/iot-device-EM-dataset-2021-01-19/Amazon-Echo-Dot/powering-on.cfile")
dataset = echodot.create_dataset('powering-on', data=iqdata)
dataset.attrs[u'dataset_description'] = u'Amazon Echo Dot was being powered on'
del iqdata

#------------------------------------------------------------------------
# creating Amazon Echo Show 5 group 
echoshow5 = iot.create_group('amazon-echo-show5')
# setting Amazon Echo Show 5 attributes 
echoshow5.attrs[u'device_name'] = u'Amazon Echo Show 5'
echoshow5.attrs[u'sampling_frequency'] = u'20MHz'
echoshow5.attrs[u'centre_frequency'] = u'1.3GHz'


# creating datasets with their attributes
iqdata = getData(dataset_folder + "/iot-device-EM-dataset-2021-01-19/Amazon-Echo-Show-5/asking-a-definition.cfile")
dataset = echoshow5.create_dataset('asking-a-definition', data=iqdata)
dataset.attrs[u'dataset_description'] = u'Amazon Echo Show 5 was asked to provide a definition'
del iqdata

iqdata = getData(dataset_folder + "/iot-device-EM-dataset-2021-01-19/Amazon-Echo-Show-5/asking-for-time.cfile")
dataset = echoshow5.create_dataset('asking-for-time', data=iqdata)
dataset.attrs[u'dataset_description'] = u'Amazon Echo Show 5 was asked to provide the time'
del iqdata

iqdata = getData(dataset_folder + "/iot-device-EM-dataset-2021-01-19/Amazon-Echo-Show-5/asking-to-play-radio.cfile")
dataset = echoshow5.create_dataset('asking-to-play-radio', data=iqdata)
dataset.attrs[u'dataset_description'] = u'Amazon Echo Show 5 was asked to play the radio'
del iqdata

iqdata = getData(dataset_folder + "/iot-device-EM-dataset-2021-01-19/Amazon-Echo-Show-5/controlling-lightbulb.cfile")
dataset = echoshow5.create_dataset('controlling-lightbulb', data=iqdata)
dataset.attrs[u'dataset_description'] = u'Amazon Echo Show 5 was asked to control a smart lightbulb'
del iqdata

iqdata = getData(dataset_folder + "/iot-device-EM-dataset-2021-01-19/Amazon-Echo-Show-5/device-idle.cfile")
dataset = echoshow5.create_dataset('device-idle', data=iqdata)
dataset.attrs[u'dataset_description'] = u'Amazon Echo Show 5 was idle'
del iqdata

iqdata = getData(dataset_folder + "/iot-device-EM-dataset-2021-01-19/Amazon-Echo-Show-5/device-resetting.cfile")
dataset = echoshow5.create_dataset('device-resetting', data=iqdata)
dataset.attrs[u'dataset_description'] = u'Amazon Echo Show 5 was being reset'
del iqdata

iqdata = getData(dataset_folder + "/iot-device-EM-dataset-2021-01-19/Amazon-Echo-Show-5/just-wakeup-word.cfile")
dataset = echoshow5.create_dataset('just-wakeup-word', data=iqdata)
dataset.attrs[u'dataset_description'] = u'Amazon Echo Show 5 was just awaken using the wakeup word'
del iqdata

iqdata = getData(dataset_folder + "/iot-device-EM-dataset-2021-01-19/Amazon-Echo-Show-5/powering-off.cfile")
dataset = echoshow5.create_dataset('powering-off', data=iqdata)
dataset.attrs[u'dataset_description'] = u'Amazon Echo Show 5 was being powered off'
del iqdata

iqdata = getData(dataset_folder + "/iot-device-EM-dataset-2021-01-19/Amazon-Echo-Show-5/powering-on.cfile")
dataset = echoshow5.create_dataset('powering-on', data=iqdata)
dataset.attrs[u'dataset_description'] = u'Amazon Echo Show 5 was being powered on'
del iqdata

#------------------------------------------------------------------------
# creating Google Home group 
googlehome = iot.create_group('google-home')
# setting Google Home attributes 
googlehome.attrs[u'device_name'] = u'Google Home'
googlehome.attrs[u'sampling_frequency'] = u'20MHz'
googlehome.attrs[u'centre_frequency'] = u'1.2GHz'


# creating datasets with their attributes
iqdata = getData(dataset_folder + "/iot-device-EM-dataset-2021-01-19/Google-Home/asking-a-definition.cfile")
dataset = googlehome.create_dataset('asking-a-definition', data=iqdata)
dataset.attrs[u'dataset_description'] = u'Google Home was asked to provide a definition'
del iqdata

iqdata = getData(dataset_folder + "/iot-device-EM-dataset-2021-01-19/Google-Home/asking-for-time.cfile")
dataset = googlehome.create_dataset('asking-for-time', data=iqdata)
dataset.attrs[u'dataset_description'] = u'Google Home was asked to provide time'
del iqdata

iqdata = getData(dataset_folder + "/iot-device-EM-dataset-2021-01-19/Google-Home/asking-to-play-radio.cfile")
dataset = googlehome.create_dataset('asking-to-play-radio', data=iqdata)
dataset.attrs[u'dataset_description'] = u'Google Home was asked to play the radio'
del iqdata

iqdata = getData(dataset_folder + "/iot-device-EM-dataset-2021-01-19/Google-Home/controlling-lightbulb.cfile")
dataset = googlehome.create_dataset('controlling-lightbulb', data=iqdata)
dataset.attrs[u'dataset_description'] = u'Google Home was asked to control a smart lightbulb'
del iqdata

iqdata = getData(dataset_folder + "/iot-device-EM-dataset-2021-01-19/Google-Home/device-idle.cfile")
dataset = googlehome.create_dataset('device-idle', data=iqdata)
dataset.attrs[u'dataset_description'] = u'Google Home was idle'
del iqdata

iqdata = getData(dataset_folder + "/iot-device-EM-dataset-2021-01-19/Google-Home/device-muted.cfile")
dataset = googlehome.create_dataset('device-muted', data=iqdata)
dataset.attrs[u'dataset_description'] = u'Google Home was muted'
del iqdata

iqdata = getData(dataset_folder + "/iot-device-EM-dataset-2021-01-19/Google-Home/device-resetting.cfile")
dataset = googlehome.create_dataset('device-resetting', data=iqdata)
dataset.attrs[u'dataset_description'] = u'Google Home was being reset'
del iqdata

iqdata = getData(dataset_folder + "/iot-device-EM-dataset-2021-01-19/Google-Home/just-wakeup-word.cfile")
dataset = googlehome.create_dataset('just-wakeup-word', data=iqdata)
dataset.attrs[u'dataset_description'] = u'Google Home was just awaken using the wakeup word'
del iqdata

iqdata = getData(dataset_folder + "/iot-device-EM-dataset-2021-01-19/Google-Home/powering-on.cfile")
dataset = googlehome.create_dataset('powering-on', data=iqdata)
dataset.attrs[u'dataset_description'] = u'Google Home was being being powered on'
del iqdata

#------------------------------------------------------------------------
# creating Samsung SmartThings Hub group 
smartthings = iot.create_group('samsung-smartthings')
# setting Samsung SmartThings attributes 
smartthings.attrs[u'device_name'] = u'Samsung SmartThings Hub v2'
smartthings.attrs[u'sampling_frequency'] = u'20MHz'
smartthings.attrs[u'centre_frequency'] = u'1GHz'


# creating datasets with their attributes
iqdata = getData(dataset_folder + "/iot-device-EM-dataset-2021-01-19/Samsung-SmartThings-Hub-v2/controlling-smart-outlet.cfile")
dataset = smartthings.create_dataset('controlling-smart-outlet', data=iqdata)
dataset.attrs[u'dataset_description'] = u'Samsung SmartThings Hub is controlling the smart outlet'
del iqdata

iqdata = getData(dataset_folder + "/iot-device-EM-dataset-2021-01-19/Samsung-SmartThings-Hub-v2/device-idle.cfile")
dataset = smartthings.create_dataset('device-idle', data=iqdata)
dataset.attrs[u'dataset_description'] = u'Samsung SmartThings Hub is idle'
del iqdata

iqdata = getData(dataset_folder + "/iot-device-EM-dataset-2021-01-19/Samsung-SmartThings-Hub-v2/device-powered-off.cfile")
dataset = smartthings.create_dataset('device-powered-off', data=iqdata)
dataset.attrs[u'dataset_description'] = u'Samsung SmartThings Hub is powered off'
del iqdata

iqdata = getData(dataset_folder + "/iot-device-EM-dataset-2021-01-19/Samsung-SmartThings-Hub-v2/device-powering-on.cfile")
dataset = smartthings.create_dataset('device-powering-on', data=iqdata)
dataset.attrs[u'dataset_description'] = u'Samsung SmartThings Hub is powering on'
del iqdata

iqdata = getData(dataset_folder + "/iot-device-EM-dataset-2021-01-19/Samsung-SmartThings-Hub-v2/openning-the-app.cfile")
dataset = smartthings.create_dataset('openning-the-app', data=iqdata)
dataset.attrs[u'dataset_description'] = u'The smartphone app of the Samsung SmartThings Hub is opened'
del iqdata

iqdata = getData(dataset_folder + "/iot-device-EM-dataset-2021-01-19/Samsung-SmartThings-Hub-v2/viewing-arrival-sensor.cfile")
dataset = smartthings.create_dataset('view-arrival-sensor', data=iqdata)
dataset.attrs[u'dataset_description'] = u'The arrival sensor status is being viewed on the Samsung SmartThings Hub'
del iqdata

iqdata = getData(dataset_folder + "/iot-device-EM-dataset-2021-01-19/Samsung-SmartThings-Hub-v2/viewing-door-sensor.cfile")
dataset = smartthings.create_dataset('view-door-sensor', data=iqdata)
dataset.attrs[u'dataset_description'] = u'The door sensor status is being viewed on the Samsung SmartThings Hub'
del iqdata

iqdata = getData(dataset_folder + "/iot-device-EM-dataset-2021-01-19/Samsung-SmartThings-Hub-v2/view-motion-sensor.cfile")
dataset = smartthings.create_dataset('view-motion-sensor', data=iqdata)
dataset.attrs[u'dataset_description'] = u'The motion sensor status is being viewed on the Samsung SmartThings Hub'
del iqdata


hf.close()

