@@ -637,43 +637,40 @@ int wisun_tasklet_set_regulatory_domain(int8_t nwk_interface_id, uint8_t regulat
637
637
638
638
int wisun_tasklet_set_own_certificate (uint8_t * cert , uint16_t cert_len , uint8_t * cert_key , uint16_t cert_key_len )
639
639
{
640
- if (wisun_tasklet_data_ptr ) {
641
- // this API can be only used before first connect()
642
- tr_err ("Already connected" );
643
- return -2 ;
644
- }
645
-
640
+ if (wisun_tasklet_data_ptr && wisun_tasklet_data_ptr -> network_interface_id != INVALID_INTERFACE_ID ) {
641
+ // interface already active write certificates to stack.
642
+ arm_certificate_entry_s arm_cert_entry ;
643
+ arm_cert_entry .cert = cert ;
644
+ arm_cert_entry .cert_len = cert_len ;
645
+ arm_cert_entry .key = cert_key ;
646
+ arm_cert_entry .key_len = cert_key_len ;
647
+ return arm_network_own_certificate_add (& arm_cert_entry );
648
+ }
649
+ // Stack is inactive store the certificates and activate when connect() called
646
650
return wisun_tasklet_store_certificate_data (cert , cert_len , cert_key , cert_key_len , false, false, false);
647
651
}
648
652
649
653
int wisun_tasklet_remove_own_certificates (void )
650
654
{
651
- if (wisun_tasklet_data_ptr ) {
652
- // this API can be only used before first connect()
653
- tr_err ("Already connected" );
654
- return -2 ;
655
- }
656
-
657
655
return wisun_tasklet_store_certificate_data (NULL , 0 , NULL , 0 , true, false, false);
658
656
}
659
657
660
658
int wisun_tasklet_remove_trusted_certificates (void )
661
659
{
662
- if (wisun_tasklet_data_ptr ) {
663
- // this API can be only used before first connect()
664
- tr_err ("Already connected" );
665
- return -2 ;
666
- }
667
-
668
660
return wisun_tasklet_store_certificate_data (NULL , 0 , NULL , 0 , false, true, false);
669
661
}
670
662
671
663
int wisun_tasklet_set_trusted_certificate (uint8_t * cert , uint16_t cert_len )
672
664
{
673
- if (wisun_tasklet_data_ptr ) {
674
- // this API can be only used before first connect()
675
- tr_err ("Already connected" );
676
- return -2 ;
677
- }
665
+ if (wisun_tasklet_data_ptr && wisun_tasklet_data_ptr -> network_interface_id != INVALID_INTERFACE_ID ) {
666
+ // interface already active write certificates to stack.
667
+ arm_certificate_entry_s arm_cert_entry ;
668
+ arm_cert_entry .cert = cert ;
669
+ arm_cert_entry .cert_len = cert_len ;
670
+ arm_cert_entry .key = NULL ;
671
+ arm_cert_entry .key_len = 0 ;
672
+ return arm_network_trusted_certificate_add (& arm_cert_entry );
673
+ }
674
+ // Stack is inactive store the certificates and activate when connect() called
678
675
return wisun_tasklet_store_certificate_data (cert , cert_len , NULL , 0 , false, false, true);
679
676
}
0 commit comments