Wednesday, March 7, 2007

Gathering Wireless Vendor Info from the SQL DB

My manager asked for a report of the BlackBerry users and their associated wireless provider. Given this is all stored in the BES SQL DB, it shouldn't be a problem to get the info - but there are some things to figure out before it works right:

1. There are two fields in the BES SQL DB that refer to a wireless provider. The first is the VendorID field, which specifies the actual maker of the BlackBerry device itself, regardless of what network it is currently connected to or roaming on.

2. The second is the Home Network field, which actually doesn't make sense because it shows you which wireless network provider the device is connected to right now, so it may not actually be the home network, but a roaming partner.

For example I have a user whose device is a T-Mobile device and their home network would obviously be T-Mobile, however they currently appear as Cingular under Home Network.

To get these values out of the SQL DB we need a query, here is the one I use to pull the data into Excel:

SELECT UserConfig.DisplayName, vHandheldSummaryInfo.VendorID, vHandheldSummaryInfo.HomeNetwork
FROM BesConfig.dbo.UserConfig UserConfig, BesConfig.dbo.vHandheldSummaryInfo vHandheldSummaryInfo
WHERE vHandheldSummaryInfo.PIN = UserConfig.PIN

Note that you need to join these two tables in Microsoft Query using the PIN field, not the default "id" field that it starts with, otherwise your data won't match. Haven't discovered why, perhaps their are two different id fields in the two tables. Anyway, just use PIN because that is a common key that I know is unique.

So once you run this query you get the user's Display Name, Vendor ID, and Home Network. Now to get the device's carrier I need just the Vendor ID field but I like to see what Home Network people are on, it is interesting to see where your people are in the world and what unique names other wireless carriers have, such as "CCT Boatphone" (!). (Apparently from the British Virgin Islands, but is it really for boats? a cruise ship? hmmm...)

One final issue is that the Vendor ID is in decimal format, so I wasn't quite sure which was which. The Home Network let me see which vendor ID matched up with which vendor name, but after doing a bunch of work for that I figured out that the vendor id's are stored in where else... the Vendors.xml file!

While the Vendors.xml file did in fact contain all the matchings between vendor ID and vendor name, the id's in this file were in Hex format! :( After a little hacking in Excel with the HEX2DEC formula, I came up with the following master table below of all vendors RIM supports:


Hex (vendor.xml)Decimal (BES DB)Provider Name
64100T-Mobile US
65101AWS
66102Cingular Wireless
67103Nextel
68104Sprint PCS
69105Verizon
6B107Rogers
6D109BWA (Aliant/Sasktel)
6F111MM02 DE
71113Telfort
72114T-Mobile DE/AU
73115TIM
74116Hutchison
75117Bouygues
76118SFR
77119Orange_France
78120VODAFONE (UK)
79121Telcel
7A122Telstra
7B123T-Mobile (UK)
7C124Vodafone Germany
7D125MM02 UK/IRL/NL
7E126Telus
7F127SMART
80128Starhub
81129Telefonica
82130Swisscom
83131Cable and Wireless
84132Vodafone (IT)
85133Vodafone (ES)
86134T-Mobile (NL)
87135Cincinnati Bell
89137Vodafone Austria
8A138Vodafone Australia
8B139Vodafone Ireland
8C140Vodafone Sweden
8D141CSL
8E142Orange UK
8F143Vodafone New Zealand
90144SingTel
91145Globe
92146Optus
93147Orange Mobistar
95149Bharti
96150KPN
98152Proximus
99153Vodafone_Portugal
9B155BT_Mobile
9C156Earthlink
9E158E-Plus
9F159BASE
A0160Dobson
A1161Vodafone_Egypt
A2162Orange_Switzerland
A4164Triton
A5165Maxis
A6166Vodafone_Denmark_(TDC)
A7167MobileOne_(Voda_Singapore)
A8168Vodacom


So now I can run my SQL query and easily match up the vendor ID's in decimal with the vendor names from this table. Cool.

No comments: