Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
I
IQRF Gateway Daemon
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
38
Issues
38
List
Boards
Labels
Service Desk
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Operations
Operations
Incidents
Environments
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Open source
IQRF Gateway Daemon
Commits
e23f5a93
Commit
e23f5a93
authored
Sep 30, 2020
by
Rostislav Spinar
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'feature/reloadDrivers'
parents
5642feba
7ea882fb
Changes
7
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
199 additions
and
133 deletions
+199
-133
src/IqmeshServices/BondNodeLocalService/BondNodeLocalService.cpp
...eshServices/BondNodeLocalService/BondNodeLocalService.cpp
+10
-10
src/IqmeshServices/EnumerateDeviceService/EnumerateDeviceService.cpp
...ervices/EnumerateDeviceService/EnumerateDeviceService.cpp
+10
-10
src/IqmeshServices/SmartConnectService/SmartConnectService.cpp
...qmeshServices/SmartConnectService/SmartConnectService.cpp
+10
-10
src/IqrfInfo/IqrfInfo.cpp
src/IqrfInfo/IqrfInfo.cpp
+50
-35
src/JsCache/JsCache.cpp
src/JsCache/JsCache.cpp
+81
-46
src/JsCache/JsCache.h
src/JsCache/JsCache.h
+10
-7
src/include/IJsCacheService.h
src/include/IJsCacheService.h
+28
-15
No files found.
src/IqmeshServices/BondNodeLocalService/BondNodeLocalService.cpp
View file @
e23f5a93
...
...
@@ -718,14 +718,14 @@ namespace iqrf {
// manufacturer name and product name
const
IJsCacheService
::
Manufacturer
*
manufacturer
=
m_iJsCacheService
->
getManufacturer
(
bondResult
.
getBondedNodeHwpId
());
if
(
manufacturer
!=
nullptr
)
{
bondResult
.
setManufacturer
(
manufacturer
->
m_name
);
IJsCacheService
::
Manufacturer
manufacturer
=
m_iJsCacheService
->
getManufacturer
(
bondResult
.
getBondedNodeHwpId
());
if
(
manufacturer
.
m_manufacturerId
>
-
1
)
{
bondResult
.
setManufacturer
(
manufacturer
.
m_name
);
}
const
IJsCacheService
::
Product
*
product
=
m_iJsCacheService
->
getProduct
(
bondResult
.
getBondedNodeHwpId
());
if
(
product
!=
nullptr
)
{
bondResult
.
setProduct
(
product
->
m_name
);
IJsCacheService
::
Product
product
=
m_iJsCacheService
->
getProduct
(
bondResult
.
getBondedNodeHwpId
());
if
(
product
.
m_manufacturerId
>
1
)
{
bondResult
.
setProduct
(
product
.
m_name
);
}
//uint8_t osVersion = bondResult.getOsRead()[4];
...
...
@@ -750,16 +750,16 @@ namespace iqrf {
return
bondResult
;
}
const
IJsCacheService
::
Package
*
package
=
m_iJsCacheService
->
getPackage
(
IJsCacheService
::
Package
package
=
m_iJsCacheService
->
getPackage
(
bondResult
.
getBondedNodeHwpId
(),
bondResult
.
getBondedNodeHwpIdVer
(),
osBuildStr
,
//TODO m_iIqrfDpaService->getCoordinatorParameters().osBuild ?
m_iIqrfDpaService
->
getCoordinatorParameters
().
dpaVerWordAsStr
);
if
(
package
!=
nullptr
)
{
if
(
package
.
m_packageId
>
-
1
)
{
std
::
list
<
std
::
string
>
standards
;
for
(
const
IJsCacheService
::
StdDriver
*
driver
:
package
->
m_stdDriverVect
)
{
standards
.
push_back
(
driver
->
getName
());
for
(
const
IJsCacheService
::
StdDriver
&
driver
:
package
.
m_stdDriverVect
)
{
standards
.
push_back
(
driver
.
getName
());
}
bondResult
.
setStandards
(
standards
);
}
...
...
src/IqmeshServices/EnumerateDeviceService/EnumerateDeviceService.cpp
View file @
e23f5a93
...
...
@@ -1033,17 +1033,17 @@ namespace iqrf {
osRead
(
deviceEnumerateResult
);
// Obtains hwpId, which in turn is needed to get manufacturer and product
const
IJsCacheService
::
Manufacturer
*
manufacturer
=
m_iJsCacheService
->
getManufacturer
(
deviceEnumerateResult
.
getEnumeratedNodeHwpId
()
);
if
(
manufacturer
!=
nullptr
)
deviceEnumerateResult
.
setManufacturer
(
manufacturer
->
m_name
);
const
IJsCacheService
::
Product
*
product
=
m_iJsCacheService
->
getProduct
(
deviceEnumerateResult
.
getEnumeratedNodeHwpId
()
);
if
(
product
!=
nullptr
)
deviceEnumerateResult
.
setProduct
(
product
->
m_name
);
IJsCacheService
::
Manufacturer
manufacturer
=
m_iJsCacheService
->
getManufacturer
(
deviceEnumerateResult
.
getEnumeratedNodeHwpId
()
);
if
(
manufacturer
.
m_manufacturerId
>
-
1
)
deviceEnumerateResult
.
setManufacturer
(
manufacturer
.
m_name
);
IJsCacheService
::
Product
product
=
m_iJsCacheService
->
getProduct
(
deviceEnumerateResult
.
getEnumeratedNodeHwpId
()
);
if
(
product
.
m_manufacturerId
>
-
1
)
deviceEnumerateResult
.
setProduct
(
product
.
m_name
);
// Peripheral enumeration
peripheralEnumeration
(
deviceEnumerateResult
);
const
IJsCacheService
::
Package
*
package
=
nullptr
;
IJsCacheService
::
Package
package
;
if
(
deviceEnumerateResult
.
getPerEnum
()
&&
deviceEnumerateResult
.
getOsRead
())
{
package
=
m_iJsCacheService
->
getPackage
(
deviceEnumerateResult
.
getEnumeratedNodeHwpId
(),
...
...
@@ -1052,11 +1052,11 @@ namespace iqrf {
deviceEnumerateResult
.
getPerEnum
()
->
getDpaVerAsHexaString
()
);
}
if
(
package
!=
nullptr
)
if
(
package
.
m_packageId
>
-
1
)
{
std
::
list
<
std
::
string
>
standards
;
for
(
const
IJsCacheService
::
StdDriver
*
driver
:
package
->
m_stdDriverVect
)
{
standards
.
push_back
(
driver
->
getName
()
);
for
(
const
IJsCacheService
::
StdDriver
&
driver
:
package
.
m_stdDriverVect
)
{
standards
.
push_back
(
driver
.
getName
()
);
}
deviceEnumerateResult
.
setStandards
(
standards
);
}
...
...
src/IqmeshServices/SmartConnectService/SmartConnectService.cpp
View file @
e23f5a93
...
...
@@ -551,14 +551,14 @@ namespace iqrf {
return
smartConnectResult
;
}
const
IJsCacheService
::
Manufacturer
*
manufacturer
=
m_iJsCacheService
->
getManufacturer
(
smartConnectResult
.
getHwpId
()
);
if
(
manufacturer
!=
nullptr
)
{
smartConnectResult
.
setManufacturer
(
manufacturer
->
m_name
);
IJsCacheService
::
Manufacturer
manufacturer
=
m_iJsCacheService
->
getManufacturer
(
smartConnectResult
.
getHwpId
()
);
if
(
manufacturer
.
m_manufacturerId
>
-
1
)
{
smartConnectResult
.
setManufacturer
(
manufacturer
.
m_name
);
}
const
IJsCacheService
::
Product
*
product
=
m_iJsCacheService
->
getProduct
(
smartConnectResult
.
getHwpId
());
if
(
product
!=
nullptr
)
{
smartConnectResult
.
setProduct
(
product
->
m_name
);
IJsCacheService
::
Product
product
=
m_iJsCacheService
->
getProduct
(
smartConnectResult
.
getHwpId
());
if
(
product
.
m_manufacturerId
>
-
1
)
{
smartConnectResult
.
setProduct
(
product
.
m_name
);
}
//uint8_t osVersion = smartConnectResult.getOsRead()[4];
...
...
@@ -579,16 +579,16 @@ namespace iqrf {
return
smartConnectResult
;
}
const
IJsCacheService
::
Package
*
package
=
m_iJsCacheService
->
getPackage
(
IJsCacheService
::
Package
package
=
m_iJsCacheService
->
getPackage
(
smartConnectResult
.
getHwpId
(),
smartConnectResult
.
getHwpIdVersion
(),
osBuildStr
,
m_iIqrfDpaService
->
getCoordinatorParameters
().
dpaVerWordAsStr
);
if
(
package
!=
nullptr
)
{
if
(
package
.
m_packageId
>
-
1
)
{
std
::
list
<
std
::
string
>
standards
;
for
(
const
IJsCacheService
::
StdDriver
*
driver
:
package
->
m_stdDriverVect
)
{
standards
.
push_back
(
driver
->
getName
()
);
for
(
const
IJsCacheService
::
StdDriver
&
driver
:
package
.
m_stdDriverVect
)
{
standards
.
push_back
(
driver
.
getName
()
);
}
smartConnectResult
.
setStandards
(
standards
);
}
...
...
src/IqrfInfo/IqrfInfo.cpp
View file @
e23f5a93
...
...
@@ -124,7 +124,7 @@ namespace iqrf {
std
::
string
m_handlerUrl
;
std
::
string
m_customDriver
;
bool
m_inRepo
;
std
::
vector
<
const
IJsCacheService
::
StdDriver
*
>
m_drivers
;
std
::
vector
<
IJsCacheService
::
StdDriver
>
m_drivers
;
};
// aux class for enumeration
...
...
@@ -571,31 +571,31 @@ namespace iqrf {
std
::
map
<
int
,
double
>
perVerMap
;
// Get for hwpid 0 plain DPA plugin
const
iqrf
::
IJsCacheService
::
Package
*
pckg0
=
m_iJsCacheService
->
getPackage
((
uint16_t
)
0
,
(
uint16_t
)
0
,
(
uint16_t
)
d
.
m_osBuild
,
(
uint16_t
)
d
.
m_dpaVer
);
if
(
nullptr
==
pckg
0
)
{
iqrf
::
IJsCacheService
::
Package
pckg0
=
m_iJsCacheService
->
getPackage
((
uint16_t
)
0
,
(
uint16_t
)
0
,
(
uint16_t
)
d
.
m_osBuild
,
(
uint16_t
)
d
.
m_dpaVer
);
if
(
pckg0
.
m_packageId
<
0
)
{
TRC_WARNING
(
"Cannot find package for:"
<<
NAME_PAR
(
hwpid
,
0
)
<<
NAME_PAR
(
hwpidVer
,
0
)
<<
NAME_PAR
(
osBuild
,
d
.
m_osBuild
)
<<
NAME_PAR
(
dpaVer
,
d
.
m_dpaVer
)
<<
std
::
endl
<<
"trying to find the package for previous version of DPA"
);
for
(
uint16_t
dpa
=
(
uint16_t
)
d
.
m_dpaVer
-
1
;
dpa
>
300
;
dpa
--
)
{
pckg0
=
m_iJsCacheService
->
getPackage
((
uint16_t
)
0
,
(
uint16_t
)
0
,
(
uint16_t
)
d
.
m_osBuild
,
dpa
);
if
(
nullptr
!=
pckg0
)
{
if
(
pckg0
.
m_packageId
>
-
1
)
{
TRC_WARNING
(
"Found and loading package for:"
<<
NAME_PAR
(
hwpid
,
0
)
<<
NAME_PAR
(
hwpidVer
,
0
)
<<
NAME_PAR
(
osBuild
,
d
.
m_osBuild
)
<<
NAME_PAR
(
dpaVer
,
dpa
));
break
;
}
}
}
if
(
nullptr
!=
pckg0
)
{
if
(
pckg0
.
m_packageId
>
-
1
)
{
for
(
auto
per
:
nd
->
getEmbedExploreEnumerate
()
->
getEmbedPer
())
{
for
(
auto
drv
:
pckg0
->
m_stdDriverVect
)
{
if
(
drv
->
getId
()
==
-
1
)
{
perVerMap
.
insert
(
std
::
make_pair
(
-
1
,
drv
->
getVersion
()));
// driver library
for
(
const
auto
&
drv
:
pckg0
.
m_stdDriverVect
)
{
if
(
drv
.
getId
()
==
-
1
)
{
perVerMap
.
insert
(
std
::
make_pair
(
-
1
,
drv
.
getVersion
()));
// driver library
}
if
(
drv
->
getId
()
==
255
)
{
perVerMap
.
insert
(
std
::
make_pair
(
255
,
drv
->
getVersion
()));
// embedExplore library
if
(
drv
.
getId
()
==
255
)
{
perVerMap
.
insert
(
std
::
make_pair
(
255
,
drv
.
getVersion
()));
// embedExplore library
}
if
(
drv
->
getId
()
==
per
)
{
perVerMap
.
insert
(
std
::
make_pair
(
per
,
drv
->
getVersion
()));
if
(
drv
.
getId
()
==
per
)
{
perVerMap
.
insert
(
std
::
make_pair
(
per
,
drv
.
getVersion
()));
}
}
}
...
...
@@ -621,8 +621,8 @@ namespace iqrf {
}
for
(
auto
pv
:
perVerMap
)
{
const
IJsCacheService
::
StdDriver
*
sd
=
m_iJsCacheService
->
getDriver
(
pv
.
first
,
pv
.
second
);
if
(
sd
)
{
IJsCacheService
::
StdDriver
sd
=
m_iJsCacheService
->
getDriver
(
pv
.
first
,
pv
.
second
);
if
(
sd
.
isValid
()
)
{
d
.
m_drivers
.
push_back
(
sd
);
}
}
...
...
@@ -1018,13 +1018,13 @@ namespace iqrf {
Device
device
(
hwpid
,
hwpidVer
,
osBuild
,
dpaVer
);
// get package from JsCache if exists
const
iqrf
::
IJsCacheService
::
Package
*
pckg
=
nullptr
;
iqrf
::
IJsCacheService
::
Package
pckg
;
if
(
hwpid
!=
0
)
{
// no custom handler => use default pckg0 to resolve periferies
pckg
=
m_iJsCacheService
->
getPackage
((
uint16_t
)
hwpid
,
(
uint16_t
)
hwpidVer
,
(
uint16_t
)
osBuild
,
(
uint16_t
)
dpaVer
);
}
if
(
pckg
)
{
deviceIdPtr
=
enumerateDeviceInRepo
(
device
,
*
pckg
);
if
(
pckg
.
m_packageId
>
-
1
)
{
deviceIdPtr
=
enumerateDeviceInRepo
(
device
,
pckg
);
}
else
{
try
{
...
...
@@ -1219,10 +1219,10 @@ namespace iqrf {
else
{
TRC_WARNING
(
"Inconsistency in driver versions: "
<<
PAR
(
driverId
)
<<
" no version"
);
}
const
IJsCacheService
::
StdDriver
*
driver
=
nullpt
r
;
IJsCacheService
::
StdDriver
drive
r
;
driver
=
m_iJsCacheService
->
getDriver
(
driverId
,
driverVer
);
if
(
driver
)
{
str2load
+=
driver
->
getDriver
();
if
(
driver
.
isValid
()
)
{
str2load
+=
driver
.
getDriver
();
}
else
{
TRC_WARNING
(
"Inconsistency in driver versions: "
<<
PAR
(
driverId
)
<<
PAR
(
driverVer
)
<<
" no driver found"
);
...
...
@@ -1461,6 +1461,17 @@ namespace iqrf {
TRC_FUNCTION_LEAVE
(
""
);
}
void
reloadDrivers
()
{
TRC_FUNCTION_ENTER
(
""
);
loadProvisoryDrivers
();
//TODO
TRC_FUNCTION_LEAVE
(
""
);
}
void
bondedInDb
(
int
nadr
,
int
dis
,
unsigned
mid
,
int
enm
)
{
TRC_FUNCTION_ENTER
(
PAR
(
nadr
)
<<
PAR
(
dis
)
<<
PAR
(
enm
));
...
...
@@ -1492,7 +1503,7 @@ namespace iqrf {
TRC_FUNCTION_LEAVE
(
""
);
}
std
::
unique_ptr
<
int
>
selectDriver
(
const
IJsCacheService
::
StdDriver
*
drv
)
std
::
unique_ptr
<
int
>
selectDriver
(
const
IJsCacheService
::
StdDriver
&
drv
)
{
std
::
unique_ptr
<
int
>
id
;
...
...
@@ -1504,8 +1515,8 @@ namespace iqrf {
"d.StandardId = ? and "
"d.Version = ? "
";"
<<
drv
->
getId
()
<<
drv
->
getVersion
()
<<
drv
.
getId
()
<<
drv
.
getVersion
()
>>
[
&
](
std
::
unique_ptr
<
int
>
d
)
{
id
=
std
::
move
(
d
);
...
...
@@ -1515,13 +1526,13 @@ namespace iqrf {
}
// check id device exist and if not insert and return id
int
driverInDb
(
const
IJsCacheService
::
StdDriver
*
drv
)
int
driverInDb
(
const
IJsCacheService
::
StdDriver
&
drv
)
{
TRC_FUNCTION_ENTER
(
NAME_PAR
(
standardId
,
drv
->
getId
())
<<
NAME_PAR
(
version
,
drv
->
getVersion
())
<<
NAME_PAR
(
name
,
drv
->
getName
()));
TRC_FUNCTION_ENTER
(
NAME_PAR
(
standardId
,
drv
.
getId
())
<<
NAME_PAR
(
version
,
drv
.
getVersion
())
<<
NAME_PAR
(
name
,
drv
.
getName
()));
std
::
string
name
=
drv
->
getName
();
int
standardId
=
drv
->
getId
();
double
version
=
drv
->
getVersion
();
std
::
string
name
=
drv
.
getName
();
int
standardId
=
drv
.
getId
();
double
version
=
drv
.
getVersion
();
database
&
db
=
*
m_db
;
...
...
@@ -1545,12 +1556,12 @@ namespace iqrf {
", ?"
", ?"
");"
<<
drv
->
getNotes
()
<<
drv
.
getNotes
()
<<
name
<<
version
<<
standardId
<<
drv
->
getVersionFlags
()
<<
drv
->
getDriver
()
<<
drv
.
getVersionFlags
()
<<
drv
.
getDriver
()
;
}
...
...
@@ -2530,14 +2541,16 @@ namespace iqrf {
modify
(
props
);
m_iIqrfDpaService
->
registerAnyMessageHandler
(
m_instanceName
,
[
&
](
const
DpaMessage
&
msg
)
{
m_iIqrfDpaService
->
registerAnyMessageHandler
(
m_instanceName
,
[
&
](
const
DpaMessage
&
msg
)
{
analyzeAnyMessage
(
msg
);
}
);
});
initDb
();
m_iJsCacheService
->
registerCacheReloadedHandler
(
m_instanceName
,
[
&
]()
{
reloadDrivers
();
});
loadProvisoryDrivers
();
m_repeatEnum
=
false
;
...
...
@@ -2597,6 +2610,8 @@ namespace iqrf {
m_enumThread
.
join
();
}
m_iJsCacheService
->
unregisterCacheReloadedHandler
(
m_instanceName
);
m_iIqrfDpaService
->
unregisterAnyMessageHandler
(
m_instanceName
);
TRC_FUNCTION_LEAVE
(
""
)
...
...
src/JsCache/JsCache.cpp
View file @
e23f5a93
...
...
@@ -92,6 +92,8 @@ namespace iqrf {
bool
m_upToDate
=
false
;
std
::
map
<
std
::
string
,
CacheReloadedFunc
>
m_cacheReloadedHndlMap
;
public:
Imp
()
{
...
...
@@ -101,95 +103,95 @@ namespace iqrf {
{
}
const
StdDriver
*
getDriver
(
int
id
,
double
ver
)
const
StdDriver
getDriver
(
int
id
,
double
ver
)
const
{
TRC_FUNCTION_ENTER
(
PAR
(
id
)
<<
std
::
fixed
<<
std
::
setprecision
(
2
)
<<
PAR
(
ver
));
const
StdDriver
*
drv
=
nullptr
;
StdDriver
drv
;
auto
foundDrv
=
m_standardMap
.
find
(
id
);
if
(
foundDrv
!=
m_standardMap
.
end
())
{
const
StdItem
&
stdItem
=
foundDrv
->
second
;
auto
foundVer
=
stdItem
.
m_drivers
.
find
(
ver
);
if
(
foundVer
!=
stdItem
.
m_drivers
.
end
())
{
drv
=
&
foundVer
->
second
;
drv
=
foundVer
->
second
;
}
}
TRC_FUNCTION_LEAVE
(
PAR
(
drv
));
TRC_FUNCTION_LEAVE
(
PAR
(
drv
.
isValid
()
));
return
drv
;
}
const
Manufacturer
*
getManufacturer
(
uint16_t
hwpid
)
const
Manufacturer
getManufacturer
(
uint16_t
hwpid
)
const
{
TRC_FUNCTION_ENTER
(
PAR
(
hwpid
));
std
::
lock_guard
<
std
::
recursive_mutex
>
lck
(
m_updateMtx
);
const
Manufacturer
*
retval
=
nullpt
r
;
Manufacturer
manufacture
r
;
auto
found
=
m_productMap
.
find
(
hwpid
);
if
(
found
!=
m_productMap
.
end
())
{
int
manufacturerId
=
found
->
second
.
m_manufacturerId
;
auto
foundManuf
=
m_manufacturerMap
.
find
(
manufacturerId
);
if
(
foundManuf
!=
m_manufacturerMap
.
end
())
{
retval
=
&
(
foundManuf
->
second
)
;
manufacturer
=
foundManuf
->
second
;
}
}
TRC_FUNCTION_LEAVE
(
""
);
return
retval
;
TRC_FUNCTION_LEAVE
(
PAR
(
manufacturer
.
m_manufacturerId
)
);
return
manufacturer
;
}
const
Product
*
getProduct
(
uint16_t
hwpid
)
const
Product
getProduct
(
uint16_t
hwpid
)
const
{
TRC_FUNCTION_ENTER
(
PAR
(
hwpid
));
std
::
lock_guard
<
std
::
recursive_mutex
>
lck
(
m_updateMtx
);
const
Product
*
retval
=
nullptr
;
Product
product
;
auto
found
=
m_productMap
.
find
(
hwpid
);
if
(
found
!=
m_productMap
.
end
())
{
retval
=
&
(
found
->
second
)
;
product
=
found
->
second
;
}
TRC_FUNCTION_LEAVE
(
""
);
return
retval
;
TRC_FUNCTION_LEAVE
(
PAR
(
product
.
m_manufacturerId
)
);
return
product
;
}
const
Package
*
getPackage
(
uint16_t
hwpid
,
uint16_t
hwpidVer
,
const
std
::
string
&
os
,
const
std
::
string
&
dpa
)
const
Package
getPackage
(
uint16_t
hwpid
,
uint16_t
hwpidVer
,
const
std
::
string
&
os
,
const
std
::
string
&
dpa
)
const
{
TRC_FUNCTION_ENTER
(
PAR
(
hwpid
)
<<
PAR
(
hwpidVer
)
<<
PAR
(
os
)
<<
PAR
(
dpa
));
std
::
lock_guard
<
std
::
recursive_mutex
>
lck
(
m_updateMtx
);
const
Package
*
retval
=
nullptr
;
Package
package
;
for
(
const
auto
&
pck
:
m_packageMap
)
{
const
Package
&
pckp
=
pck
.
second
;
if
(
pckp
.
m_hwpid
==
hwpid
&&
pckp
.
m_hwpidVer
==
hwpidVer
&&
pckp
.
m_os
==
os
&&
pckp
.
m_dpa
==
dpa
)
{
retval
=
&
(
pck
.
second
)
;
package
=
pck
.
second
;
break
;
}
}
TRC_FUNCTION_LEAVE
(
PAR
(
retval
));
return
retval
;
TRC_FUNCTION_LEAVE
(
PAR
(
package
.
m_packageId
));
return
package
;
}
const
Package
*
getPackage
(
uint16_t
hwpid
,
uint16_t
hwpidVer
,
uint16_t
os
,
uint16_t
dpa
)
const
Package
getPackage
(
uint16_t
hwpid
,
uint16_t
hwpidVer
,
uint16_t
os
,
uint16_t
dpa
)
const
{
TRC_FUNCTION_ENTER
(
PAR
(
hwpid
)
<<
PAR
(
hwpidVer
)
<<
PAR
(
os
)
<<
PAR
(
dpa
));
std
::
lock_guard
<
std
::
recursive_mutex
>
lck
(
m_updateMtx
);
const
Package
*
retval
=
nullptr
;
Package
package
;
for
(
const
auto
&
pck
:
m_packageMap
)
{
const
Package
&
pckp
=
pck
.
second
;
if
(
pckp
.
m_hwpid
==
hwpid
&&
pckp
.
m_hwpidVer
==
hwpidVer
&&
pckp
.
m_os
==
embed
::
os
::
Read
::
getOsBuildAsString
(
os
)
&&
pckp
.
m_dpa
==
embed
::
explore
::
Enumerate
::
getDpaVerAsHexaString
(
dpa
))
{
retval
=
&
(
pck
.
second
)
;
package
=
pck
.
second
;
break
;
}
}
TRC_FUNCTION_LEAVE
(
PAR
(
retval
)
<<
NAME_PAR
(
packageId
,
(
retval
?
retval
->
m_packageId
:
-
1
)
));
return
retval
;
TRC_FUNCTION_LEAVE
(
PAR
(
package
.
m_packageId
));
return
package
;
}
std
::
map
<
int
,
std
::
map
<
double
,
std
::
vector
<
std
::
pair
<
int
,
int
>>>>
getDrivers
(
const
std
::
string
&
os
,
const
std
::
string
&
dpa
)
...
...
@@ -206,8 +208,8 @@ namespace iqrf {
const
Package
&
p
=
pck
.
second
;
if
(
p
.
m_os
==
os
&&
p
.
m_dpa
==
dpa
)
{
for
(
const
auto
&
drv
:
p
.
m_stdDriverVect
)
{
map2
[
drv
->
getId
()][
drv
->
getVersion
()].
push_back
(
std
::
make_pair
(
p
.
m_hwpid
,
p
.
m_hwpidVer
));
ostr
<<
'['
<<
drv
->
getId
()
<<
','
<<
std
::
fixed
<<
std
::
setprecision
(
2
)
<<
drv
->
getVersion
()
<<
"] "
;
map2
[
drv
.
getId
()][
drv
.
getVersion
()].
push_back
(
std
::
make_pair
(
p
.
m_hwpid
,
p
.
m_hwpidVer
));
ostr
<<
'['
<<
drv
.
getId
()
<<
','
<<
std
::
fixed
<<
std
::
setprecision
(
2
)
<<
drv
.
getVersion
()
<<
"] "
;
}
}
}
...
...
@@ -269,32 +271,32 @@ namespace iqrf {
return
retval
;
}
const
IJsCacheService
::
OsDpa
*
getOsDpa
(
int
id
)
const
IJsCacheService
::
OsDpa
getOsDpa
(
int
id
)
const
{
TRC_FUNCTION_ENTER
(
PAR
(
id
));
std
::
lock_guard
<
std
::
recursive_mutex
>
lck
(
m_updateMtx
);
const
OsDpa
*
retval
=
nullptr
;
OsDpa
retval
;
auto
found
=
m_osDpaMap
.
find
(
id
);
if
(
found
!=
m_osDpaMap
.
end
())
{
retval
=
&
(
found
->
second
)
;
retval
=
found
->
second
;
}
TRC_FUNCTION_LEAVE
(
""
);
return
retval
;
}
const
IJsCacheService
::
OsDpa
*
getOsDpa
(
const
std
::
string
&
os
,
const
std
::
string
&
dpa
)
const
IJsCacheService
::
OsDpa
getOsDpa
(
const
std
::
string
&
os
,
const
std
::
string
&
dpa
)
const
{
TRC_FUNCTION_ENTER
(
PAR
(
os
)
<<
PAR
(
dpa
));
std
::
lock_guard
<
std
::
recursive_mutex
>
lck
(
m_updateMtx
);
const
OsDpa
*
retval
=
nullptr
;
OsDpa
retval
;
for
(
auto
&
a
:
m_osDpaMap
)
{
if
(
os
==
a
.
second
.
m_os
&&
dpa
==
a
.
second
.
m_dpa
)
{
retval
=
&
a
.
second
;
retval
=
a
.
second
;
break
;
}
}
...
...
@@ -313,23 +315,23 @@ namespace iqrf {
return
m_serverState
;
}
const
StdDriver
*
getStandard
(
int
standardId
,
double
version
)
StdDriver
getStandard
(
int
standardId
,
double
version
)
{
TRC_FUNCTION_ENTER
(
PAR
(
standardId
)
<<
std
::
fixed
<<
std
::
setprecision
(
2
)
<<
PAR
(
version
));
std
::
lock_guard
<
std
::
recursive_mutex
>
lck
(
m_updateMtx
);
const
StdDriver
*
retval
=
nullpt
r
;
StdDriver
stdDrive
r
;
auto
found
=
m_standardMap
.
find
(
standardId
);
if
(
found
!=
m_standardMap
.
end
())
{
auto
foundVer
=
found
->
second
.
m_drivers
.
find
(
version
);
if
(
foundVer
!=
found
->
second
.
m_drivers
.
end
())
{
retval
=
&
(
foundVer
->
second
)
;
stdDriver
=
foundVer
->
second
;
}
}
TRC_FUNCTION_LEAVE
(
""
);
return
retval
;
TRC_FUNCTION_LEAVE
(
PAR
(
stdDriver
.
isValid
())
);
return
stdDriver
;
}
bool
parseFromFile
(
const
std
::
string
&
fname
,
rapidjson
::
Document
&
doc
)
...
...
@@ -428,6 +430,17 @@ namespace iqrf {
m_upToDate
=
true
;
TRC_INFORMATION
(
"Loading IqrfRepo cache success"
);
std
::
cout
<<
"Loading IqrfRepo cache success"
<<
std
::
endl
;
//invoke call back
{
std
::
lock_guard
<
std
::
recursive_mutex
>
lck
(
m_updateMtx
);
for
(
auto
&
hndlIt
:
m_cacheReloadedHndlMap
)
{
if
(
hndlIt
.
second
)
{
hndlIt
.
second
();
}
}
}
}
catch
(
std
::
exception
&
e
)
{
CATCH_EXC_TRC_WAR
(
std
::
logic_error
,
e
,
"Loading IqrfRepo cache failed"
);
...
...
@@ -793,6 +806,18 @@ namespace iqrf {
TRC_FUNCTION_LEAVE
(
""
)
}
void
registerCacheReloadedHandler
(
const
std
::
string
&
clientId
,
CacheReloadedFunc
hndl
)
{
std
::
lock_guard
<
std
::
recursive_mutex
>
lck
(
m_updateMtx
);
m_cacheReloadedHndlMap
[
clientId
]
=
hndl
;
}
void
unregisterCacheReloadedHandler
(
const
std
::
string
&
clientId
)
{
std
::
lock_guard
<
std
::
recursive_mutex
>
lck
(
m_updateMtx
);
m_cacheReloadedHndlMap
.
erase
(
clientId
);
}
void
checkCache
()
{
TRC_FUNCTION_ENTER
(
""
);
...
...
@@ -1008,8 +1033,8 @@ namespace iqrf {
for
(
auto
itr
=
standardArray
->
Begin
();
itr
!=
standardArray
->
End
();
++
itr
)
{
POINTER_GET_INT
(
""
,
itr
,
"/standardID"
,
standardId
,
fname
);
POINTER_GET_DOUBLE
(
""
,
itr
,
"/version"
,
version
,
fname
);
const
StdDriver
*
stdDrv
=
getStandard
(
standardId
,
version
);
if
(
stdDrv
)
{
StdDriver
stdDrv
=
getStandard
(
standardId
,
version
);
if
(
stdDrv
.
isValid
()
)
{
pck
.
m_stdDriverVect
.
push_back
(
stdDrv
);
auxtrc
<<
'['
<<
standardId
<<
','
<<
std
::
fixed
<<
std
::
setprecision
(
2
)
<<
version
<<
"], "
;
}
...
...
@@ -1318,27 +1343,27 @@ namespace iqrf {
delete
m_imp
;
}
const
IJsCacheService
::
StdDriver
*
JsCache
::
getDriver
(
int
id
,
double
ver
)
const
IJsCacheService
::
StdDriver
JsCache
::
getDriver
(
int
id
,
double
ver
)
const
{
return
m_imp
->
getDriver
(
id
,
ver
);
}
const
IJsCacheService
::
Manufacturer
*
JsCache
::
getManufacturer
(
uint16_t
hwpid
)
const
IJsCacheService
::
Manufacturer
JsCache
::
getManufacturer
(
uint16_t
hwpid
)
const
{
return
m_imp
->
getManufacturer
(
hwpid
);
}
const
IJsCacheService
::
Product
*
JsCache
::
getProduct
(
uint16_t
hwpid
)
const
IJsCacheService
::
Product
JsCache
::
getProduct
(
uint16_t
hwpid
)
const
{
return
m_imp
->
getProduct
(
hwpid
);
}
const
IJsCacheService
::
Package
*
JsCache
::
getPackage
(
uint16_t
hwpid
,
uint16_t
hwpidVer
,
const
std
::
string
&
os
,
const
std
::
string
&
dpa
)
const
IJsCacheService
::
Package
JsCache
::
getPackage
(
uint16_t
hwpid
,
uint16_t
hwpidVer
,
const
std
::
string
&
os
,
const
std
::
string
&
dpa
)
const
{
return
m_imp
->
getPackage
(
hwpid
,
hwpidVer
,
os
,
dpa
);
}
const
IJsCacheService
::
Package
*
JsCache
::
getPackage
(
uint16_t
hwpid
,
uint16_t
hwpidVer
,
uint16_t
os
,
uint16_t
dpa
)
const
IJsCacheService
::
Package
JsCache
::
getPackage
(
uint16_t
hwpid
,
uint16_t
hwpidVer
,
uint16_t
os
,
uint16_t
dpa
)
const
{
return
m_imp
->
getPackage
(
hwpid
,
hwpidVer
,
os
,
dpa
);
}
...
...
@@ -1358,12 +1383,12 @@ namespace iqrf {
return
m_imp
->
getOsDpa
();