@@ -645,11 +645,13 @@ function asMEI(manufacturerCode, code) {
645645
646646// The representation of null depends on the type, so we can't use a single
647647// macro that's defined elsewhere for "null value".
648- function determineAttributeDefaultValue (
648+ async function determineAttributeDefaultValue (
649649 specifiedDefault ,
650650 type ,
651651 typeSize ,
652- isNullable
652+ isNullable ,
653+ db ,
654+ sessionId
653655) {
654656 if ( specifiedDefault !== null || ! isNullable ) {
655657 return specifiedDefault
@@ -660,7 +662,7 @@ function determineAttributeDefaultValue(
660662 return null
661663 }
662664
663- if ( types . isSignedInteger ( type ) ) {
665+ if ( await types . isSignedInteger ( db , sessionId , type ) ) {
664666 return '0x80' + '00' . repeat ( typeSize - 1 )
665667 }
666668
@@ -681,7 +683,7 @@ function determineAttributeDefaultValue(
681683 * 2.) If client is included on at least one endpoint add client atts.
682684 * 3.) If server is included on at least one endpoint add server atts.
683685 */
684- async function collectAttributes ( endpointTypes , options ) {
686+ async function collectAttributes ( db , sessionId , endpointTypes , options ) {
685687 let commandMfgCodes = [ ] // Array of { index, mfgCode } objects
686688 let clusterMfgCodes = [ ] // Array of { index, mfgCode } objects
687689 let attributeMfgCodes = [ ] // Array of { index, mfgCode } objects
@@ -710,7 +712,7 @@ async function collectAttributes(endpointTypes, options) {
710712 ? options . spaceForDefaultValue
711713 : 2
712714
713- endpointTypes . forEach ( ( ept ) => {
715+ for ( let ept of endpointTypes ) {
714716 let endpoint = {
715717 clusterIndex : clusterIndex ,
716718 clusterCount : ept . clusters . length ,
@@ -728,7 +730,7 @@ async function collectAttributes(endpointTypes, options) {
728730
729731 ept . clusters . sort ( zclUtil . clusterComparator )
730732
731- ept . clusters . forEach ( ( c ) => {
733+ for ( let c of ept . clusters ) {
732734 let cluster = {
733735 endpointId : ept . endpointId ,
734736 clusterId : asMEI ( c . manufacturerCode , c . code ) ,
@@ -754,18 +756,20 @@ async function collectAttributes(endpointTypes, options) {
754756 c . attributes . sort ( zclUtil . attributeComparator )
755757
756758 // Go over all the attributes in the endpoint and add them to the list.
757- c . attributes . forEach ( ( a ) => {
759+ for ( let a of c . attributes ) {
758760 // typeSize is the size of a buffer needed to hold the attribute, if
759761 // that's known.
760762 let typeSize = a . typeSize
761763 // defaultSize is the size of the attribute in the readonly defaults
762764 // store.
763765 let defaultSize = typeSize
764- let attributeDefaultValue = determineAttributeDefaultValue (
766+ let attributeDefaultValue = await determineAttributeDefaultValue (
765767 a . defaultValue ,
766768 a . type ,
767769 typeSize ,
768- a . isNullable
770+ a . isNullable ,
771+ db ,
772+ sessionId
769773 )
770774 // Various types store the length of the actual content in bytes.
771775 // For those, we can size the default storage to be just big enough for
@@ -963,7 +967,7 @@ async function collectAttributes(endpointTypes, options) {
963967 }
964968 attributeMfgCodes . push ( att )
965969 }
966- } )
970+ }
967971
968972 // Go over the commands
969973 c . commands . sort ( zclUtil . commandComparator )
@@ -1051,10 +1055,10 @@ async function collectAttributes(endpointTypes, options) {
10511055 }
10521056 clusterMfgCodes . push ( clt )
10531057 }
1054- } )
1058+ }
10551059 endpoint . attributeSize = endpointAttributeSize
10561060 endpointList . push ( endpoint )
1057- } )
1061+ }
10581062
10591063 return {
10601064 endpointList : endpointList ,
@@ -1269,7 +1273,7 @@ function endpoint_config(options) {
12691273 collectAttributeSizes ( db , this . global . zclPackageIds , endpointTypes )
12701274 )
12711275 . then ( ( endpointTypes ) =>
1272- collectAttributes ( endpointTypes , collectAttributesOptions )
1276+ collectAttributes ( db , sessionId , endpointTypes , collectAttributesOptions )
12731277 )
12741278 . then ( ( collection ) => {
12751279 Object . assign ( newContext , collection )
0 commit comments