I am using a php script to track my iPhones positions for a project. The script I’m using can be found here on github. The issue I’m facing however is that it’s tracking to devices. My laptop AND my iPhone. I want it to track just the iPhone however I want the ability to easily switch between the two devices if need be; in other words I want priority to be given to track the iPhone then the laptop. So I’m thinking of using the “deviceClass” to determine what device to select but I have no idea how to add it into the file: class.sosumi.php Here’s the array output here:
Sosumi Object
(
[devices] => Array
(
[0] => SosumiDevice Object
(
[isLocating] => 1
[locationTimestamp] => **
[locationType] => Wifi
[horizontalAccuracy] => 65
[locationFinished] => 1
[longitude] => **
[latitude] => **
[deviceModel] => MacBookPro7_1
[deviceStatus] => 200
[id] => **
[name] => **
[deviceClass] => MacBookPro
[chargingStatus] =>
[batteryLevel] => 0
)
[1] => SosumiDevice Object
(
[isLocating] => 1
[locationTimestamp] => **
[locationType] => Wifi
[horizontalAccuracy] => 65
[locationFinished] => 1
[longitude] => **
[latitude] => **
[deviceModel] => FourthGen
[deviceStatus] => 203
[id] => **
[name] => **
[deviceClass] => iPhone
[chargingStatus] => NotCharging
[batteryLevel] => 0.5866984
)
)
)
Any help with figuring out how to get this working would be appreciated. It seems easy but for some reason I can’t get it working.
Cheers!
I’m not sure whether I’ve got your question clearly, but you need either:
array_filterWhich will allow you filter your array like this:
usortSort array that first are MacBooks
This adds values classes like this:
MacBookPro => 1FourGen => 2Therefore when you add params like:
MacBookPro, FourthGenIt’s evaluated as:
1 - 2, which returns-1=>MacBookProshould be beforeFourthGenforeachloopSplit devices to groups based on device type:
You can achieve the same with array filter, this would be more effective if you need to get all groups,
array_filterwhen you need just one gruop.