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