Better implementation for generating device id

This commit is contained in:
Zaid Abdulla committed 2012-10-21 11:24:47 +03:00
1 parent 88060dd288
commit 52967d018c
2 files changed
+12 -2

No files matched your search

+10
View File
@@ -1,8 +1,18 @@
exports.endsWith = (str, suffix) ->
str.indexOf(suffix, str.length - suffix.length) isnt -1
exports.arrayToHash = (arr) ->
hash = {}
for i in arr
hash[i[0]] = i[1]
return hash
exports.getDeviceId = (deviceIdStruct) ->
# Guaranteeing globally unique id as defined in TR-069
if deviceIdStruct['ProductClass']
return "#{escape(deviceIdStruct['OUI'])}-#{escape(deviceIdStruct['ProductClass'])}-#{escape(deviceIdStruct['SerialNumber'])}"
return "#{escape(deviceIdStruct['OUI'])}-#{escape(deviceIdStruct['SerialNumber'])}"