Exemple #1
0
def get_advertised_id():
    """
    Return the advertised id of IBeacon
    """
    beacon_info = json.loads(request.get_data())
    if not Validator.valid(beacon_info):
        return json_response({"message": "Invalid JSON Content"},
                             status_code=400)

    ibeacon = IBeacon(beacon_info)
    return json_response({"advertised_id": ibeacon.advertised_id()},
                         status_code=200)
Exemple #2
0
 def create_beacon(form):
     """
     Return appropiate beacon
     """
     if form.get('type') == 'iBEACON':
         return IBeacon(form)
     return EddyStone(form)
Exemple #3
0
def get_estimote_details(advertised_id):
    """
    Returns the namespace and instance id of the beacon
    """
    result = os.popen(ESTIMOTE_CMD).read()
    beacon_list = json.loads(result)
    for beacon in beacon_list:
        beacon_advertised_id = IBeacon(beacon).advertised_id()
        if advertised_id == beacon_advertised_id:
            return beacon
    return None
Exemple #4
0
 def test_0070_advertised_id_with_major_1600_minor_5(self):
     self.beacon_data["major"] = "1600"
     self.beacon_data["minor"] = "5"
     beacon = IBeacon(self.beacon_data)
     self.assertEqual(beacon.advertised_id(), "uUB/MCVVa1f+bf////9kBQ==")
Exemple #5
0
 def test_0060_advertised_id_with_major_1600_minor_582567(self):
     self.beacon_data["major"] = "1600"
     self.beacon_data["minor"] = "582567"
     beacon = IBeacon(self.beacon_data)
     self.assertEqual(beacon.advertised_id(), "uUB/MCVVa1f+bf//ZAjjpw==")
Exemple #6
0
 def test_0030_advertised_id_with_major_64931_minor_51855(self):
     self.beacon_data["major"] = "64931"
     self.beacon_data["minor"] = "51855"
     beacon = IBeacon(self.beacon_data)
     self.assertEqual(beacon.advertised_id(), "uUB/MCVVa1f+bf///aPKjw==")
Exemple #7
0
 def test_0020_advertised_id_with_major_50206_minor_57048(self):
     self.beacon_data["major"] = "50206"
     self.beacon_data["minor"] = "57048"
     beacon = IBeacon(self.beacon_data)
     self.assertEqual(beacon.advertised_id(), "uUB/MCVVa1f+bf//xB7e2A==")
Exemple #8
0
 def test_0010_advertised_id_with_major_64931_minor_59274(self):
     beacon = IBeacon(self.beacon_data)
     self.assertEqual(beacon.advertised_id(), "uUB/MCVVa1f+bf///aPnig==")