@@ -422,20 +422,15 @@ namespace http {
422
422
}
423
423
424
424
std::string hwid = request::findValue (&req, " idx" );
425
- if (hwid == " " )
426
- return ;
427
- int iHardwareID = atoi (hwid.c_str ());
428
- CDomoticzHardwareBase *pHardware = m_mainworker.GetHardware (iHardwareID);
429
- if (pHardware == NULL )
430
- return ;
431
- if (pHardware->HwdType != HTYPE_BleBox)
425
+ CDomoticzHardwareBase *pBaseHardware = GetHardwareBase (hwid, HTYPE_BleBox);
426
+ if (pBaseHardware == NULL )
432
427
return ;
433
428
434
429
root[" status" ] = " OK" ;
435
430
root[" title" ] = " BleBoxGetNodes" ;
436
431
437
432
std::vector<std::vector<std::string> > result;
438
- result = m_sql.safe_query (" SELECT ID,Name,DeviceID FROM DeviceStatus WHERE (HardwareID==%d )" , iHardwareID );
433
+ result = m_sql.safe_query (" SELECT ID,Name,DeviceID FROM DeviceStatus WHERE (HardwareID=='%d' )" , pBaseHardware-> m_HwdID );
439
434
if (result.size () > 0 )
440
435
{
441
436
std::vector<std::vector<std::string> >::const_iterator itt;
@@ -469,12 +464,9 @@ namespace http {
469
464
(mode2 == " " )
470
465
)
471
466
return ;
472
- int iHardwareID = atoi (hwid.c_str ());
473
- CDomoticzHardwareBase *pBaseHardware = m_mainworker.GetHardware (iHardwareID);
467
+ CDomoticzHardwareBase *pBaseHardware = GetHardwareBase (hwid, HTYPE_BleBox);
474
468
if (pBaseHardware == NULL )
475
469
return ;
476
- if (pBaseHardware->HwdType != HTYPE_BleBox)
477
- return ;
478
470
BleBox *pHardware = reinterpret_cast <BleBox*>(pBaseHardware);
479
471
480
472
root[" status" ] = " OK" ;
@@ -505,12 +497,9 @@ namespace http {
505
497
(ip == " " )
506
498
)
507
499
return ;
508
- int iHardwareID = atoi (hwid.c_str ());
509
- CDomoticzHardwareBase *pBaseHardware = m_mainworker.GetHardware (iHardwareID);
500
+ CDomoticzHardwareBase *pBaseHardware = GetHardwareBase (hwid, HTYPE_BleBox);
510
501
if (pBaseHardware == NULL )
511
502
return ;
512
- if (pBaseHardware->HwdType != HTYPE_BleBox)
513
- return ;
514
503
BleBox *pHardware = reinterpret_cast <BleBox*>(pBaseHardware);
515
504
516
505
root[" status" ] = " OK" ;
@@ -536,12 +525,9 @@ namespace http {
536
525
(ip == " " )
537
526
)
538
527
return ;
539
- int iHardwareID = atoi (hwid.c_str ());
540
- CDomoticzHardwareBase *pBaseHardware = m_mainworker.GetHardware (iHardwareID);
528
+ CDomoticzHardwareBase *pBaseHardware = GetHardwareBase (hwid, HTYPE_BleBox);
541
529
if (pBaseHardware == NULL )
542
530
return ;
543
- if (pBaseHardware->HwdType != HTYPE_BleBox)
544
- return ;
545
531
BleBox *pHardware = reinterpret_cast <BleBox*>(pBaseHardware);
546
532
547
533
root[" status" ] = " OK" ;
@@ -564,12 +550,9 @@ namespace http {
564
550
(nodeid == " " )
565
551
)
566
552
return ;
567
- int iHardwareID = atoi (hwid.c_str ());
568
- CDomoticzHardwareBase *pBaseHardware = m_mainworker.GetHardware (iHardwareID);
553
+ CDomoticzHardwareBase *pBaseHardware = GetHardwareBase (hwid, HTYPE_BleBox);
569
554
if (pBaseHardware == NULL )
570
555
return ;
571
- if (pBaseHardware->HwdType != HTYPE_BleBox)
572
- return ;
573
556
BleBox *pHardware = reinterpret_cast <BleBox*>(pBaseHardware);
574
557
575
558
root[" status" ] = " OK" ;
@@ -586,14 +569,9 @@ namespace http {
586
569
}
587
570
588
571
std::string hwid = request::findValue (&req, " idx" );
589
- if (hwid == " " )
590
- return ;
591
- int iHardwareID = atoi (hwid.c_str ());
592
- CDomoticzHardwareBase *pBaseHardware = m_mainworker.GetHardware (iHardwareID);
572
+ CDomoticzHardwareBase *pBaseHardware = GetHardwareBase (hwid, HTYPE_BleBox);
593
573
if (pBaseHardware == NULL )
594
574
return ;
595
- if (pBaseHardware->HwdType != HTYPE_BleBox)
596
- return ;
597
575
BleBox *pHardware = reinterpret_cast <BleBox*>(pBaseHardware);
598
576
599
577
root[" status" ] = " OK" ;
0 commit comments